-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiamond_test.go
21 lines (18 loc) · 2.83 KB
/
diamond_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package main
import "testing"
func TestMakeDiamond(t *testing.T) {
tables := []struct {
letter byte
diamond string
} {
{'A', "A"},
{'Z', " A\n B B\n C C\n D D\n E E\n F F\n G G\n H H\n I I\n J J\n K K\n L L\n M M\n N N\n O O\n P P\n Q Q\n R R\n S S\n T T\n U U\n V V\n W W\n X X\n Y Y\nZ Z\n Y Y\n X X\n W W\n V V\n U U\n T T\n S S\n R R\n Q Q\n P P\n O O\n N N\n M M\n L L\n K K\n J J\n I I\n H H\n G G\n F F\n E E\n D D\n C C\n B B\n A"},
{'M', " A\n B B\n C C\n D D\n E E\n F F\n G G\n H H\n I I\n J J\n K K\n L L\nM M\n L L\n K K\n J J\n I I\n H H\n G G\n F F\n E E\n D D\n C C\n B B\n A"},
}
for _, table := range tables {
d := makeDiamond(table.letter)
if d != table.diamond {
t.Errorf("Got :\n%s\nExpected :\n%s\n", d, table.diamond)
}
}
}