-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jesse Schmidt
committed
Aug 6, 2024
1 parent
67d5082
commit fcf06e4
Showing
2 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package avs | ||
|
||
import "testing" | ||
|
||
func TestVersionLTGT(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
v1 version | ||
v2 version | ||
wantLT bool | ||
wantGT bool | ||
}{ | ||
{ | ||
name: "v1 is less than v2", | ||
v1: newVersion("1.0.0"), | ||
v2: newVersion("2.0.0"), | ||
wantLT: true, | ||
wantGT: false, | ||
}, | ||
{ | ||
name: "v1 is greater than v2", | ||
v1: newVersion("2.0.0"), | ||
v2: newVersion("1.0.0"), | ||
wantLT: false, | ||
wantGT: true, | ||
}, | ||
{ | ||
name: "v1 is less than v2", | ||
v1: newVersion("1.0.0"), | ||
v2: newVersion("1.0.1"), | ||
wantLT: true, | ||
wantGT: false, | ||
}, | ||
{ | ||
name: "v1 is less than v2", | ||
v1: newVersion("1.0.0"), | ||
v2: newVersion("1.0.0.dev0"), | ||
wantLT: true, | ||
wantGT: false, | ||
}, | ||
{ | ||
name: "v1 is greater than v2", | ||
v1: newVersion("1.0.0.dev0"), | ||
v2: newVersion("1.0.0"), | ||
wantLT: false, | ||
wantGT: true, | ||
}, | ||
{ | ||
name: "v1 is less than v2", | ||
v1: newVersion("1.0.0.dev0"), | ||
v2: newVersion("1.0.0.dev1"), | ||
wantLT: true, | ||
wantGT: false, | ||
}, | ||
{ | ||
name: "v1 is equal to v2", | ||
v1: newVersion("1.0.0"), | ||
v2: newVersion("1.0.0"), | ||
wantLT: false, | ||
wantGT: false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
got := tc.v1.lt(tc.v2) | ||
if got != tc.wantLT { | ||
t.Errorf("expected %v, got %v", tc.wantLT, got) | ||
} | ||
|
||
got = tc.v1.gt(tc.v2) | ||
if got != tc.wantGT { | ||
t.Errorf("expected %v, got %v", !tc.wantLT, got) | ||
} | ||
}) | ||
} | ||
} |