@@ -11,6 +11,32 @@ func Equals[V comparable](tb testing.TB, got V, exp V) {
11
11
}
12
12
}
13
13
14
+ func EqualsMap [K comparable , V comparable ](tb testing.TB , got map [K ]V , exp map [K ]V ) {
15
+ if len (got ) != len (exp ) {
16
+ tb .Fatalf ("\n exp (len %d): %v\n got (len %d): %v" , len (exp ), exp , len (got ), got )
17
+ }
18
+
19
+ for k , v := range exp {
20
+ if gotV , gotOk := got [k ]; ! gotOk {
21
+ tb .Fatalf ("\n key `%v` in got map not present" , k )
22
+ } else if v != gotV {
23
+ tb .Fatalf ("\n in got[%v]\n exp: %v\n got: %v" , k , v , gotV )
24
+ }
25
+ }
26
+ }
27
+
28
+ func EqualsList [V comparable ](tb testing.TB , got []V , exp []V ) {
29
+ if len (got ) != len (exp ) {
30
+ tb .Fatalf ("\n exp (len %d): %v\n got (len %d): %v" , len (exp ), exp , len (got ), got )
31
+ }
32
+
33
+ for i , v := range exp {
34
+ if got [i ] != v {
35
+ tb .Fatalf ("\n in got[%v]\n exp: %v\n got: %v" , i , v , got [i ])
36
+ }
37
+ }
38
+ }
39
+
14
40
func ExpectError (tb testing.TB , err error , exp string ) {
15
41
if err == nil {
16
42
tb .Fatalf ("expected error, got nil" )
@@ -22,3 +48,9 @@ func ExpectError(tb testing.TB, err error, exp string) {
22
48
func ExpectNil (tb testing.TB , d any ) {
23
49
Equals (tb , fmt .Sprintf ("%v" , d ), "<nil>" )
24
50
}
51
+
52
+ func ExpectNoError (tb testing.TB , err error ) {
53
+ if err != nil {
54
+ tb .Fatalf ("expected none, got error\n error: %s" , err )
55
+ }
56
+ }
0 commit comments