-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
broken WIP tests and public testdata
- Loading branch information
Showing
11 changed files
with
243 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
a b c d | ||
1 Hello 42.0 0.0 | ||
2 World 99.1 0.01 | ||
3 This 7e8 0.001 | ||
4 Tests 2.4e-8 0.0001 | ||
5 Text 0.0001 0.00001 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
a b c d | ||
1 Hello 42.0 0.00000 | ||
2 World 99.1 0.01000 | ||
3 This 7E+08 0.00100 | ||
4 Tests 2.4E-08 0.00010 | ||
5 Text 0.0001 0.00001 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Integers Floats Fractions Dates v1 | ||
One 1 1.234 1/2 "July 11, 2004" TRUE | ||
Two 4 1.2345678 42 1/3 11 Jul 00 TRUE | ||
Three 6 1.0 1/5 9-Sep FALSE | ||
Two Words 99 -42.1 -4 1/5 Jun-42 TRUE | ||
Three Small Words 123456789 123456789.0 9999 9/10 1-1-01 FALSE | ||
This is a longer sentence that fills the cell and overflows 1000000000000 1000000000000.0 | ||
Some merged cells (tall version) 123456789 7 38 2/15 "July 12, 2004" | ||
5 123456790.234 1/5 22 Aug 00 | ||
1000000000001 1111 1/10 | ||
|
||
Merged columns (single row) | ||
|
||
Merged cells again (big box) custom yes/no bools! | ||
A yes | ||
B no | ||
C | ||
D |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,159 @@ | ||
package xlsx | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func noTestOpen(t *testing.T) { | ||
wb, err := Open("test.xlsx") | ||
var testFiles = []string{ | ||
"../testdata/multi_test.xlsx", | ||
"../testdata/basic.xlsx", | ||
"../testdata/basic2.xlsx", | ||
} | ||
|
||
func TestLoading(t *testing.T) { | ||
for _, fn := range testFiles { | ||
wb, err := Open(fn) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
sheets, err := wb.List() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
for _, s := range sheets { | ||
sheet, err := wb.Get(s) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
for sheet.Next() { | ||
sheet.Strings() | ||
} | ||
} | ||
|
||
err = wb.Close() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
} | ||
|
||
func TestBasic(t *testing.T) { | ||
trueFile, err := os.ReadFile("../testdata/basic.tsv") | ||
if err != nil { | ||
t.Skip() | ||
} | ||
lines := strings.Split(string(trueFile), "\n") | ||
|
||
fn := "../testdata/basic.xlsx" | ||
wb, err := Open(fn) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
sheets, err := wb.List() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
for _, s := range sheets { | ||
sheet, err := wb.Get(s) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
i := 0 | ||
for sheet.Next() { | ||
row := strings.Join(sheet.Strings(), "\t") | ||
if lines[i] != row { | ||
t.Fatalf("line %d mismatch: '%s' <> '%s'", i, row, lines[i]) | ||
} | ||
i++ | ||
} | ||
} | ||
|
||
err = wb.Close() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestBasic2(t *testing.T) { | ||
trueFile, err := os.ReadFile("../testdata/basic2.tsv") | ||
if err != nil { | ||
t.Skip() | ||
} | ||
lines := strings.Split(string(trueFile), "\n") | ||
|
||
fn := "../testdata/basic2.xlsx" | ||
wb, err := Open(fn) | ||
if err != nil { | ||
log.Fatal(err) | ||
t.Fatal(err) | ||
} | ||
|
||
sheets, err := wb.List() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
for _, s := range sheets { | ||
//log.Println(s) | ||
sheet, err := wb.Get(s) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
i := 0 | ||
for sheet.Next() { | ||
sheet.Strings() | ||
row := strings.Join(sheet.Strings(), "\t") | ||
if lines[i] != row { | ||
t.Fatalf("line %d mismatch: '%s' <> '%s'", i, row, lines[i]) | ||
} | ||
i++ | ||
} | ||
} | ||
|
||
err = wb.Close() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func TestOpen2(t *testing.T) { | ||
wb, err := Open("test2.xlsx") | ||
func TestMulti(t *testing.T) { | ||
trueFile, err := os.ReadFile("../testdata/multi_test.tsv") | ||
if err != nil { | ||
log.Fatal(err) | ||
t.Skip() | ||
} | ||
lines := strings.Split(string(trueFile), "\n") | ||
|
||
fn := "../testdata/multi_test.xlsx" | ||
wb, err := Open(fn) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
sheets, err := wb.List() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
for _, s := range sheets { | ||
//log.Println(s) | ||
sheet, err := wb.Get(s) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
i := 0 | ||
for sheet.Next() { | ||
sheet.Strings() | ||
row := strings.Join(sheet.Strings(), "\t") | ||
if lines[i] != row { | ||
t.Fatalf("line %d mismatch: '%s' <> '%s'", i, row, lines[i]) | ||
} | ||
i++ | ||
} | ||
} | ||
|
||
err = wb.Close() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} |