From: Scott Worley Date: Tue, 29 Dec 2015 01:30:26 +0000 (-0800) Subject: gofmt X-Git-Url: http://git.scottworley.com/slidingtile/commitdiff_plain/212a5629d44cb0aa108057fe5a6d0c67bb479d54?ds=sidebyside gofmt --- 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() + } }