From 212a5629d44cb0aa108057fe5a6d0c67bb479d54 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 28 Dec 2015 17:30:26 -0800 Subject: [PATCH 1/1] gofmt --- sliding_tile.go | 34 +++++++++++++++++----------------- sliding_tile_test.go | 38 +++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sliding_tile.go b/sliding_tile.go index a934b4e..32bccae 100644 --- a/sliding_tile.go +++ b/sliding_tile.go @@ -11,24 +11,24 @@ type Space int8 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() { - 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) } diff --git a/sliding_tile_test.go b/sliding_tile_test.go index 41be233..28392ee 100644 --- a/sliding_tile_test.go +++ b/sliding_tile_test.go @@ -3,26 +3,26 @@ 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() - } + 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() + } } -- 2.44.1