|
| 1 | +package xls |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "testing" |
| 6 | + "time" |
| 7 | +) |
| 8 | + |
| 9 | +func TestBigTable(t *testing.T) { |
| 10 | + xlFile, err := Open("BigTable.xls", "utf-8") |
| 11 | + if err != nil { |
| 12 | + t.Fatalf("Cant open xls file: %s", err) |
| 13 | + } |
| 14 | + |
| 15 | + sheet := xlFile.GetSheet(0) |
| 16 | + if sheet == nil { |
| 17 | + t.Fatal("Cant get sheet") |
| 18 | + } |
| 19 | + |
| 20 | + cnt1 := 1 |
| 21 | + cnt2 := 10000 |
| 22 | + cnt3 := 20000 |
| 23 | + date1, _ := time.Parse("2006-01-02", "2015-01-01") |
| 24 | + date2, _ := time.Parse("2006-01-02", "2016-01-01") |
| 25 | + date3, _ := time.Parse("2006-01-02", "2017-01-01") |
| 26 | + |
| 27 | + for i := 1; i <= 4999; i++ { |
| 28 | + row := sheet.Row(i) |
| 29 | + if row == nil { |
| 30 | + continue |
| 31 | + } |
| 32 | + |
| 33 | + col2sample := fmt.Sprintf("%d от %s", cnt1, date1.Format("02.01.2006")) |
| 34 | + col5sample := fmt.Sprintf("%d от %s", cnt2, date2.Format("02.01.2006")) |
| 35 | + col8sample := fmt.Sprintf("%d от %s", cnt3, date3.Format("02.01.2006")) |
| 36 | + |
| 37 | + col2 := row.Col(2) |
| 38 | + col5 := row.Col(5) |
| 39 | + col8 := row.Col(8) |
| 40 | + |
| 41 | + if col2 != col2sample { |
| 42 | + t.Fatalf("Row %d: col 2 val not eq base value: %s != %s", i, col2, col2sample) |
| 43 | + } |
| 44 | + if col5 != col5sample { |
| 45 | + t.Fatalf("Row %d: col 5 val not eq base value: %s != %s", i, col5, col5sample) |
| 46 | + } |
| 47 | + if col8 != col8sample { |
| 48 | + t.Fatalf("Row %d: col 8 val not eq base value: %s != %s", i, col8, col8sample) |
| 49 | + } |
| 50 | + |
| 51 | + cnt1++ |
| 52 | + cnt2++ |
| 53 | + cnt3++ |
| 54 | + date1 = date1.AddDate(0, 0, 1) |
| 55 | + date2 = date2.AddDate(0, 0, 1) |
| 56 | + date3 = date3.AddDate(0, 0, 1) |
| 57 | + |
| 58 | + } |
| 59 | +} |
0 commit comments