-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbase65536_test.go
55 lines (46 loc) · 1.52 KB
/
base65536_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
44
45
46
47
48
49
50
51
52
53
54
55
package base65536
import (
// test library
"testing"
// other libraries
"strings"
)
func TestEncode(t *testing.T) {
s := "hello world"
expected := "驨ꍬ啯𒁷ꍲᕤ"
actual := Encode(s)
if actual != expected {
t.Errorf("This encoder is not correct.\nexpected: %s\nactual: %s", expected, actual)
}
}
func TestDecode(t *testing.T) {
s := "驨ꍬ啯𒁷ꍲᕤ"
expected := "hello world"
actual := Decode(s)
if actual != expected {
t.Errorf("This encoder is not correct.\nexpected: %s\nactual: %s", expected, actual)
}
}
func TestCorrectnessCheckingJapaneseAndEnglish(t *testing.T) {
str := "Why Japanese!? おかしいやろぉ!! 躊躇って書いてる間に躊躇してまぅわ!"
encodeStr := Encode(str)
decodeStr := Decode(encodeStr)
if str != decodeStr {
t.Errorf("This encode/decode is not correct.\nbefore: %s\nafter: %s", str, decodeStr)
}
}
func TestCorrectnessCheckingAllString(t *testing.T) {
strMap := []string{
"1234567890",
"abcdefghijklmnopqrstuvwxyz",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゐゆゑよらりるれろわをん",
"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤヰユヱヨラリルレロワヲン",
}
str := strings.Join(strMap, "")
encodeStr := Encode(str)
decodeStr := Decode(encodeStr)
if str != decodeStr {
t.Errorf("This encode/decode is not correct.\nbefore: %s\nafter: %s", str, decodeStr)
}
}