prefix_test.go 640 B

123456789101112131415161718192021222324252627
  1. package ipplot
  2. import (
  3. "testing"
  4. )
  5. func TestLessThanOrEqFailure1(t *testing.T) {
  6. pfx0, _ := NewIPv4([]byte{198, 18, 0, 0}, 15)
  7. ipb0 := NewIPBlock(pfx0, IANAReserved)
  8. pfx1, _ := NewIPv4([]byte{198, 175, 251, 92}, 32)
  9. ipb1 := NewIPBlock(pfx1, Allocation)
  10. pfx2, _ := NewIPv4([]byte{203, 0, 113, 0}, 24)
  11. ipb2 := NewIPBlock(pfx2, IANAReserved)
  12. // this was failing; caused by bug in lessThan logic
  13. if ipb1.LessThanOrEq(ipb0) {
  14. t.Errorf("should not be left of %s", pfx0)
  15. }
  16. if ipb2.LessThanOrEq(ipb1) {
  17. t.Errorf("should not be right of %s", pfx2)
  18. }
  19. if !ipb1.LessThanOrEq(ipb2) {
  20. t.Errorf("should be left of %s", pfx2)
  21. }
  22. }