-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xpm_test.go
51 lines (46 loc) · 1.29 KB
/
xpm_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
package xpm
import (
"fmt"
"testing"
)
var letters = []rune("abcdefghijklmnopqrstuvwxyz")
func TestNum2charcode(t *testing.T) {
if num2charcode(0, letters) != "a" {
t.Errorf("wanted a, got %s", num2charcode(0, letters))
}
if num2charcode(1, letters) != "b" {
t.Errorf("wanted b, got %s", num2charcode(1, letters))
}
if num2charcode(25, letters) != "z" {
t.Errorf("wanted z, got %s", num2charcode(25, letters))
}
if num2charcode(26, letters) != "aa" {
t.Errorf("wanted aa, got %s", num2charcode(26, letters))
}
if num2charcode(27, letters) != "ab" {
t.Errorf("wanted ab, got %s", num2charcode(27, letters))
}
if num2charcode(51, letters) != "az" {
t.Errorf("wanted az, got %s", num2charcode(51, letters))
}
if num2charcode(52, letters) != "ba" {
t.Errorf("wanted ba, got %s", num2charcode(52, letters))
}
if num2charcode(53, letters) != "bb" {
t.Errorf("wanted bb, got %s", num2charcode(53, letters))
}
if inc("zzzzzzzz", letters) != "aaaaaaaaa" {
t.Errorf("wanted aaaaaaaaa, got %s", inc("zzzzzzzz", letters))
}
}
func TestNum2charcode2(t *testing.T) {
for x := 18000; x < 18700; x++ {
//fmt.Println(num2charcode(0, letters,(x))
num2charcode(x, letters)
}
}
func Example_hexify() {
fmt.Println(hexify([]byte{0, 7, 0x80, 0xff}))
// Output:
// [0x00 0x07 0x80 0xff]
}