diff options
author | xuri <xuri.me@gmail.com> | 2022-01-19 00:51:09 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2022-01-19 00:51:09 +0800 |
commit | 74f6ea94eae45c8fb89a23cc94802e57ce279a84 (patch) | |
tree | f27a05419c57c3ecb89b8fd84df1ed1e5121eb05 | |
parent | 4daa6ed0b46fdd994e46403feb049b162eca19b8 (diff) |
ref #1054, breaking change for the column and row's iterator
This removed 3 exported functions: `TotalCols`, `CurrentCol` and `CurrentRow`
-rw-r--r-- | cell_test.go | 8 | ||||
-rw-r--r-- | col.go | 10 | ||||
-rw-r--r-- | col_test.go | 9 | ||||
-rw-r--r-- | rows.go | 5 | ||||
-rw-r--r-- | rows_test.go | 1 |
5 files changed, 11 insertions, 22 deletions
diff --git a/cell_test.go b/cell_test.go index b3bb997..8d00e2d 100644 --- a/cell_test.go +++ b/cell_test.go @@ -682,8 +682,10 @@ func TestSharedStringsError(t *testing.T) { rows, err := f.Rows("Sheet1") assert.NoError(t, err) const maxUint16 = 1<<16 - 1 + currentRow := 0 for rows.Next() { - if rows.CurrentRow() == 19 { + currentRow++ + if currentRow == 19 { _, err := rows.Columns() assert.NoError(t, err) // Test get cell value from string item with invalid offset @@ -705,8 +707,10 @@ func TestSharedStringsError(t *testing.T) { assert.NoError(t, err) rows, err = f.Rows("Sheet1") assert.NoError(t, err) + currentRow = 0 for rows.Next() { - if rows.CurrentRow() == 19 { + currentRow++ + if currentRow == 19 { _, err := rows.Columns() assert.NoError(t, err) break @@ -40,16 +40,6 @@ type Cols struct { sheetXML []byte } -// CurrentCol returns the column number that represents the current column. -func (cols *Cols) CurrentCol() int { - return cols.curCol -} - -// TotalCols returns the total columns count in the worksheet. -func (cols *Cols) TotalCols() int { - return cols.totalCols -} - // GetCols return all the columns in a sheet by given worksheet name (case // sensitive). For example: // diff --git a/col_test.go b/col_test.go index 2dd27db..e325ed1 100644 --- a/col_test.go +++ b/col_test.go @@ -68,8 +68,6 @@ func TestColumnsIterator(t *testing.T) { for cols.Next() { colCount++ - assert.Equal(t, colCount, cols.CurrentCol()) - assert.Equal(t, expectedNumCol, cols.TotalCols()) require.True(t, colCount <= expectedNumCol, "colCount is greater than expected") } assert.Equal(t, expectedNumCol, colCount) @@ -85,8 +83,6 @@ func TestColumnsIterator(t *testing.T) { for cols.Next() { colCount++ - assert.Equal(t, colCount, cols.CurrentCol()) - assert.Equal(t, expectedNumCol, cols.TotalCols()) require.True(t, colCount <= 4, "colCount is greater than expected") } assert.Equal(t, expectedNumCol, colCount) @@ -131,6 +127,11 @@ func TestGetColsError(t *testing.T) { cols.sheetXML = []byte(`<worksheet><sheetData><row r="1"><c r="A" t="str"><v>A</v></c></row></sheetData></worksheet>`) _, err = cols.Rows() assert.EqualError(t, err, newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error()) + + f.Pkg.Store("xl/worksheets/sheet1.xml", nil) + f.Sheet.Store("xl/worksheets/sheet1.xml", nil) + _, err = f.Cols("Sheet1") + assert.NoError(t, err) } func TestColsRows(t *testing.T) { @@ -79,11 +79,6 @@ type Rows struct { token xml.Token } -// CurrentRow returns the row number that represents the current row. -func (rows *Rows) CurrentRow() int { - return rows.seekRow -} - // Next will return true if find the next row element. func (rows *Rows) Next() bool { rows.seekRow++ diff --git a/rows_test.go b/rows_test.go index 0ac9271..0d2ca23 100644 --- a/rows_test.go +++ b/rows_test.go @@ -74,7 +74,6 @@ func TestRowsIterator(t *testing.T) { for rows.Next() { rowCount++ - assert.Equal(t, rowCount, rows.CurrentRow()) require.True(t, rowCount <= expectedNumRow, "rowCount is greater than expected") } assert.Equal(t, expectedNumRow, rowCount) |