aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs
diff options
context:
space:
mode:
authorWWWesten <4700006+WWWesten@users.noreply.github.com>2021-11-01 23:43:29 +0500
committerGitHub <noreply@github.com>2021-11-01 23:43:29 +0500
commit0a14279e2a21bcb9654a06a2d49e1e4f0cc5329c (patch)
treee1b1bd603b011ca98e5793e356326bf4a35a7050 /tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs
parentf2817fef743eeb75a00782ceea363b2d3e7dc9f2 (diff)
parent76eeb8f655424d295e73ced8349c6fefee6ddb12 (diff)
Merge branch 'jellyfin:master' into master
Diffstat (limited to 'tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs')
-rw-r--r--tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs b/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs
new file mode 100644
index 000000000..7730841a1
--- /dev/null
+++ b/tests/Jellyfin.Extensions.Tests/AlphanumericComparatorTests.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Linq;
+using Xunit;
+
+namespace Jellyfin.Extensions.Tests
+{
+ public class AlphanumericComparatorTests
+ {
+ // 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 AlphanumericComparatorTest(params string?[] strings)
+ {
+ var copy = strings.Reverse().ToArray();
+ Array.Sort(copy, new AlphanumericComparator());
+ Assert.True(strings.SequenceEqual(copy));
+ }
+ }
+}