]> git.scottworley.com Git - slidingtile/commitdiff
tests
authorScott Worley <scottworley@scottworley.com>
Mon, 28 Dec 2015 23:03:13 +0000 (15:03 -0800)
committerScott Worley <scottworley@scottworley.com>
Mon, 28 Dec 2015 23:03:13 +0000 (15:03 -0800)
sliding_tile_test.go [new file with mode: 0644]

diff --git a/sliding_tile_test.go b/sliding_tile_test.go
new file mode 100644 (file)
index 0000000..41be233
--- /dev/null
@@ -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()
+  }
+}