git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2b2a070)
Expand tests for factorial
2020年6月18日 06:41:31 +0000 (08:41 +0200)
2020年6月18日 06:41:31 +0000 (08:41 +0200)
Move from int4 to numeric test. (They were originally int4 functions,
but were reimplemented for numeric in
04a4821adef38155b7920ba9eb83c4c3c29156f8.) Add some tests for edge
cases.

Discussion: https://www.postgresql.org/message-id/flat/6ce1df0e-86a3-e544-743a-f357ff663f68%402ndquadrant.com


diff --git a/src/test/regress/expected/int4.out b/src/test/regress/expected/int4.out
index c384af18ee89dee5f0dd16ed166cea97aac90e0d..77f43739a7c1f0a7576c7870fbd0a18ec59ad742 100644 (file)
--- a/src/test/regress/expected/int4.out
+++ b/src/test/regress/expected/int4.out
@@ -299,18 +299,6 @@ SELECT int4 '1000' < int4 '999' AS false;
f
(1 row)
-SELECT 4! AS twenty_four;
- twenty_four
--------------
- 24
-(1 row)
-
-SELECT !!3 AS six;
- six
------
- 6
-(1 row)
-
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
ten
-----
diff --git a/src/test/regress/expected/numeric.out b/src/test/regress/expected/numeric.out
index c7fe63d03744432094f86e28532dd928f0ed43e8..b255be7c8520841c3667caf4ddb36a912534ad77 100644 (file)
--- a/src/test/regress/expected/numeric.out
+++ b/src/test/regress/expected/numeric.out
@@ -2315,3 +2315,44 @@ FROM (VALUES (0::numeric, 0::numeric),
SELECT lcm(9999 * (10::numeric)^131068 + (10::numeric^131068 - 1), 2); -- overflow
ERROR: value overflows numeric format
+--
+-- Tests for factorial
+--
+SELECT 4!;
+ ?column?
+----------
+ 24
+(1 row)
+
+SELECT !!3;
+ ?column?
+----------
+ 6
+(1 row)
+
+SELECT factorial(15);
+ factorial
+---------------
+ 1307674368000
+(1 row)
+
+SELECT 100000!;
+ERROR: value overflows numeric format
+SELECT 0!;
+ ?column?
+----------
+ 1
+(1 row)
+
+SELECT -4!;
+ ?column?
+----------
+ 1
+(1 row)
+
+SELECT factorial(-4);
+ factorial
+-----------
+ 1
+(1 row)
+
diff --git a/src/test/regress/sql/int4.sql b/src/test/regress/sql/int4.sql
index a9e90a96c4c092eb22770474af75bddc08ca4686..b00c9dea2a6daa2c48daf1440027db33c4d947d6 100644 (file)
--- a/src/test/regress/sql/int4.sql
+++ b/src/test/regress/sql/int4.sql
@@ -114,10 +114,6 @@ SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true;
SELECT int4 '1000' < int4 '999' AS false;
-SELECT 4! AS twenty_four;
-
-SELECT !!3 AS six;
-
SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten;
SELECT 2 + 2 / 2 AS three;
diff --git a/src/test/regress/sql/numeric.sql b/src/test/regress/sql/numeric.sql
index 41475a9a245f44d063e57c3a5ad62eb49f2848a0..1332a9cf07a6c0dc6a7ab6df6705672636d2c0e5 100644 (file)
--- a/src/test/regress/sql/numeric.sql
+++ b/src/test/regress/sql/numeric.sql
@@ -1111,3 +1111,14 @@ FROM (VALUES (0::numeric, 0::numeric),
(4232.820::numeric, 132.72000::numeric)) AS v(a, b);
SELECT lcm(9999 * (10::numeric)^131068 + (10::numeric^131068 - 1), 2); -- overflow
+
+--
+-- Tests for factorial
+--
+SELECT 4!;
+SELECT !!3;
+SELECT factorial(15);
+SELECT 100000!;
+SELECT 0!;
+SELECT -4!;
+SELECT factorial(-4);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /