Kavita/API.Tests/Comparers/StringLogicalComparerTest.cs
Joseph Milazzo 591b574706
Unit Tests & New Natural Sort (#941)
* Added a lot of tests

* More tests! Added a Parser.NormalizePath to normalize all paths within Kavita.

* Fixed a bug where MarkChaptersAsUnread implementation wasn't consistent between different files and lead to extra row generation for no reason.

* Added more unit tests

* Found a better implementation for Natural Sorting. Added tests and validate it works. Next commit will swap out natural Sort for new Extension.

* Replaced NaturalSortComparer with OrderByNatural.

* Drastically simplified and sped up FindFirstEntry for finding cover images in archives

* Initial fix for a epub bug where metadata defines key as absolute path but document uses a relative path. We now have a hack to correct for the epub.
2022-01-15 07:39:34 -08:00

35 lines
931 B
C#

using System;
using API.Comparators;
using Xunit;
namespace API.Tests.Comparers
{
public class StringLogicalComparerTest
{
[Theory]
[InlineData(
new[] {"x1.jpg", "x10.jpg", "x3.jpg", "x4.jpg", "x11.jpg"},
new[] {"x1.jpg", "x3.jpg", "x4.jpg", "x10.jpg", "x11.jpg"}
)]
[InlineData(
new[] {"a.jpg", "aaa.jpg", "1.jpg", },
new[] {"1.jpg", "a.jpg", "aaa.jpg"}
)]
[InlineData(
new[] {"a.jpg", "aaa.jpg", "1.jpg", "!cover.png"},
new[] {"!cover.png", "1.jpg", "a.jpg", "aaa.jpg"}
)]
public void StringComparer(string[] input, string[] expected)
{
Array.Sort(input, StringLogicalComparer.Compare);
var i = 0;
foreach (var s in input)
{
Assert.Equal(s, expected[i]);
i++;
}
}
}
}