summaryrefslogtreecommitdiff
path: root/src/util/util_test.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-05-23 18:41:13 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-05-23 18:42:54 +0900
commitd4216b0dcc13567479d81cc5ad2adedb1443ea8b (patch)
tree6ec7aa3dde44344312e483fce316dcce79e1f087 /src/util/util_test.go
parentbfe2bf4dced665f8752dab5f2ce17b67f6ff8b53 (diff)
downloadfzf-d4216b0dcc13567479d81cc5ad2adedb1443ea8b.tar.gz
Use MSYS=enable_pcon instead of winpty on mintty 3.4.5 or later
Diffstat (limited to 'src/util/util_test.go')
-rw-r--r--src/util/util_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/util/util_test.go b/src/util/util_test.go
index af0762b5..013f3c23 100644
--- a/src/util/util_test.go
+++ b/src/util/util_test.go
@@ -203,3 +203,34 @@ func TestStringWidth(t *testing.T) {
t.Errorf("Expected: %d, Actual: %d", 1, w)
}
}
+
+func TestCompareVersions(t *testing.T) {
+ assert := func(a, b string, expected int) {
+ if result := CompareVersions(a, b); result != expected {
+ t.Errorf("Expected: %d, Actual: %d", expected, result)
+ }
+ }
+
+ assert("2", "1", 1)
+ assert("2", "2", 0)
+ assert("2", "10", -1)
+
+ assert("2.1", "2.2", -1)
+ assert("2.1", "2.1.1", -1)
+
+ assert("1.2.3", "1.2.2", 1)
+ assert("1.2.3", "1.2.3", 0)
+ assert("1.2.3", "1.2.3.0", 0)
+ assert("1.2.3", "1.2.4", -1)
+
+ // Different number of parts
+ assert("1.0.0", "1", 0)
+ assert("1.0.0", "1.0", 0)
+ assert("1.0.0", "1.0.0", 0)
+ assert("1.0", "1.0.0", 0)
+ assert("1", "1.0.0", 0)
+ assert("1.0.0", "1.0.0.1", -1)
+ assert("1.0.0.1.0", "1.0.0.1", 0)
+
+ assert("", "3.4.5", -1)
+}