summaryrefslogtreecommitdiffstats
path: root/tests/002-rpmvercmp.phpt
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2023-09-11 10:21:36 +0200
committerRemi Collet <remi@php.net>2023-09-11 10:21:36 +0200
commit64504e8b8fb097d6e849953eb0e4721321c41a27 (patch)
tree6d993631f655de280efa8b6db1c664f0294ae39b /tests/002-rpmvercmp.phpt
parent1662502e7dc10dcd4f17eb304486e2058cbb1d5a (diff)
add optional operator to rpmcmpver for consistency with version_compare
Diffstat (limited to 'tests/002-rpmvercmp.phpt')
-rw-r--r--tests/002-rpmvercmp.phpt44
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