diff options
Diffstat (limited to 'lib_test.go')
| -rw-r--r-- | lib_test.go | 57 | 
1 files changed, 29 insertions, 28 deletions
diff --git a/lib_test.go b/lib_test.go index c668fc8..ef0d8f5 100644 --- a/lib_test.go +++ b/lib_test.go @@ -1,8 +1,13 @@  package excelize -import "testing" +import ( +	"fmt" +	"testing" -func TestAxisLowerOrEqualThan(t *testing.T) { +	"github.com/stretchr/testify/assert" +) + +func TestAxisLowerOrEqualThanIsTrue(t *testing.T) {  	trueExpectedInputList := [][2]string{  		{"A", "B"},  		{"A", "AA"}, @@ -12,13 +17,14 @@ func TestAxisLowerOrEqualThan(t *testing.T) {  		{"2", "11"},  	} -	for _, trueExpectedInput := range trueExpectedInputList { -		isLowerOrEqual := axisLowerOrEqualThan(trueExpectedInput[0], trueExpectedInput[1]) -		if !isLowerOrEqual { -			t.Fatalf("Expected %v <= %v = true, got false\n", trueExpectedInput[0], trueExpectedInput[1]) -		} +	for i, trueExpectedInput := range trueExpectedInputList { +		t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) { +			assert.True(t, axisLowerOrEqualThan(trueExpectedInput[0], trueExpectedInput[1])) +		})  	} +} +func TestAxisLowerOrEqualThanIsFalse(t *testing.T) {  	falseExpectedInputList := [][2]string{  		{"B", "A"},  		{"AA", "A"}, @@ -28,32 +34,27 @@ func TestAxisLowerOrEqualThan(t *testing.T) {  		{"11", "2"},  	} -	for _, falseExpectedInput := range falseExpectedInputList { -		isLowerOrEqual := axisLowerOrEqualThan(falseExpectedInput[0], falseExpectedInput[1]) -		if isLowerOrEqual { -			t.Fatalf("Expected %v <= %v = false, got true\n", falseExpectedInput[0], falseExpectedInput[1]) -		} +	for i, falseExpectedInput := range falseExpectedInputList { +		t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) { +			assert.False(t, axisLowerOrEqualThan(falseExpectedInput[0], falseExpectedInput[1])) +		})  	}  }  func TestGetCellColRow(t *testing.T) { -	cellExpectedColRowList := map[string][2]string{ -		"C220":    {"C", "220"}, -		"aaef42":  {"aaef", "42"}, -		"bonjour": {"bonjour", ""}, -		"59":      {"", "59"}, -		"":        {"", ""}, +	cellExpectedColRowList := [][3]string{ +		{"C220", "C", "220"}, +		{"aaef42", "aaef", "42"}, +		{"bonjour", "bonjour", ""}, +		{"59", "", "59"}, +		{"", "", ""},  	} -	for cell, expectedColRow := range cellExpectedColRowList { -		col, row := getCellColRow(cell) - -		if col != expectedColRow[0] { -			t.Fatalf("Expected cell %v to return col %v, got col %v\n", cell, expectedColRow[0], col) -		} - -		if row != expectedColRow[1] { -			t.Fatalf("Expected cell %v to return row %v, got row %v\n", cell, expectedColRow[1], row) -		} +	for i, test := range cellExpectedColRowList { +		t.Run(fmt.Sprintf("TestData%d", i), func(t *testing.T) { +			col, row := getCellColRow(test[0]) +			assert.Equal(t, test[1], col, "Unexpected col") +			assert.Equal(t, test[2], row, "Unexpected row") +		})  	}  }  | 
