-
Notifications
You must be signed in to change notification settings - Fork 1
/
typemethods_test.go
90 lines (77 loc) · 1.49 KB
/
typemethods_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package typemethods
import (
"sort"
"testing"
)
//////////////////////////////////////////////
/// Counter
//////////////////////////////////////////////
func TestCounter(t *testing.T) {
c := Counter(0)
println(c)
c.Up()
println(c)
c.Down()
println(c)
}
//////////////////////////////////////////////
/// SortStr
//////////////////////////////////////////////
func TestSortStr(t *testing.T) {
s := sortStr("This is a string to sort")
println(s)
sort.Sort(s)
println(s)
println()
// s1 := "a"
// s1 += "bc"
// println(s1)
// s += "bc"
// ^error
}
//////////////////////////////////////////////
/// SortLines
//////////////////////////////////////////////
func TestSortLines(t *testing.T) {
l := sortLines{
"These",
"are",
"some",
"lines",
"to",
"sort",
}
println(l)
println()
sort.Sort(l)
println(l)
println()
}
//////////////////////////////////////////////
/// BinaryConversion
//////////////////////////////////////////////
func TestBinaryConversion(t *testing.T) {
println(fromBinary("1001"))
println(fromBinary("1111011"))
println(sortInt(9).toBinary())
println(sortInt(123).toBinary())
println()
}
//////////////////////////////////////////////
/// SortInt
//////////////////////////////////////////////
func sortIt(i int64) {
si := sortInt(i)
println(si)
println(si.toBinary())
si.sort()
println(si.toBinary())
println(si)
println()
}
func TestSortInt(t *testing.T) {
intSlice := []int64{7, 13, 14, 8, 9, 123}
for _, i := range intSlice {
sortIt(i)
}
}