From bf93858f025091b28c27037be94d5a5d744fef03 Mon Sep 17 00:00:00 2001 From: Phillip Hoff Date: Tue, 3 Nov 2026 00:32:26 -0800 Subject: [PATCH] Skip exchange set catalogues and plain comments in the AML corpus test (#42) The local-only AML corpus test read CATALOG.031 as a cell, because its extension looks like one, and required every non-empty DSID COMT to parse as AML metadata. COMT is free text in S-57: the published AML cells write key=value metadata there, but copies of the AML 3.0 trials cells in the S-64 test data carry a plain comment instead. The test now skips exchange set catalogues and only requires a comment written as key=value pairs to parse. Co-Authored-By: Claude Opus 5.5 --- tests/EncDotNet.UnitTests/AmlDataSetCorpusTests.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/EncDotNet.UnitTests/AmlDataSetCorpusTests.cs b/tests/EncDotNet.UnitTests/AmlDataSetCorpusTests.cs index 3c52b5b..4566762 100644 --- a/tests/EncDotNet.UnitTests/AmlDataSetCorpusTests.cs +++ b/tests/EncDotNet.UnitTests/AmlDataSetCorpusTests.cs @@ -27,7 +27,7 @@ public void RealCells_AreAmlAndEveryCodeResolvesInTheirCatalogue() int cells = 0, features = 0, values = 0; var paths = Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories) - .Where(p => CellExtension().IsMatch(Path.GetExtension(p))) + .Where(p => CellExtension().IsMatch(Path.GetExtension(p)) && !IsExchangeSetCatalogue(p)) .Order(StringComparer.Ordinal); foreach (var path in paths) @@ -53,8 +53,11 @@ public void RealCells_AreAmlAndEveryCodeResolvesInTheirCatalogue() failures.Add($"{cell}: product {dataSet.Product.Kind} has no AML product"); } + // COMT is free text in S-57. The published AML cells write AML metadata there as + // key=value pairs, but copies re-encoded by other tools can carry a plain comment, + // which isn't metadata. Only a comment written as pairs must parse. var comment = dataSet.Identification.Comment; - if (!string.IsNullOrWhiteSpace(comment) && dataSet.Metadata is null) + if (comment is not null && comment.Contains('=', StringComparison.Ordinal) && dataSet.Metadata is null) { failures.Add($"{cell}: COMT isn't AML metadata: \"{comment}\""); } @@ -113,6 +116,13 @@ private static int Count(IReadOnlyList attributes, S57ObjectC return attributes.Count; } + /// + /// Gets whether a file is an exchange set catalogue (CATALOG.031), which has a cell-like + /// extension but isn't a cell. + /// + private static bool IsExchangeSetCatalogue(string path) => + Path.GetFileNameWithoutExtension(path).Equals("CATALOG", StringComparison.OrdinalIgnoreCase); + /// Matches the extension of a base cell (.000) or an update cell (.001 and up). [GeneratedRegex(@"^\.\d{3}$")] private static partial Regex CellExtension();