Skip to content

Commit f4ffead

Browse files
author
Sander Roobol
committed
Adding tests for the bcmath extension
1 parent 64e45b1 commit f4ffead

File tree

9 files changed

+135
-0
lines changed

9 files changed

+135
-0
lines changed

ext/bcmath/tests/bcadd.phpt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
bcadd() function
3+
--SKIP--
4+
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo bcadd("1", "2"),"\n";
8+
echo bcadd("-1", "5", 4),"\n";
9+
echo bcadd("1928372132132819737213", "8728932001983192837219398127471", 2),"\n";
10+
?>
11+
--EXPECT--
12+
3
13+
4.0000
14+
8728932003911564969352217864684.00

ext/bcmath/tests/bccomp.phpt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
bccomp() function
3+
--SKIP--
4+
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo bccomp("-1", "5", 4),"\n";
8+
echo bccomp("1928372132132819737213", "8728932001983192837219398127471"),"\n";
9+
echo bccomp("1.00000000000000000001", "1", 2),"\n";
10+
echo bccomp("97321", "2321"),"\n";
11+
?>
12+
--EXPECT--
13+
-1
14+
-1
15+
0
16+
1

ext/bcmath/tests/bcdiv.phpt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
bcdiv() function
3+
--SKIP--
4+
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo bcdiv("1", "2"),"\n";
8+
echo bcdiv("1", "2", 2),"\n";
9+
echo bcdiv("-1", "5", 4),"\n";
10+
echo bcdiv("8728932001983192837219398127471", "1928372132132819737213", 2),"\n";
11+
?>
12+
--EXPECT--
13+
0
14+
0.50
15+
-0.2000
16+
4526580661.75

ext/bcmath/tests/bcmod.phpt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
bcmod() function
3+
--SKIP--
4+
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo bcmod("11", "2"),"\n";
8+
echo bcmod("-1", "5"),"\n";
9+
echo bcmod("8728932001983192837219398127471", "1928372132132819737213"),"\n";
10+
?>
11+
--EXPECT--
12+
1
13+
-1
14+
1459434331351930289678

ext/bcmath/tests/bcmul.phpt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
bcmul() function
3+
--SKIP--
4+
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo bcmul("1", "2"),"\n";
8+
echo bcmul("-3", "5"),"\n";
9+
echo bcmul("1234567890", "9876543210"),"\n";
10+
echo bcmul("2.5", "1.5", 2),"\n";
11+
?>
12+
--EXPECT--
13+
2
14+
-15
15+
12193263111263526900
16+
3.75

ext/bcmath/tests/bcpow.phpt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
bcpow() function
3+
--SKIP--
4+
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo bcpow("1", "2"),"\n";
8+
echo bcpow("-2", "5", 4),"\n";
9+
echo bcpow("2", "64"),"\n";
10+
?>
11+
--EXPECT--
12+
1
13+
-32
14+
18446744073709551616

ext/bcmath/tests/bcscale.phpt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
bcscale() function
3+
--SKIP--
4+
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo bcadd("1", "2"),"\n";
8+
bcscale(2);
9+
echo bcadd("1", "2"),"\n";
10+
bcscale(10);
11+
echo bcadd("1", "2"),"\n";
12+
bcscale(0);
13+
echo bcadd("1", "2"),"\n";
14+
?>
15+
--EXPECT--
16+
3
17+
3.00
18+
3.0000000000
19+
3

ext/bcmath/tests/bcsqrt.phpt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
bcsqrt() function
3+
--SKIP--
4+
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo bcsqrt("9"),"\n";
8+
echo bcsqrt("1928372132132819737213", 5),"\n";
9+
?>
10+
--EXPECT--
11+
3
12+
43913234134.28826

ext/bcmath/tests/bcsub.phpt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
bcsub() function
3+
--SKIP--
4+
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
echo bcsub("1", "2"),"\n";
8+
echo bcsub("-1", "5", 4),"\n";
9+
echo bcsub("8728932001983192837219398127471", "1928372132132819737213", 2),"\n";
10+
?>
11+
--EXPECT--
12+
-1
13+
-6.0000
14+
8728932000054820705086578390258.00

0 commit comments

Comments
 (0)