-
Notifications
You must be signed in to change notification settings - Fork 1
/
decode_test.go
41 lines (36 loc) · 1.31 KB
/
decode_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
package base256
import (
"bytes"
"io/ioutil"
"testing"
)
var (
decodeSpec = map[string]string{
"x💀🍵👯233🎂💁D": "Equim",
"你好👾🍧🙆🍬🙇🕷👦🍯🚶🍬👱🕸世界": "Hello World!",
"❤❤❤🦁🌐👈🚁🚴🏤🦁🗾🏍🚁🚴🏟🦁🗺👀🚁🚵🏔🦁🗾🖐🚁🏋🗺🐅🕍💓🚠💋🚈🦁🗺👉🚁🚴💒🐖🚇🚴🌺🤑🍠👟🏝👼🌼🙃🚁🏋🏗": "「さやかちゃん、大好きだ!(*^ω^*)」",
"🐗🏰🖖🌅🐗🏰🖕🚆🐈🌐👉🛀👃🏡💬🕷🐗🏰🖖🌄🐗🏰🖕🚆🐈🌐👉🛀👃🏡💬🚠🤘💈🐯🚆💙🚠💥🕋🐯🚅💫🚡🙏🏝🐅🏞🙌🛎👭🏙😕": "👩🏻💻 👨🏻💻咱们工人有力量(",
"🐏🏘💏🌾😮🛀👲🚘🏇🍏": "\xf2\x8e\x88\x31\x1a\xf0\x68\xce\x7a\x3f",
"": "",
" ": "",
}
)
func TestDecode(t *testing.T) {
for k, v := range decodeSpec {
if actual := string(DecodeString(k)); actual != v {
t.Fatalf("expected `%s`, got `%s`", v, actual)
}
}
}
func TestDecoder(t *testing.T) {
for k, v := range decodeSpec {
d := NewDecoder(bytes.NewReader([]byte(k)))
actual, err := ioutil.ReadAll(d)
if err != nil {
t.Fatal(err)
}
if string(actual) != v {
t.Fatalf("expected `%s`, got `%s`", v, actual)
}
}
}