package main import ( "fmt" "sort" "testing" ) func TestLog(t *testing.T) { tests := []struct { input int64 expected int64 }{ {1, 0}, {2, 1}, {0, 0}, {3, 1}, {4, 2}, } for _, test := range tests { actual := Log(test.input) if test.expected != actual { t.Errorf("%d, expected: %d, actual: %d", test.input, test.expected, actual) } } } func TestPow(t *testing.T) { tests := []struct { x int64 n int64 expected int64 }{ {1, 0, 1}, {2, 0, 1}, {0, 0, 1}, {0, 2, 0}, {1, 1, 1}, {1, 2, 1}, {2, 1, 2}, {2, 2, 4}, {2, 3, 8}, {3, 2, 9}, {6, 7, 279936}, } for _, test := range tests { actual := Pow(test.x, test.n) if test.expected != actual { t.Errorf("%d**%d, expected: %d, actual: %d", test.x, test.n, test.expected, actual) } } } func TestPost(t *testing.T) { tests := []struct { size int64 height int64 id int64 expected int64 }{ {14, 4, 7, 0}, {14, 4, 8, 1}, {14, 4, 3, 2}, {14, 4, 5, 9}, {14, 4, 0, 14}, } for _, test := range tests { actual := Post(test.size, test.height, test.id) if test.expected != actual { t.Errorf("%d, %d, expected: %d, actual: %d", test.size, test.id, test.expected, actual) } } } func TestShuffle(t *testing.T) { a := sort.IntSlice([]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) Shuffle(a) fmt.Println(a) }