From: Scott Worley Date: Mon, 28 Dec 2015 23:03:13 +0000 (-0800) Subject: tests X-Git-Url: http://git.scottworley.com/slidingtile/commitdiff_plain/0d0e3b823054308d06cc50fcdba6b08b4373734f?ds=inline tests --- diff --git a/sliding_tile_test.go b/sliding_tile_test.go new file mode 100644 index 0000000..41be233 --- /dev/null +++ b/sliding_tile_test.go @@ -0,0 +1,28 @@ +package main + +import "testing" + +func Test_read_board_from_strings(t *testing.T) { + b, err := read_board_from_strings([]string{"1","2","9","12","6","8","13","14","0","11","15","3","7","4","10","5"}) + if err != nil || *b != Board([BOARD_SIZE]Space{1,2,9,12,6,8,13,14,0,11,15,3,7,4,10,5}) { + t.Fail() + } + + // Not enough + b, err = read_board_from_strings([]string{"1","2","9","12","6","8","13","14","0","11","15","3","7","4","10"}) + if err == nil { + t.Fail() + } + + // Not an integer + b, err = read_board_from_strings([]string{"1","foo","9","12","6","8","13","14","0","11","15","3","7","4","10","5"}) + if err == nil { + t.Fail() + } + + // Empty string + b, err = read_board_from_strings([]string{"1","","9","12","6","8","13","14","0","11","15","3","7","4","10","5"}) + if err == nil { + t.Fail() + } +}