cell_test.go 951 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package excelize
  2. import "testing"
  3. func TestCheckCellInArea(t *testing.T) {
  4. expectedTrueCellInAreaList := [][2]string{
  5. {"c2", "A1:AAZ32"},
  6. {"AA0", "Z0:AB1"},
  7. {"B9", "A1:B9"},
  8. {"C2", "C2:C2"},
  9. }
  10. for _, expectedTrueCellInArea := range expectedTrueCellInAreaList {
  11. cell := expectedTrueCellInArea[0]
  12. area := expectedTrueCellInArea[1]
  13. cellInArea := checkCellInArea(cell, area)
  14. if !cellInArea {
  15. t.Fatalf("Expected cell %v to be in area %v, got false\n", cell, area)
  16. }
  17. }
  18. expectedFalseCellInAreaList := [][2]string{
  19. {"c2", "A4:AAZ32"},
  20. {"C4", "D6:A1"}, // weird case, but you never know
  21. {"AEF42", "BZ40:AEF41"},
  22. }
  23. for _, expectedFalseCellInArea := range expectedFalseCellInAreaList {
  24. cell := expectedFalseCellInArea[0]
  25. area := expectedFalseCellInArea[1]
  26. cellInArea := checkCellInArea(cell, area)
  27. if cellInArea {
  28. t.Fatalf("Expected cell %v not to be inside of area %v, but got true\n", cell, area)
  29. }
  30. }
  31. }