|
|
@ -6,6 +6,7 @@ import (
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func TestRows(t *testing.T) {
|
|
|
|
func TestRows(t *testing.T) {
|
|
|
@ -41,6 +42,25 @@ func TestRows(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// test bug https://github.com/360EntSecGroup-Skylar/excelize/issues/502
|
|
|
|
|
|
|
|
func TestRowsIterator(t *testing.T) {
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
sheet2 = "Sheet2"
|
|
|
|
|
|
|
|
expectedNumRow = 11
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
xlsx, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rows, err := xlsx.Rows(sheet2)
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
var rowCount int
|
|
|
|
|
|
|
|
for rows.Next() {
|
|
|
|
|
|
|
|
rowCount++
|
|
|
|
|
|
|
|
require.True(t, rowCount <= expectedNumRow, "rowCount is greater than expected")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, expectedNumRow, rowCount)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestRowsError(t *testing.T) {
|
|
|
|
func TestRowsError(t *testing.T) {
|
|
|
|
xlsx, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
|
|
|
|
xlsx, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
|
|
|
|
if !assert.NoError(t, err) {
|
|
|
|
if !assert.NoError(t, err) {
|
|
|
|