php-src/ext/bcmath/tests/run_bcmath_tests_function.inc
Jorg Adam Sowa ee22612856
Extend tests of bcmath extension (#11563)
Add coverage for:

 * different formats of zero (0, 0.0)
 * small integers and decimals
 * large integers and large decimals with large fractional part
 * negative numbers for all of the above ones
2023-07-05 17:43:30 +01:00

27 lines
652 B
PHP

<?php
const STRING_PADDING = 30;
function run_bcmath_tests(
$firstTerms,
$secondTerms,
$symbol,
$bcmath_function
) {
$scales = [0, 10];
foreach ($scales as $scale) {
foreach ($firstTerms as $firstTerm) {
echo "Number \"$firstTerm\" (scale $scale)\n";
foreach ($secondTerms as $secondTerm) {
echo $firstTerm,
" $symbol ",
str_pad($secondTerm, STRING_PADDING),
" = ",
$bcmath_function($firstTerm, $secondTerm, $scale),
"\n";
}
echo "\n";
}
}
}