diff options
Diffstat (limited to 'tests/002-rpmvercmp.phpt')
-rw-r--r-- | tests/002-rpmvercmp.phpt | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/002-rpmvercmp.phpt b/tests/002-rpmvercmp.phpt index d83cf67..c53a183 100644 --- a/tests/002-rpmvercmp.phpt +++ b/tests/002-rpmvercmp.phpt @@ -29,11 +29,53 @@ $ok = true; foreach ($cases as $case) { list($a,$b,$expected) = $case; $result = rpmvercmp($a,$b); - if ($result != $expected) { + if ($result !== $expected) { $ok = false; printf("rpmvercmp(%s, %s) = %d when %d expected\n", $a, $b, $result, $expected); } } + +$cases = [ + ['1', '2', '>', false], + ['1', '2', 'gt', false], + ['1', '2', '>=', false], + ['1', '2', 'ge', false], + ['1', '1', '>=', true], + ['1', '1', 'ge', true], + + ['1', '2', '<', true], + ['1', '2', 'lt', true], + ['1', '2', '<=', true], + ['1', '2', 'le', true], + ['1', '1', '<=', true], + ['1', '1', 'le', true], + + ['1', '1', '=', true], + ['1', '1', '==', true], + ['1', '1', 'eq', true], + + ['1', '2', '=', false], + ['1', '2', '==', false], + ['1', '2', 'eq', false], + + ['1', '1', '!=', false], + ['1', '1', '<>', false], + ['1', '1', 'ne', false], + + ['1', '2', '!=', true], + ['1', '2', '<>', true], + ['1', '2', 'ne', true], +]; +foreach ($cases as $case) { + list($a,$b,$op,$expected) = $case; + $result = rpmvercmp($a,$b,$op); + if ($result !== $expected) { + $ok = false; + printf("rpmvercmp(%s, %s, %s) = %s when %s expected\n", + $a, $b, $op, $result ? "true" : "false", $expected ? "true" : "false"); + } +} + if ($ok) echo "OK\n"; ?> Done |