From fb23c1d82cc3e48d9c260caf6c2646abbee01b25 Mon Sep 17 00:00:00 2001 From: MPCoreDeveloper Date: Fri, 4 Sep 2026 22:08:54 +0200 Subject: [PATCH] test: report exact missing row ids in growing-table reopen survival test The intermittent 500-vs-499 failure (issue #400) gives no clue which row is lost. Replace the count assertion with an explicit expected-vs-actual id set comparison that prints missing/extra ids on failure, so a failing runner shows whether the tail row is lost (write/truncation) or a middle row (parse/arena). --- .../Storage/SingleFileCompressionTests.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/SharpCoreDB.Tests/Storage/SingleFileCompressionTests.cs b/tests/SharpCoreDB.Tests/Storage/SingleFileCompressionTests.cs index aa81003e..ef4d185c 100644 --- a/tests/SharpCoreDB.Tests/Storage/SingleFileCompressionTests.cs +++ b/tests/SharpCoreDB.Tests/Storage/SingleFileCompressionTests.cs @@ -7,6 +7,7 @@ namespace SharpCoreDB.Tests.Storage; using System; using System.IO; using System.IO.Compression; +using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading; @@ -473,7 +474,13 @@ public void DatabaseFactory_Compression_GrowingTable_ReopenSelectShouldSurvive() // Reopen and SELECT must survive with the data intact. var db2 = factory.CreateWithOptions(_testDbPath, "unused", options); var results = db2.ExecuteQuery("SELECT * FROM t ORDER BY id"); - Assert.Equal(500, results.Count); + var actualIds = results.Select(r => Convert.ToInt64(r["id"])).OrderBy(id => id).ToList(); + var expectedIds = Enumerable.Range(0, 500).Select(i => (long)i).ToList(); + var missing = expectedIds.Except(actualIds).ToList(); + var extra = actualIds.Except(expectedIds).ToList(); + Assert.True( + missing.Count == 0 && extra.Count == 0, + $"Row set mismatch after reopen: missing={missing.Count} [{string.Join(",", missing.Take(10))}], extra={extra.Count} [{string.Join(",", extra.Take(10))}]."); Assert.Equal("user42", results[42]["name"]?.ToString()); Assert.Equal("user499", results[499]["name"]?.ToString()); DisposeDatabase(db2);