You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gods/utils/comparator_test.go

46 lines
765 B
Go

package utils
import "testing"
func TestIntComparator(t *testing.T) {
tests := [][]interface{}{
{1, 1, 0},
{1, 2, -1},
{2, 1, 1},
{11, 22, -1},
{0, 0, 0},
{1, 0, 1},
{0, 1, -1},
}
for _, test := range tests {
actual := IntComparator(test[0], test[1])
expected := test[2]
if actual != expected {
t.Errorf("Got %v expected %v", actual, expected)
}
}
}
func TestStringComparator(t *testing.T) {
tests := [][]interface{}{
{"a", "a", 0},
{"a", "b", -1},
{"b", "a", 1},
{"aa", "aab", -1},
{"", "", 0},
{"a", "", 1},
{"", "a", -1},
}
for _, test := range tests {
actual := StringComparator(test[0], test[1])
expected := test[2]
if actual != expected {
t.Errorf("Got %v expected %v", actual, expected)
}
}
}