From 6ff89f913d920a6dff19ee8121cc62d2541c097a Mon Sep 17 00:00:00 2001
From: strNophix <nvdpoel01@gmail.com>
Date: Wed, 27 Apr 2022 10:06:53 +0200
Subject: [PATCH] Added unit test MapList

---
 pkg/utils_test.go | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

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)
+	}
+}