jellyfin/tests/Jellyfin.Controller.Tests/AlphanumComparatorTests.cs
obradovichv 0282a1ed09 Fix string culture specificity
Fix bug in SsaParser.cs primary color {\1c} formatting that would leave
behind the {\1c} closing token and instead append </font> token
unconditionally to the dialogue text. Add tests.

Change AlphanumComparatorTests.cs complementary test data generation
from an array shuffle to an array reversal. Although it was previously
using a seeded Random, the shuffle itself could result in no
rearrangement of elements if the seed or test data changed over time.
The reversal guarantees reordering of elements and has the added benefit
of simplifying the test code since no special handling is needed for
arrays of 2 elements.

Change DailyTrigger.cs logging of TriggerDate format to
"yyyy-MM-dd HH:mm:ss.fff zzz" for consistency with configured log
timestamp format and change DueTime format to culture-invariant "c"
format.
2021-01-03 20:17:27 +02:00

31 lines
1.4 KiB
C#

using System;
using System.Linq;
using MediaBrowser.Controller.Sorting;
using Xunit;
namespace Jellyfin.Controller.Tests
{
public class AlphanumComparatorTests
{
// InlineData is pre-sorted
[Theory]
[InlineData(null, "", "1", "9", "10", "a", "z")]
[InlineData("50F", "100F", "SR9", "SR100")]
[InlineData("image-1.jpg", "image-02.jpg", "image-4.jpg", "image-9.jpg", "image-10.jpg", "image-11.jpg", "image-22.jpg")]
[InlineData("Hard drive 2GB", "Hard drive 20GB")]
[InlineData("b", "e", "è", "ě", "f", "g", "k")]
[InlineData("123456789", "123456789a", "abc", "abcd")]
[InlineData("12345678912345678912345678913234567891", "123456789123456789123456789132345678912")]
[InlineData("12345678912345678912345678913234567891", "12345678912345678912345678913234567891")]
[InlineData("12345678912345678912345678913234567891", "12345678912345678912345678913234567892")]
[InlineData("12345678912345678912345678913234567891a", "12345678912345678912345678913234567891a")]
[InlineData("12345678912345678912345678913234567891a", "12345678912345678912345678913234567891b")]
public void AlphanumComparatorTest(params string?[] strings)
{
var copy = strings.Reverse().ToArray();
Array.Sort(copy, new AlphanumComparator());
Assert.True(strings.SequenceEqual(copy));
}
}
}