lib_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package excelize
  2. import "testing"
  3. func TestAxisLowerOrEqualThan(t *testing.T) {
  4. trueExpectedInputList := [][2]string{
  5. [2]string{"A", "B"},
  6. [2]string{"A", "AA"},
  7. [2]string{"B", "AA"},
  8. [2]string{"BC", "ABCD"},
  9. [2]string{"1", "2"},
  10. [2]string{"2", "11"},
  11. }
  12. for _, trueExpectedInput := range trueExpectedInputList {
  13. isLowerOrEqual := axisLowerOrEqualThan(trueExpectedInput[0], trueExpectedInput[1])
  14. if !isLowerOrEqual {
  15. t.Fatalf("Expected %v <= %v = true, got false\n", trueExpectedInput[0], trueExpectedInput[1])
  16. }
  17. }
  18. falseExpectedInputList := [][2]string{
  19. [2]string{"B", "A"},
  20. [2]string{"AA", "A"},
  21. [2]string{"AA", "B"},
  22. [2]string{"ABCD", "AB"},
  23. [2]string{"2", "1"},
  24. [2]string{"11", "2"},
  25. }
  26. for _, falseExpectedInput := range falseExpectedInputList {
  27. isLowerOrEqual := axisLowerOrEqualThan(falseExpectedInput[0], falseExpectedInput[1])
  28. if isLowerOrEqual {
  29. t.Fatalf("Expected %v <= %v = false, got true\n", falseExpectedInput[0], falseExpectedInput[1])
  30. }
  31. }
  32. }
  33. func TestGetCellColRow(t *testing.T) {
  34. cellExpectedColRowList := map[string][2]string{
  35. "C220": [2]string{"C", "220"},
  36. "aaef42": [2]string{"aaef", "42"},
  37. "bonjour": [2]string{"bonjour", ""},
  38. "59": [2]string{"", "59"},
  39. "": [2]string{"", ""},
  40. }
  41. for cell, expectedColRow := range cellExpectedColRowList {
  42. col, row := getCellColRow(cell)
  43. if col != expectedColRow[0] {
  44. t.Fatalf("Expected cell %v to return col %v, got col %v\n", cell, expectedColRow[0], col)
  45. }
  46. if row != expectedColRow[1] {
  47. t.Fatalf("Expected cell %v to return row %v, got row %v\n", cell, expectedColRow[1], row)
  48. }
  49. }
  50. }