lib_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package excelize
  2. import "testing"
  3. func TestAxisLowerOrEqualThan(t *testing.T) {
  4. trueExpectedInputList := [][2]string{
  5. {"A", "B"},
  6. {"A", "AA"},
  7. {"B", "AA"},
  8. {"BC", "ABCD"},
  9. {"1", "2"},
  10. {"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. {"B", "A"},
  20. {"AA", "A"},
  21. {"AA", "B"},
  22. {"ABCD", "AB"},
  23. {"2", "1"},
  24. {"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": {"C", "220"},
  36. "aaef42": {"aaef", "42"},
  37. "bonjour": {"bonjour", ""},
  38. "59": {"", "59"},
  39. "": {"", ""},
  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. }