2015-02-25 06:34:12 -06:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2015-03-19 18:14:08 -05:00
|
|
|
// miscellaneous test helpers
|
|
|
|
|
2015-02-25 06:34:12 -06:00
|
|
|
func CheckInt(name string, got int, expected int, t *testing.T) (err error) {
|
|
|
|
if got != expected {
|
2015-03-23 16:34:05 -05:00
|
|
|
err = fmt.Errorf("status for %v incorrect. expected %v, got %v", name, expected, got)
|
|
|
|
if t != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
2015-02-25 06:34:12 -06:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func CheckDuration(name string, got time.Duration, expected time.Duration, t *testing.T) (err error) {
|
|
|
|
if got != expected {
|
2015-03-23 16:34:05 -05:00
|
|
|
err = fmt.Errorf("status for %v incorrect. expected %v, got %v", name, expected, got)
|
|
|
|
if t != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
2015-02-25 06:34:12 -06:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func ArrayEq(a, b []int) bool {
|
|
|
|
if len(a) != len(b) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
for i := range a {
|
|
|
|
if a[i] != b[i] {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|