Commit 333b956f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 274d6fbb
......@@ -117,8 +117,10 @@ func TestRangeSet(t *testing.T) {
}
for _, tt := range testv {
U := tt.A.Union(tt.B)
D := tt.A.Difference(tt.B)
A := tt.A
B := tt.B
U := A.Union(B)
D := A.Difference(B)
if !U.Equal(tt.Union) {
t.Errorf("Union:\n A: %s\n B: %s\n ->u: %s\n okU: %s\n", tt.A, tt.B, U, tt.Union)
......@@ -126,5 +128,27 @@ func TestRangeSet(t *testing.T) {
if !D.Equal(tt.Difference) {
t.Errorf("Difference:\n A: %s\n B: %s\n ->d: %s\n okD: %s\n", tt.A, tt.B, D, tt.Difference)
}
// HasRange XXX use AllRanges instead of direct .rangev access
assertHasRange(t, A.rangev, A, true)
assertHasRange(t, B.rangev, B, true)
assertHasRange(t, A.rangev, U, true)
assertHasRange(t, B.rangev, U, true)
Dab := D
Dba := B.Difference(A)
assertHasRange(t, Dab.rangev, B, false)
assertHasRange(t, Dba.rangev, A, false)
}
}
// assertHasRange asserts for all ranges from rangev that S.HasRange(r) == hasOK
func assertHasRange(t *testing.T, rangev []Range, S *RangeSet, hasOK bool) {
t.Helper()
for _, r := range rangev {
has := S.HasRange(r)
if has != hasOK {
t.Errorf("HasRange:\n S: %s\n r: %s\n ->: %v\n ok: %v\n", S, r, has, hasOK)
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment