Skip to content

Commit

Permalink
test custom writing systems to ensure they don't crash (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev authored and myieye committed Feb 28, 2025
1 parent f593852 commit f90b45a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion backend/FwLite/LcmCrdt/Data/SqlSortingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private static Expression<Func<string, WritingSystem, string>> CollateUnicodeExp
internal static string CollationName(WritingSystem ws)
{
//don't use ':' in the name, it won't work
return $"NOCASE_WS_{ws.WsId}";
//'-' is not allowed in a collation name according to linq2db, blocked on bug https://github.com/linq2db/linq2db/issues/4849
return $"NOCASE_WS_{ws.WsId.Code.Replace("-", "_")}";
}
}
20 changes: 19 additions & 1 deletion backend/FwLite/MiniLcm.Tests/SortingTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ private Task CreateEntry(string headword)
return Api.CreateEntry(new() { LexemeForm = { { "en", headword } }, });
}


// ReSharper disable InconsistentNaming
const string Ru_A= "\u0410";
const string Ru_a = "\u0430";
Expand All @@ -32,4 +31,23 @@ public async Task EntriesAreSorted(string headwords)
var entries = await Api.GetEntries().Select(e => e.Headword()).ToArrayAsync();
entries.Should().Equal(headwordList);
}

[Theory]
[InlineData("lwl-Zxxx-x-minority2-audio")]
//note this test does not ensure the sorting works, just that it doesn't crash when creating or querying the data
public async Task CanUseValidWritingSystems(string wsId)
{
await Api.CreateWritingSystem(WritingSystemType.Vernacular,
new()
{
Id = Guid.NewGuid(),
Type = WritingSystemType.Vernacular,
WsId = wsId,
Name = "custom",
Abbreviation = "Cs",
Font = "Arial"
});
await Api.GetEntries(new QueryOptions(new SortOptions(SortField.Headword, wsId)))
.ToArrayAsync();
}
}

0 comments on commit f90b45a

Please sign in to comment.