From 4c908ea89683e5b5bc96fa11995fb62a5e85fc8f Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Fri, 15 Nov 2019 20:18:30 +0000 Subject: parameterized another test --- reader/reader_test.go | 20 ++++++++++++-------- 1 file 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) + } } } -- cgit v1.2.3