-
Notifications
You must be signed in to change notification settings - Fork 3
/
warpper_test.go
68 lines (55 loc) · 2.01 KB
/
warpper_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
56
57
58
59
60
61
62
63
64
65
66
67
68
package mixer
import "testing"
const testWrapperPassword = "mixer123456"
func TestEncodeNumber(t *testing.T) {
source := int64(1234567890)
encode := EncodeNumber(testWrapperPassword, source)
decode, err := DecodeNumber(testWrapperPassword, encode)
if err != nil {
t.Fatal(err)
}
encodePadding := EncodeNumberPadding(testWrapperPassword, source, 32)
decodePadding, err := DecodeNumber(testWrapperPassword, encodePadding)
if err != nil {
t.Fatal(err)
}
t.Logf("\n------------\nsource: %v\nencode: %v\ndecode: %v\nencodePadding: %v\ndecodePadding: %v\n------------\n",
source, encode, decode, encodePadding, decodePadding)
}
func TestEncodeID(t *testing.T) {
source := uint64(9223372036854775808)
encode := EncodeID(testWrapperPassword, source)
decode, err := DecodeID(testWrapperPassword, encode)
if err != nil {
t.Fatal(err)
}
encodePadding := EncodeIDPadding(testWrapperPassword, source, 32)
decodePadding, err := DecodeID(testWrapperPassword, encodePadding)
if err != nil {
t.Fatal(err)
}
t.Logf("\n------------\nsource: %v\nencode: %v\ndecode: %v\nencodePadding: %v\ndecodePadding: %v\n------------\n",
source, encode, decode, encodePadding, decodePadding)
}
func TestEncodeBase32(t *testing.T) {
source := "!@#$%^&*()〇"
encode := EncodeBase32(testWrapperPassword, source)
decode, err := DecodeBase32(testWrapperPassword, encode)
if err != nil {
t.Fatal(err)
}
encodePadding := EncodeBase32Padding(testWrapperPassword, source, 64)
decodePadding, err := DecodeBase32(testWrapperPassword, encodePadding)
if err != nil {
t.Fatal(err)
}
t.Logf("\n------------\nsource: %v\nencode: %v\ndecode: %v\nencodePadding: %v\ndecodePadding: %v\n------------\n",
source, encode, decode, encodePadding, decodePadding)
}
func TestEncodeString(t *testing.T) {
source := "0123456789abcdefgHIJKLMN"
encode := EncodeString(testWrapperPassword, source)
decode := DecodeString(testWrapperPassword, encode)
t.Logf("\n------------\nsource: %v\nencode: %v\ndecode: %v\n------------\n",
source, encode, decode)
}