diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/002-rpmvercmp.phpt | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/tests/002-rpmvercmp.phpt b/tests/002-rpmvercmp.phpt index 909ad0f..4f1b051 100644 --- a/tests/002-rpmvercmp.phpt +++ b/tests/002-rpmvercmp.phpt @@ -3,11 +3,34 @@ Check for rpmvercmp function --SKIPIF-- <?php if (!extension_loaded("rpminfo")) print "skip"; ?> --FILE-- -<?php -var_dump(rpmvercmp("1.0", "1.1")); -var_dump(rpmvercmp("1.1", "1.0")); -var_dump(rpmvercmp("1.0", "1.0")); -var_dump(rpmvercmp("2.0.14-22.el7_0", "2.0.14.1-35.el7_6")); +<?php +$cases = [ + ['1.0', '1.1', -1], + ['1.1', '1.0', 1], + ['1.0', '1.0', 0], + ['2.0.14-22.el7_0', '2.0.14.1-35.el7_6', -1], + ['', '', 0], + ['0:1', '1', 0], + ['0:1', '1:1', -1], + ['1:1', '2', 1], + ['1~RC1', '1', -1], + ['1~RC1', '1', -1], + ['1~RC1-1', '1-0', -1], + ['1~beta', '1~RC', 1], + ['1-1', '1-2', -1], + ['1.1-1', '1-1.1', 1], + ['1.1-1~a', '1.1-1', -1], +]; +$ok = true; +foreach ($cases as $case) { + list($a,$b,$expected) = $case; + $result = rpmvercmp($a,$b); + if ($result != $expected) { + $ok = false; + printf("rpmvercmp(%s, %s) = %d when %d expected\n", $a, $b, $result, $expected); + } +} +if ($ok) echo "OK\n"; // Errors var_dump(rpmvercmp()); var_dump(rpmvercmp("a")); @@ -15,10 +38,7 @@ var_dump(rpmvercmp("a", "b", "c")); ?> Done --EXPECTF-- -int(-1) -int(1) -int(0) -int(-1) +OK Warning: rpmvercmp() expects exactly 2 parameters, 0 given in %s/002-rpmvercmp.php on line %d NULL |