forked from gepaplexx/multena-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_test.go
43 lines (31 loc) · 1.05 KB
/
util_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"sort"
"testing"
"github.com/stretchr/testify/assert"
)
func TestContainsIgnoreCase(t *testing.T) {
slice := []string{"apple", "banana", "orange"}
// Test case: Element exists in the slice (case-insensitive match)
assert.True(t, ContainsIgnoreCase(slice, "Banana"))
// Test case: Element exists in the slice (exact case match)
assert.True(t, ContainsIgnoreCase(slice, "banana"))
// Test case: Element does not exist in the slice
assert.False(t, ContainsIgnoreCase(slice, "grape"))
}
func TestMapKeysToArray(t *testing.T) {
// Test case: Map with string keys
stringMap := map[string]int{"a": 1, "b": 2, "c": 3}
stringKeys := MapKeysToArray(stringMap)
// Sort the keys
sort.Strings(stringKeys)
expectedStringKeys := []string{"a", "b", "c"}
assert.Equal(t, expectedStringKeys, stringKeys)
// Test case: Map with int keys
intMap := map[int]string{1: "a", 2: "b", 3: "c"}
intKeys := MapKeysToArray(intMap)
// Sort the keys
sort.Ints(intKeys)
expectedIntKeys := []int{1, 2, 3}
assert.Equal(t, expectedIntKeys, intKeys)
}