|
|
@ -6,6 +6,7 @@ package utils
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func TestIntComparator(t *testing.T) {
|
|
|
|
func TestIntComparator(t *testing.T) {
|
|
|
@ -53,6 +54,26 @@ func TestStringComparator(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestTimeComparator(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
now := time.Now()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// i1,i2,expected
|
|
|
|
|
|
|
|
tests := [][]interface{}{
|
|
|
|
|
|
|
|
{now, now, 0},
|
|
|
|
|
|
|
|
{now.Add(24 * 7 * 2 * time.Hour), now, 1},
|
|
|
|
|
|
|
|
{now, now.Add(24 * 7 * 2 * time.Hour), -1},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
|
|
|
|
actual := TimeComparator(test[0], test[1])
|
|
|
|
|
|
|
|
expected := test[2]
|
|
|
|
|
|
|
|
if actual != expected {
|
|
|
|
|
|
|
|
t.Errorf("Got %v expected %v", actual, expected)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestCustomComparator(t *testing.T) {
|
|
|
|
func TestCustomComparator(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
type Custom struct {
|
|
|
|
type Custom struct {
|
|
|
|