]> git.scottworley.com Git - slidingtile/commitdiff
gofmt
authorScott Worley <scottworley@scottworley.com>
Tue, 29 Dec 2015 01:30:26 +0000 (17:30 -0800)
committerScott Worley <scottworley@scottworley.com>
Tue, 29 Dec 2015 01:30:26 +0000 (17:30 -0800)
sliding_tile.go
sliding_tile_test.go

index a934b4e055f6594da8c7e1f9a5b3243d1108ae68..32bccae239b9b0c9a1f8b989c5396c4bc527fe93 100644 (file)
@@ -11,24 +11,24 @@ type Space int8
 type Board [BOARD_SIZE]Space
 
 func read_board_from_strings(in []string) (*Board, error) {
 type Board [BOARD_SIZE]Space
 
 func read_board_from_strings(in []string) (*Board, error) {
-  if len(in) != BOARD_SIZE {
-    return nil, fmt.Errorf("Please provide %d values", BOARD_SIZE)
-  }
-  var b Board
-  for i, s := range in {
-    num, err := strconv.Atoi(s)
-    b[i] = Space(num)
-    if err != nil {
-      return nil, err
-    }
-  }
-  return &b, nil
+       if len(in) != BOARD_SIZE {
+               return nil, fmt.Errorf("Please provide %d values", BOARD_SIZE)
+       }
+       var b Board
+       for i, s := range in {
+               num, err := strconv.Atoi(s)
+               b[i] = Space(num)
+               if err != nil {
+                       return nil, err
+               }
+       }
+       return &b, nil
 }
 
 func main() {
 }
 
 func main() {
-  start, err := read_board_from_strings(os.Args[1:])
-  if err != nil {
-    panic(err)
-  }
-  fmt.Println(start)
+       start, err := read_board_from_strings(os.Args[1:])
+       if err != nil {
+               panic(err)
+       }
+       fmt.Println(start)
 }
 }
index 41be233cb203728499723359393edd1f4a889282..28392eef4599c4b9cd9d0a7968b57a8325d1a16c 100644 (file)
@@ -3,26 +3,26 @@ package main
 import "testing"
 
 func Test_read_board_from_strings(t *testing.T) {
 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()
-  }
+       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 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()
-  }
+       // 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()
-  }
+       // 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()
+       }
 }
 }