-
Notifications
You must be signed in to change notification settings - Fork 27
/
tile_test.go
48 lines (44 loc) · 1.02 KB
/
tile_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
package strutil
import (
"testing"
)
func TestTile(t *testing.T) {
tests := []struct {
pattern string
length int
expected string
}{
{"", 10, ""},
{"-", 10, "----------"},
{"-.", -1, ""},
{"-.", 0, ""},
{"-.", 2, "-."},
{"-.", 1, "-"},
{"-.", 3, "-.-"},
{"-.", 4, "-.-."},
{"-৹", 0, ""},
{"-৹", 2, "-৹"},
{"-৹", 1, "-"},
{"-৹", 3, "-৹-"},
{"-৹", 4, "-৹-৹"},
{".-", 4, ".-.-"},
{".-=", 4, ".-=."},
{".-", 1, "."},
{"-৹_৹", 16, "-৹_৹-৹_৹-৹_৹-৹_৹"},
{"-৹_৹", 17, "-৹_৹-৹_৹-৹_৹-৹_৹-"},
{"-৹_৹", 18, "-৹_৹-৹_৹-৹_৹-৹_৹-৹"},
{"-৹_৹", 19, "-৹_৹-৹_৹-৹_৹-৹_৹-৹_"},
{"-৹_৹", 20, "-৹_৹-৹_৹-৹_৹-৹_৹-৹_৹"},
}
for i, test := range tests {
output := Tile(test.pattern, test.length)
Assert(t, test.expected, output, "Test case %d is not successful\n", i)
}
}
func BenchmarkTile(b *testing.B) {
var s string
for n := 0; n < b.N; n++ {
s = Tile("-.", 10)
}
_ = s
}