-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.go
More file actions
66 lines (62 loc) · 1.29 KB
/
test.go
File metadata and controls
66 lines (62 loc) · 1.29 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"reflect"
"testing"
)
func TestSortPhoneNumbers(t *testing.T) {
tests := []struct {
name string
input map[string]string
expected map[string]string
}{
{
name: "empty input",
input: map[string]string{},
expected: map[string]string{},
},
{
name: "one item",
input: map[string]string{
"12345678901": "John",
},
expected: map[string]string{
"12345678901": "John",
},
},
{
name: "multiple items",
input: map[string]string{
"12345678901": "John",
"98765432109": "Jane",
"55555555555": "Jim",
},
expected: map[string]string{
"55555555555": "Jim",
"12345678901": "John",
"98765432109": "Jane",
},
},
{
name: "persian names",
input: map[string]string{
"12345678901": "مهدی",
"98765432109": "اسمان",
},
expected: map[string]string{
"98765432109": "اسمان",
"12345678901": "مهدی1",
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actual := sortPhoneNumbers(test.input)
if !reflect.DeepEqual(actual, test.expected) {
t.Errorf("expected: %v, actual: %v", test.expected, actual)
} else {
fmt.Println("Success Test")
}
})
}
}