Skip to content

Commit 1c31f40

Browse files
committed
Created Array assertions.
1 parent 6653214 commit 1c31f40

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

assert.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package assert
22

33
import (
44
"errors"
5+
"reflect"
56
"testing"
67
)
78

@@ -16,6 +17,17 @@ func Equals[T comparable](t *testing.T, a T, b T, name string) bool {
1617
return equals
1718
}
1819

20+
func EqualsArray[T comparable](t *testing.T, a []T, b []T, name string) bool {
21+
t.Helper()
22+
23+
equals := reflect.DeepEqual(a, b)
24+
if !equals {
25+
t.Errorf("%v is incorrect. Expected: %v, Recieved: %v", name, b, a)
26+
}
27+
28+
return equals
29+
}
30+
1931
func Getter[T comparable](t *testing.T, a func() T, b T, name string) bool {
2032
t.Helper()
2133

@@ -28,6 +40,18 @@ func Getter[T comparable](t *testing.T, a func() T, b T, name string) bool {
2840
return equals
2941
}
3042

43+
func GetterArray[T comparable](t *testing.T, a func() []T, b []T, name string) bool {
44+
t.Helper()
45+
46+
value := a()
47+
equals := reflect.DeepEqual(value, b)
48+
if !equals {
49+
t.Errorf("%v is incorrect. Expected: %v, Recieved: %v", name, b, value)
50+
}
51+
52+
return equals
53+
}
54+
3155
func True(t *testing.T, value bool, message string) bool {
3256
t.Helper()
3357

0 commit comments

Comments
 (0)