]> git.scottworley.com Git - slidingtile/blame - sliding_tile_test.go
tests
[slidingtile] / sliding_tile_test.go
CommitLineData
0d0e3b82
SW
1package main
2
3import "testing"
4
5func Test_read_board_from_strings(t *testing.T) {
6 b, err := read_board_from_strings([]string{"1","2","9","12","6","8","13","14","0","11","15","3","7","4","10","5"})
7 if err != nil || *b != Board([BOARD_SIZE]Space{1,2,9,12,6,8,13,14,0,11,15,3,7,4,10,5}) {
8 t.Fail()
9 }
10
11 // Not enough
12 b, err = read_board_from_strings([]string{"1","2","9","12","6","8","13","14","0","11","15","3","7","4","10"})
13 if err == nil {
14 t.Fail()
15 }
16
17 // Not an integer
18 b, err = read_board_from_strings([]string{"1","foo","9","12","6","8","13","14","0","11","15","3","7","4","10","5"})
19 if err == nil {
20 t.Fail()
21 }
22
23 // Empty string
24 b, err = read_board_from_strings([]string{"1","","9","12","6","8","13","14","0","11","15","3","7","4","10","5"})
25 if err == nil {
26 t.Fail()
27 }
28}