diff --git a/pkg/utils_test.go b/pkg/utils_test.go index a7224ef..47c06e1 100644 --- a/pkg/utils_test.go +++ b/pkg/utils_test.go @@ -1,14 +1,37 @@ package gomus_test import ( + "strconv" "testing" gomus "git.cesium.pw/niku/gomus/pkg" ) +func SliceEquals[T string | int](a, b []T) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if a[i] != b[i] { + return false + } + } + return true +} + func TestMapBetween(t *testing.T) { r := gomus.MapFloatBetween(2, 1, 3, 5, 10) if r != 7.5 { t.Fatalf("Expected value to be mapped to #, got: %f", r) } } + +func TestMapList(t *testing.T) { + e := []string{"1", "2", "3"} + r := gomus.MapList([]int{1, 2, 3}, func(i int) string { + return strconv.Itoa(i) + }) + if !SliceEquals(e, r) { + t.Fatalf("Expected list to be mapped to string %s got: %s", e, r) + } +}