forked from spring1843/go-dsa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
look_and_tell_test.go
40 lines (35 loc) · 857 Bytes
/
look_and_tell_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
package strings
import (
"testing"
)
/*
TestFindDuplicate tests solution(s) with the following signature and problem description:
func LookAndTell(depth int) []string
Given a depth, return the output of look and tell an algorithm where each line reads the
last line. For example "1" is read as "11" (one one), and "11" is read as "21" (two ones).
*/
func TestFindDuplicate(t *testing.T) {
tests := []struct {
depth int
lastLine string
}{
{0, "-1"},
{1, "1"},
{2, "11"},
{3, "21"},
{4, "1211"},
{5, "111221"},
{6, "312211"},
{7, "13112221"},
{8, "1113213211"},
{9, "31131211131221"},
{10, "13211311123113112211"},
}
for i, test := range tests {
tell := LookAndTell(test.depth)
got := tell[len(tell)-1]
if got != test.lastLine {
t.Fatalf("Failed test case #%d. Want %q got %q", i, test.lastLine, got)
}
}
}