diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-11-15 20:18:30 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-11-15 20:18:30 +0000 |
commit | 4c908ea89683e5b5bc96fa11995fb62a5e85fc8f (patch) | |
tree | eb51baf0eb2f2cc83f91ad7517713ef504efcf43 | |
parent | 6a7c40a40e3ef1be724e96b53f53ad788522b196 (diff) |
parameterized another test
-rw-r--r-- | reader/reader_test.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/reader/reader_test.go b/reader/reader_test.go index f27700a..8c44360 100644 --- a/reader/reader_test.go +++ b/reader/reader_test.go @@ -86,17 +86,21 @@ func TestGetSheetsFromDM(t *testing.T) { } } -// TODO: reformat this test func to use the case func TestReadXLSX(t *testing.T) { d := ReadXLSX("testdata/test_template.xlsx") - if d["Summary"]["A2"].Value != "Date:" { - t.Errorf("Expected A2 in Summary sheet to be 'Date:' - instead it is %s", d["Summary"]["A2"].Value) - } - if d["Another Sheet"]["F5"].Value != "4.2" { - t.Errorf("Expected F5 in Another Sheet sheet to be 4.2 - instead it is %s", d["Another Sheet"]["F5"].Value) + cases := []struct { + sheet, cellref, val string + }{ + {"Summary", "A2", "Date:"}, + {"Another Sheet", "F5", "4.2"}, + {"Another Sheet", "J22", "18"}, } - if d["Another Sheet"]["J22"].Value != "18" { - t.Errorf("Expected J22 in Another Sheet sheet to be 18 - instead it is %s", d["Another Sheet"]["J22"].Value) + for _, c := range cases { + got := d[c.sheet][c.cellref].Value + if got != c.val { + t.Errorf("Expected %s in %s sheet to be %s "+ + " - instead it is %s", c.cellref, c.sheet, c.val, d[c.sheet][c.cellref].Value) + } } } |