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) <noreply@anthropic.com>
This commit is contained in:
AK Clark
2026-05-15 01:10:57 -05:00
parent 0499bbae7e
commit ebce0c073b

View File

@@ -855,6 +855,8 @@ namespace TemplatesTests
[DataRow("<samplerate[#,##0'Hz ']>", "44,100Hz ", "en-CA", "any")]
[DataRow("<samplerate[#,##0'Hz ']>", "44100Hz ", "de-CH", "any")]
[DataRow("<samplerate[#,##0'Hz ']>", "44\u00A0100Hz ", "fr-CA", "any")] // non-breaking-space
[DataRow("<samplerate[#,##0'Hz ']>", "44.100Hz ", "de-DE", "any")] // period thousands separator
[DataRow("<samplerate[#,##0'Hz ']>", "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<Templates.FileTemplate>(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<Templates.FileTemplate>("<samplerate[#,##0]>", 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("<tag>", "Tag1, Tag2, Tag3")]
[DataRow("<tag [separator( - )]>", "Tag1 - Tag2 - Tag3")]