From 19033bf2e57cdbcc79a2a682cb0bf59ea2a473d4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Mon, 28 Sep 2026 22:26:35 +0200 Subject: [PATCH] Fail the whole-replay comparison where it compared no read set --- drawfence_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drawfence_test.go b/drawfence_test.go index 6f9a0aa..56fa605 100644 --- a/drawfence_test.go +++ b/drawfence_test.go @@ -160,12 +160,16 @@ func TestReplayPairsFindsWhatAWholeReplayFinds(t *testing.T) { } return nil }) + compared := 0 for _, root := range roots { - wantPairsFindAll(t, root.label, renderDraws(root.t).reads) + compared += wantPairsFindAll(t, root.label, renderDraws(root.t).reads) if root.t.isRecord && len(root.t.fields) > 0 { - wantPairsFindAll(t, root.label+" as a record", columnDraws(root.t, sortedNames(root.t.fields)).reads) + compared += wantPairsFindAll(t, root.label+" as a record", columnDraws(root.t, sortedNames(root.t.fields)).reads) } } + if compared == 0 { + t.Error("no read set rendering together holds two table reads, so the comparison proved nothing") + } } func TestReplayPairsFindsWhatAWholeReplayOfSelectedRowsFinds(t *testing.T) { @@ -209,7 +213,8 @@ func TestReplayPairsFindsWhatAWholeReplayOfSelectedRowsFinds(t *testing.T) { } } -func wantPairsFindAll(t *testing.T, label string, reads []pathRead) { +// wantPairsFindAll counts the read sets rendering together that hold two table reads or more. +func wantPairsFindAll(t *testing.T, label string, reads []pathRead) int { t.Helper() var tabled []pathRead for _, r := range reads { @@ -219,7 +224,11 @@ func wantPairsFindAll(t *testing.T, label string, reads []pathRead) { } pairs := replayPairs(reads) var whole error + compared := 0 eachRenderSet(tabled, func(set []pathRead) { + if len(set) > 1 { + compared++ + } var d pinSet for _, r := range set { if err := r.tr.replay(&d); err != nil && whole == nil { @@ -230,6 +239,7 @@ func wantPairsFindAll(t *testing.T, label string, reads []pathRead) { if (pairs == nil) != (whole == nil) { t.Errorf("%s: replayPairs = %v, a whole replay of every read set rendering together = %v", label, pairs, whole) } + return compared } // eachRenderSet calls fn with every maximal set of reads that render together, by Bron–Kerbosch.