forked from BambooEngine/bamboo-core
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathencoder_test.go
More file actions
47 lines (37 loc) · 1.09 KB
/
Copy pathencoder_test.go
File metadata and controls
47 lines (37 loc) · 1.09 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
package bamboo
import (
"reflect"
"testing"
)
func TestGetCharsetNames(t *testing.T) {
names1 := GetCharsetNames()
names2 := GetCharsetNames()
if len(names1) == 0 {
t.Fatalf("GetCharsetNames returned empty slice")
}
if names1[0] != UNICODE {
t.Errorf("First charset must be %s, got %s", UNICODE, names1[0])
}
if !reflect.DeepEqual(names1, names2) {
t.Errorf("GetCharsetNames order is non-deterministic: %v vs %v", names1, names2)
}
expectedCount := len(charsetDefinitions) + 1
if len(names1) != expectedCount {
t.Errorf("Expected %d charset names, got %d", expectedCount, len(names1))
}
}
func TestEncode(t *testing.T) {
input := "Tiếng Việt"
if got := Encode(UNICODE, input); got != input {
t.Errorf("Encode Unicode failed. Got %s, expected %s", got, input)
}
if got := Encode("NonExistentCharset", input); got != input {
t.Errorf("Encode non-existent charset failed. Got %s, expected %s", got, input)
}
for name := range charsetDefinitions {
out := Encode(name, input)
if len(out) == 0 {
t.Errorf("Encode %s returned empty result for %s", name, input)
}
}
}