Skip to content

Extend tests of bcmath extension #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
347 changes: 337 additions & 10 deletions ext/bcmath/tests/bcadd.phpt

Large diffs are not rendered by default.

276 changes: 276 additions & 0 deletions ext/bcmath/tests/bcadd_large_numbers.phpt

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions ext/bcmath/tests/bcadd_variation001.phpt

This file was deleted.

191 changes: 191 additions & 0 deletions ext/bcmath/tests/bcadd_zero.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
--TEST--
bcadd() function with number zero
--EXTENSIONS--
bcmath
--INI--
bcmath.scale=0
--FILE--
<?php
require(__DIR__ . "/run_bcmath_tests_function.inc");

$leftSummands = ["0", "0.00", "-0", "-0.00"];
$rightSummands = array_merge($leftSummands, [
"15",
"-15",
"1",
"-9",
"14.14",
"-16.60",
"0.15",
"-0.01",
"15151324141414.412312232141241",
"-132132245132134.1515123765412",
"141241241241241248267654747412",
"-149143276547656984948124912",
"0.1322135476547459213732911312",
"-0.123912932193769965476541321",
]);

run_bcmath_tests($leftSummands, $rightSummands, "+", bcadd(...));

?>
--EXPECT--
Number "0" (scale 0)
0 + 0 = 0
0 + 0.00 = 0
0 + -0 = 0
0 + -0.00 = 0
0 + 15 = 15
0 + -15 = -15
0 + 1 = 1
0 + -9 = -9
0 + 14.14 = 14
0 + -16.60 = -16
0 + 0.15 = 0
0 + -0.01 = 0
0 + 15151324141414.412312232141241 = 15151324141414
0 + -132132245132134.1515123765412 = -132132245132134
0 + 141241241241241248267654747412 = 141241241241241248267654747412
0 + -149143276547656984948124912 = -149143276547656984948124912
0 + 0.1322135476547459213732911312 = 0
0 + -0.123912932193769965476541321 = 0

Number "0.00" (scale 0)
0.00 + 0 = 0
0.00 + 0.00 = 0
0.00 + -0 = 0
0.00 + -0.00 = 0
0.00 + 15 = 15
0.00 + -15 = -15
0.00 + 1 = 1
0.00 + -9 = -9
0.00 + 14.14 = 14
0.00 + -16.60 = -16
0.00 + 0.15 = 0
0.00 + -0.01 = 0
0.00 + 15151324141414.412312232141241 = 15151324141414
0.00 + -132132245132134.1515123765412 = -132132245132134
0.00 + 141241241241241248267654747412 = 141241241241241248267654747412
0.00 + -149143276547656984948124912 = -149143276547656984948124912
0.00 + 0.1322135476547459213732911312 = 0
0.00 + -0.123912932193769965476541321 = 0

Number "-0" (scale 0)
-0 + 0 = 0
-0 + 0.00 = 0
-0 + -0 = 0
-0 + -0.00 = 0
-0 + 15 = 15
-0 + -15 = -15
-0 + 1 = 1
-0 + -9 = -9
-0 + 14.14 = 14
-0 + -16.60 = -16
-0 + 0.15 = 0
-0 + -0.01 = 0
-0 + 15151324141414.412312232141241 = 15151324141414
-0 + -132132245132134.1515123765412 = -132132245132134
-0 + 141241241241241248267654747412 = 141241241241241248267654747412
-0 + -149143276547656984948124912 = -149143276547656984948124912
-0 + 0.1322135476547459213732911312 = 0
-0 + -0.123912932193769965476541321 = 0

Number "-0.00" (scale 0)
-0.00 + 0 = 0
-0.00 + 0.00 = 0
-0.00 + -0 = 0
-0.00 + -0.00 = 0
-0.00 + 15 = 15
-0.00 + -15 = -15
-0.00 + 1 = 1
-0.00 + -9 = -9
-0.00 + 14.14 = 14
-0.00 + -16.60 = -16
-0.00 + 0.15 = 0
-0.00 + -0.01 = 0
-0.00 + 15151324141414.412312232141241 = 15151324141414
-0.00 + -132132245132134.1515123765412 = -132132245132134
-0.00 + 141241241241241248267654747412 = 141241241241241248267654747412
-0.00 + -149143276547656984948124912 = -149143276547656984948124912
-0.00 + 0.1322135476547459213732911312 = 0
-0.00 + -0.123912932193769965476541321 = 0

Number "0" (scale 10)
0 + 0 = 0.0000000000
0 + 0.00 = 0.0000000000
0 + -0 = 0.0000000000
0 + -0.00 = 0.0000000000
0 + 15 = 15.0000000000
0 + -15 = -15.0000000000
0 + 1 = 1.0000000000
0 + -9 = -9.0000000000
0 + 14.14 = 14.1400000000
0 + -16.60 = -16.6000000000
0 + 0.15 = 0.1500000000
0 + -0.01 = -0.0100000000
0 + 15151324141414.412312232141241 = 15151324141414.4123122321
0 + -132132245132134.1515123765412 = -132132245132134.1515123765
0 + 141241241241241248267654747412 = 141241241241241248267654747412.0000000000
0 + -149143276547656984948124912 = -149143276547656984948124912.0000000000
0 + 0.1322135476547459213732911312 = 0.1322135476
0 + -0.123912932193769965476541321 = -0.1239129321

Number "0.00" (scale 10)
0.00 + 0 = 0.0000000000
0.00 + 0.00 = 0.0000000000
0.00 + -0 = 0.0000000000
0.00 + -0.00 = 0.0000000000
0.00 + 15 = 15.0000000000
0.00 + -15 = -15.0000000000
0.00 + 1 = 1.0000000000
0.00 + -9 = -9.0000000000
0.00 + 14.14 = 14.1400000000
0.00 + -16.60 = -16.6000000000
0.00 + 0.15 = 0.1500000000
0.00 + -0.01 = -0.0100000000
0.00 + 15151324141414.412312232141241 = 15151324141414.4123122321
0.00 + -132132245132134.1515123765412 = -132132245132134.1515123765
0.00 + 141241241241241248267654747412 = 141241241241241248267654747412.0000000000
0.00 + -149143276547656984948124912 = -149143276547656984948124912.0000000000
0.00 + 0.1322135476547459213732911312 = 0.1322135476
0.00 + -0.123912932193769965476541321 = -0.1239129321

Number "-0" (scale 10)
-0 + 0 = 0.0000000000
-0 + 0.00 = 0.0000000000
-0 + -0 = 0.0000000000
-0 + -0.00 = 0.0000000000
-0 + 15 = 15.0000000000
-0 + -15 = -15.0000000000
-0 + 1 = 1.0000000000
-0 + -9 = -9.0000000000
-0 + 14.14 = 14.1400000000
-0 + -16.60 = -16.6000000000
-0 + 0.15 = 0.1500000000
-0 + -0.01 = -0.0100000000
-0 + 15151324141414.412312232141241 = 15151324141414.4123122321
-0 + -132132245132134.1515123765412 = -132132245132134.1515123765
-0 + 141241241241241248267654747412 = 141241241241241248267654747412.0000000000
-0 + -149143276547656984948124912 = -149143276547656984948124912.0000000000
-0 + 0.1322135476547459213732911312 = 0.1322135476
-0 + -0.123912932193769965476541321 = -0.1239129321

Number "-0.00" (scale 10)
-0.00 + 0 = 0.0000000000
-0.00 + 0.00 = 0.0000000000
-0.00 + -0 = 0.0000000000
-0.00 + -0.00 = 0.0000000000
-0.00 + 15 = 15.0000000000
-0.00 + -15 = -15.0000000000
-0.00 + 1 = 1.0000000000
-0.00 + -9 = -9.0000000000
-0.00 + 14.14 = 14.1400000000
-0.00 + -16.60 = -16.6000000000
-0.00 + 0.15 = 0.1500000000
-0.00 + -0.01 = -0.0100000000
-0.00 + 15151324141414.412312232141241 = 15151324141414.4123122321
-0.00 + -132132245132134.1515123765412 = -132132245132134.1515123765
-0.00 + 141241241241241248267654747412 = 141241241241241248267654747412.0000000000
-0.00 + -149143276547656984948124912 = -149143276547656984948124912.0000000000
-0.00 + 0.1322135476547459213732911312 = 0.1322135476
-0.00 + -0.123912932193769965476541321 = -0.1239129321
15 changes: 11 additions & 4 deletions ext/bcmath/tests/bccomp.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ bcmath
bcmath.scale=0
--FILE--
<?php
echo bccomp("-1", "5", 4),"\n";
echo bccomp("1928372132132819737213", "8728932001983192837219398127471"),"\n";
echo bccomp("1.00000000000000000001", "1", 2),"\n";
echo bccomp("97321", "2321"),"\n";
echo bccomp("-1", "5", 4), "\n";
echo bccomp("1928372132132819737213", "8728932001983192837219398127471"), "\n";
echo bccomp("1.00000000000000000001", "1", 2), "\n";
echo bccomp("97321", "2321"), "\n";
echo bccomp("0", "14"), "\n";
echo bccomp("1", "0"), "\n";
echo bccomp("0.000", "0", 3), "\n";

?>
--EXPECT--
-1
-1
0
1
-1
1
0
8 changes: 5 additions & 3 deletions ext/bcmath/tests/bccomp_variation001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ bcmath
bcmath.scale=0
--FILE--
<?php
echo bccomp("2.2", "2.2", "2")."\n";
echo bccomp("2.32", "2.2", "2")."\n";
echo bccomp("2.29", "2.3", "2");
echo bccomp("2.2", "2.2", "2") . "\n";
echo bccomp("2.32", "2.2", "2") . "\n";
echo bccomp("2.29", "2.3", "2") . "\n";
echo bccomp("2.29", "0", "2") . "\n";
?>
--EXPECT--
0
1
-1
1
14 changes: 8 additions & 6 deletions ext/bcmath/tests/bccomp_variation002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ bcmath
bcmath.scale=0
--FILE--
<?php
echo bccomp("-2", "-2")."\n";
echo bccomp("-2", "2", "1")."\n";
echo bccomp("-2.29", "-2.3", "2")."\n";
echo bccomp("-2.29", "2.3", "2")."\n";
echo bccomp("2.29", "-2.3", "2")."\n";
echo bccomp("-2.29", "-2.3", "1");
echo bccomp("-2", "-2") . "\n";
echo bccomp("-2", "2", "1") . "\n";
echo bccomp("-2.29", "-2.3", "2") . "\n";
echo bccomp("-2.29", "2.3", "2") . "\n";
echo bccomp("2.29", "-2.3", "2") . "\n";
echo bccomp("-2.29", "-2.3", "1") . "\n";
echo bccomp("-2.29", "0", "1") . "\n";
?>
--EXPECT--
0
Expand All @@ -20,3 +21,4 @@ echo bccomp("-2.29", "-2.3", "1");
-1
1
1
-1
Loading