From ebce0c073bf54bc93e5c28e9185b0a83d1a7ef50 Mon Sep 17 00:00:00 2001 From: AK Clark Date: Fri, 15 May 2026 01:10:57 -0500 Subject: [PATCH] Fix Tag_culture_test platform dependency on de-CH NumberGroupSeparator The de-CH row hard-coded U+2019 as the expected thousands separator, which only matches certain .NET/ICU/CLDR data versions. Linux .NET hosts return U+0027 (ASCII apostrophe) for the same culture, so every Linux CI run failed this test regardless of the actual change under test. Resolve U+2019 in DataRow expectations to the runtime culture's NumberGroupSeparator before comparison so the test stays stable across hosts while still verifying the engine respects culture-specific formatting. - Added DataRows for de-DE (period) and ja-JP (comma) - Added Samplerate_template_uses_culture_NumberGroupSeparator as an explicit regression guard that asserts the engine uses whatever the runtime CultureInfo reports Fixes #1813. Verified locally: 584 tests pass, 0 failed (565 succeeded, 19 skipped Windows-only). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../TemplatesTests.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs b/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs index 0b661dc6..bb326ebe 100644 --- a/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs +++ b/Source/_Tests/LibationFileManager.Tests/TemplatesTests.cs @@ -855,6 +855,8 @@ namespace TemplatesTests [DataRow("", "44,100Hz ", "en-CA", "any")] [DataRow("", "44’100Hz ", "de-CH", "any")] [DataRow("", "44\u00A0100Hz ", "fr-CA", "any")] // non-breaking-space + [DataRow("", "44.100Hz ", "de-DE", "any")] // period thousands separator + [DataRow("", "44,100Hz ", "ja-JP", "any")] // comma thousands separator public void Tag_culture_test(string template, string expected, string cultureName, string title) { var bookDto = Shared.GetLibraryBook(); @@ -863,6 +865,12 @@ namespace TemplatesTests bookDto.Authors = [new("Isaac Asimov", "B00IA42MOV")]; var culture = new CultureInfo(cultureName); + // U+2019 in DataRow expectations is a placeholder for whatever the + // platform's current ICU/CLDR data says the culture's NumberGroupSeparator + // is. de-CH in particular returns U+2019 on some hosts and U+0027 on + // others; resolve to whatever the runtime says to keep the test stable. + expected = expected.Replace("’", culture.NumberFormat.NumberGroupSeparator); + Templates.TryGetTemplate(template, out var fileTemplate).Should().BeTrue(); fileTemplate @@ -870,6 +878,28 @@ namespace TemplatesTests .Should().Be(expected); } + [TestMethod] + [DataRow("en-CA")] + [DataRow("en-US")] + [DataRow("de-CH")] + [DataRow("de-DE")] + [DataRow("fr-CA")] + [DataRow("ja-JP")] + public void Samplerate_template_uses_culture_NumberGroupSeparator(string cultureName) + { + // Regression guard for the de-CH / ICU mismatch (issue #1813): the engine + // must always use the runtime culture's NumberGroupSeparator, not a + // hard-coded codepoint, so the test stays stable across .NET hosts. + var culture = new CultureInfo(cultureName); + var bookDto = Shared.GetLibraryBook(); + bookDto.LengthInMinutes = TimeSpan.FromMinutes(123456789); + + Templates.TryGetTemplate("", out var fileTemplate).Should().BeTrue(); + var actual = fileTemplate.GetName(bookDto, new MultiConvertFileProperties { OutputFileName = string.Empty }, culture); + + actual.Should().Be($"44{culture.NumberFormat.NumberGroupSeparator}100"); + } + [TestMethod] [DataRow("", "Tag1, Tag2, Tag3")] [DataRow("", "Tag1 - Tag2 - Tag3")]