MCPcopy
hub / github.com/qax-os/excelize / TestRowsIterator

Function TestRowsIterator

rows_test.go:85–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

83}
84
85func TestRowsIterator(t *testing.T) {
86 sheetName, rowCount, expectedNumRow := "Sheet2", 0, 11
87 f, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
88 require.NoError(t, err)
89
90 rows, err := f.Rows(sheetName)
91 require.NoError(t, err)
92
93 for rows.Next() {
94 rowCount++
95 require.True(t, rowCount <= expectedNumRow, "rowCount is greater than expected")
96 }
97 assert.Equal(t, expectedNumRow, rowCount)
98 assert.NoError(t, rows.Close())
99 assert.NoError(t, f.Close())
100
101 // Valued cell sparse distribution test
102 f, sheetName, rowCount, expectedNumRow = NewFile(), "Sheet1", 0, 3
103 cells := []string{"C1", "E1", "A3", "B3", "C3", "D3", "E3"}
104 for _, cell := range cells {
105 assert.NoError(t, f.SetCellValue(sheetName, cell, 1))
106 }
107 rows, err = f.Rows(sheetName)
108 require.NoError(t, err)
109 for rows.Next() {
110 rowCount++
111 require.True(t, rowCount <= expectedNumRow, "rowCount is greater than expected")
112 }
113 assert.Equal(t, expectedNumRow, rowCount)
114}
115
116func TestRowsGetRowOpts(t *testing.T) {
117 sheetName := "Sheet2"

Callers

nothing calls this directly

Calls 6

OpenFileFunction · 0.85
NewFileFunction · 0.85
SetCellValueMethod · 0.80
CloseMethod · 0.65
RowsMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected