]> git.scottworley.com Git - slidingtile/blob - sliding_tile_test.go
41be233cb203728499723359393edd1f4a889282
[slidingtile] / sliding_tile_test.go
1 package main
2
3 import "testing"
4
5 func 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 }