From 14c288c0e4d0daf12e5aa304071a60cfd1cf1a33 Mon Sep 17 00:00:00 2001 From: PapaCharlie Date: Tue, 23 Jul 2024 17:30:33 -0700 Subject: [PATCH] Improve test --- mem/buffers_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mem/buffers_test.go b/mem/buffers_test.go index 113a265dca48..cfa23f669e2f 100644 --- a/mem/buffers_test.go +++ b/mem/buffers_test.go @@ -211,27 +211,27 @@ func (s) TestSplit(t *testing.T) { } } + // Take a ref of the original buffer ref1 := buf.Ref() split1 := buf.Split(2) checkBufData(buf, data[:2]) checkBufData(split1, data[2:]) + // Check that even though buf was split, the reference wasn't modified checkBufData(ref1, data) + ref1.Free() + // Check that splitting the buffer more than once works as intended. split2 := split1.Split(1) checkBufData(split1, data[2:3]) checkBufData(split2, data[3:]) - splitRef := split1.Ref() - ref2 := buf.Ref() - split1.Free() + // If any of the following frees actually free the buffer, the test will fail. buf.Free() - ref1.Free() - splitRef.Free() split2.Free() ready = true - ref2.Free() + split1.Free() if !freed { t.Fatalf("Buffer never freed")