diff options
author | xuri <xuri.me@gmail.com> | 2022-10-20 00:02:30 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2022-10-20 00:02:30 +0800 |
commit | 2df615fa2831bd578371d4e3606f16461c474ce7 (patch) | |
tree | 440e30fc64cad3fde230a03645d4be96580fdff1 /stream_test.go | |
parent | 3ece904b0082f4d63afe0d795b61c860d0790c83 (diff) |
This close #1373, fixes the incorrect build-in number format apply the result
- An error will be returned when setting the stream row without ascending row numbers, to avoid potential mistakes as mentioned in #1139
- Updated unit tests
Diffstat (limited to 'stream_test.go')
-rw-r--r-- | stream_test.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/stream_test.go b/stream_test.go index c399d63..a4a0590 100644 --- a/stream_test.go +++ b/stream_test.go @@ -61,7 +61,7 @@ func TestStreamWriter(t *testing.T) { }})) assert.NoError(t, streamWriter.SetRow("A6", []interface{}{time.Now()})) assert.NoError(t, streamWriter.SetRow("A7", nil, RowOpts{Height: 20, Hidden: true, StyleID: styleID})) - assert.EqualError(t, streamWriter.SetRow("A7", nil, RowOpts{Height: MaxRowHeight + 1}), ErrMaxRowHeight.Error()) + assert.EqualError(t, streamWriter.SetRow("A8", nil, RowOpts{Height: MaxRowHeight + 1}), ErrMaxRowHeight.Error()) for rowID := 10; rowID <= 51200; rowID++ { row := make([]interface{}, 50) @@ -77,7 +77,7 @@ func TestStreamWriter(t *testing.T) { assert.NoError(t, file.SaveAs(filepath.Join("test", "TestStreamWriter.xlsx"))) // Test set cell column overflow. - assert.ErrorIs(t, streamWriter.SetRow("XFD1", []interface{}{"A", "B", "C"}), ErrColumnNumber) + assert.ErrorIs(t, streamWriter.SetRow("XFD51201", []interface{}{"A", "B", "C"}), ErrColumnNumber) // Test close temporary file error. file = NewFile() @@ -226,6 +226,9 @@ func TestStreamSetRow(t *testing.T) { streamWriter, err := file.NewStreamWriter("Sheet1") assert.NoError(t, err) assert.EqualError(t, streamWriter.SetRow("A", []interface{}{}), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error()) + // Test set row with non-ascending row number + assert.NoError(t, streamWriter.SetRow("A1", []interface{}{})) + assert.EqualError(t, streamWriter.SetRow("A1", []interface{}{}), newStreamSetRowError(1).Error()) } func TestStreamSetRowNilValues(t *testing.T) { |