-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathencode_test.go
More file actions
41 lines (37 loc) ยท 1.38 KB
/
encode_test.go
File metadata and controls
41 lines (37 loc) ยท 1.38 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
package base256
import (
"bytes"
"testing"
)
var (
encodeSpec = map[string]string{
"Equim": "๐๐ต๐ฏ๐๐",
"Hello World!": "๐พ๐ง๐๐ฌ๐๐ท๐ฆ๐ฏ๐ถ๐ฌ๐ฑ๐ธ",
"ใใใใใกใใใๅคงๅฅฝใใ ๏ผ(*^ฯ^*)ใ": "๐ฆ๐๐๐๐ด๐ค๐ฆ๐พ๐๐๐ด๐๐ฆ๐บ๐๐๐ต๐๐ฆ๐พ๐๐๐๐บ๐
๐๐๐ ๐๐๐ฆ๐บ๐๐๐ด๐๐๐๐ด๐บ๐ค๐ ๐๐๐ผ๐ผ๐๐๐๐",
"๐ฉ๐ปโ๐ป ๐จ๐ปโ๐ปๅฑไปฌๅทฅไบบๆๅ้(": "๐๐ฐ๐๐
๐๐ฐ๐๐๐๐๐๐๐๐ก๐ฌ๐ท๐๐ฐ๐๐๐๐ฐ๐๐๐๐๐๐๐๐ก๐ฌ๐ ๐ค๐๐ฏ๐๐๐ ๐ฅ๐๐ฏ๐
๐ซ๐ก๐๐๐
๐๐๐๐ญ๐๐",
"\xf2\x8e\x88\x31\x1a\xf0\x68\xce\x7a\x3f": "๐๐๐๐พ๐ฎ๐๐ฒ๐๐๐",
"": "",
}
)
func TestEncode(t *testing.T) {
for k, v := range encodeSpec {
if actual := EncodeToString([]byte(k)); actual != v {
t.Fatalf("expected `%s`, got `%s`", v, actual)
}
}
}
func TestEncoder(t *testing.T) {
for k, v := range encodeSpec {
buf := new(bytes.Buffer)
e := NewEncoder(buf)
if _, err := e.Write([]byte(k)); err != nil {
t.Fatal(err)
}
if err := e.Close(); err != nil {
t.Fatal(err)
}
if actual := string(buf.Bytes()); actual != v {
t.Fatalf("expected `%s`, got `%s`", v, actual)
}
}
}