diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:54:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:54:43 +0000 |
commit | e4283f6d48b98e764b988b43bbc86b9d52e6ec94 (patch) | |
tree | c8f7f7a6c2f5faa2942d27cefc6fd46cca492656 /tests/unit/versionCompare.js | |
parent | Initial commit. (diff) | |
download | gnome-shell-e4283f6d48b98e764b988b43bbc86b9d52e6ec94.tar.xz gnome-shell-e4283f6d48b98e764b988b43bbc86b9d52e6ec94.zip |
Adding upstream version 43.9.upstream/43.9upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/unit/versionCompare.js')
-rw-r--r-- | tests/unit/versionCompare.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/unit/versionCompare.js b/tests/unit/versionCompare.js new file mode 100644 index 0000000..1997a6c --- /dev/null +++ b/tests/unit/versionCompare.js @@ -0,0 +1,52 @@ +// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- + +// Test cases for version comparison + +const JsUnit = imports.jsUnit; + +const Environment = imports.ui.environment; +Environment.init(); + +const Util = imports.misc.util; + +const tests = [ + { v1: '40', + v2: '40', + res: 0 }, + { v1: '40', + v2: '42', + res: -1 }, + { v1: '42', + v2: '40', + res: 1 }, + { v1: '3.38.0', + v2: '40', + res: -1 }, + { v1: '40', + v2: '3.38.0', + res: 1 }, + { v1: '40', + v2: '3.38.0', + res: 1 }, + { v1: '40.alpha.1.1', + v2: '40', + res: -1 }, + { v1: '40', + v2: '40.alpha.1.1', + res: 1 }, + { v1: '40.beta', + v2: '40', + res: -1 }, + { v1: '40.1', + v2: '40', + res: 1 }, + { v1: '', + v2: '40.alpha', + res: -1 }, +]; + +for (let i = 0; i < tests.length; i++) { + name = 'Test #' + i + ' v1: ' + tests[i].v1 + ', v2: ' + tests[i].v2; + print(name); + JsUnit.assertEquals(name, Util.GNOMEversionCompare (tests[i].v1, tests[i].v2), tests[i].res); +} |