2020-03-04 18:54:46 -05:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using Xunit;
|
|
|
|
|
2021-06-19 12:02:33 -04:00
|
|
|
namespace Jellyfin.Extensions.Tests
|
2020-03-04 18:54:46 -05:00
|
|
|
{
|
2021-06-19 12:02:33 -04:00
|
|
|
public class AlphanumericComparatorTests
|
2020-03-04 18:54:46 -05:00
|
|
|
{
|
2020-03-05 06:24:12 -05:00
|
|
|
// InlineData is pre-sorted
|
2020-03-04 18:54:46 -05:00
|
|
|
[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")]
|
2021-06-19 12:02:33 -04:00
|
|
|
public void AlphanumericComparatorTest(params string?[] strings)
|
2020-03-04 18:54:46 -05:00
|
|
|
{
|
2021-01-03 13:13:21 -05:00
|
|
|
var copy = strings.Reverse().ToArray();
|
2021-06-19 12:02:33 -04:00
|
|
|
Array.Sort(copy, new AlphanumericComparator());
|
2022-12-27 10:53:58 -05:00
|
|
|
Assert.Equal(strings, copy);
|
2020-03-04 18:54:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|