diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-12-04 10:38:27 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-12-04 10:38:27 +0000 |
commit | a54bf5613b0c17d0a06b81405afbfd686e54b581 (patch) | |
tree | b7dcea4a80e86fc80460a58062d411954b8d9e46 | |
parent | 27aee57258f81ef6b381f45bbd4c0f337a201f67 (diff) |
replaced test with one generated by gotests
-rw-r--r-- | coords_test.go | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/coords_test.go b/coords_test.go index 8f8f865..6b73f2d 100644 --- a/coords_test.go +++ b/coords_test.go @@ -52,31 +52,6 @@ func TestAlphas(t *testing.T) { } } -func TestCollectLetters(t *testing.T) { - cases := []struct { - alpha string - index int - }{ - {"XEZ", 16379}, - {"XEY", 16378}, - {"XEX", 16377}, - {"A", 0}, - {"B", 1}, - {"C", 2}, - {"AA", 26}, - } - for _, c := range cases { - s, err := ColAlphaToIndex(c.alpha) - if err != nil { - t.Fatal(err) - } - if s != c.index { - t.Errorf("Expected %d to return %s, instead it returned %d", c.index, c.alpha, s) - } - - } -} - func TestGetColApha(t *testing.T) { cases := []struct { index int @@ -97,3 +72,34 @@ func TestGetColApha(t *testing.T) { } } } + +func TestColAlphaToIndex(t *testing.T) { + type args struct { + letters string + } + tests := []struct { + name string + args args + want int + wantErr bool + }{ + {"TestColAlphaToIndex", args{"XEZ"}, 16379, false}, + {"TestColAlphaToIndex", args{"XEY"}, 16378, false}, + {"TestColAlphaToIndex", args{"XEX"}, 16377, false}, + {"TestColAlphaToIndex", args{"A"}, 0, false}, + {"TestColAlphaToIndex", args{"B"}, 1, false}, + {"TestColAlphaToIndex", args{"AA"}, 26, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := ColAlphaToIndex(tt.args.letters) + if (err != nil) != tt.wantErr { + t.Errorf("ColAlphaToIndex() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("ColAlphaToIndex() = %v, want %v", got, tt.want) + } + }) + } +} |