Feature/generic type (#19)

Supports generics and any
This commit is contained in:
jeffery
2023-04-07 19:21:05 +08:00
committed by GitHub
parent ce429aed1f
commit 9a8c60b30a
51 changed files with 348 additions and 1127 deletions

View File

@@ -3,27 +3,23 @@ package mapUtil
import "testing"
func TestMapValueExists(t *testing.T) {
m := map[string]interface{}{
m := map[string]string{
"foo": "bar",
"baz": 123,
"qux": []int{1, 2, 3},
"baz": "123",
}
if !MapValueExists(m, "bar") {
t.Errorf("expected MapValueExists to return true for value 'bar'")
}
if !MapValueExists(m, 123) {
if !MapValueExists(m, "123") {
t.Errorf("expected MapValueExists to return true for value 123")
}
if MapValueExists(m, "non-existent") {
t.Errorf("expected MapValueExists to return false for value 'non-existent'")
}
//if MapValueExists(m, []int{1, 2, 3}) {
// t.Errorf("expected MapValueExists to return false for value []int{1, 2, 3}")
//}
}
func TestMapKeyExists(t *testing.T) {
m := map[string]interface{}{
m := map[string]any{
"foo": "bar",
"baz": 123,
"qux": []int{1, 2, 3},