Skip to content

Commit

Permalink
Add SemVerMatches tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaScorpion committed Dec 9, 2023
1 parent bba3aba commit 586b80d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions internal/semver_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package internal

import "testing"

func TestSemVerMatches(t *testing.T) {
cases := [][]any{
{"1.2.3", "1.2.3", true},
{"1.2.3", "1.2", true},
{"1.2.3", "1", true},
{"invalid", "2.0.0", false},
{"2.0.0", "invalid", false},
{"", "3.0.0", false},
{"4.0.0", "v4", true},
{"v4.0.0", "4", true},
{" 5.0.0 ", "5.0.0", true},
{"5.0.0 ", " 5.0.0 ", true},
}

for _, c := range cases {
a := c[0].(string)
b := c[1].(string)
expected := c[2].(bool)
actual := SemVerMatches(a, b)
if actual != expected {
t.Errorf("SemVerMatches(%s, %s) = %t, expected %t", a, b, actual, expected)
}
}
}

0 comments on commit 586b80d

Please sign in to comment.