mirror of
https://github.com/SabreTools/SabreTools.IO.git
synced 2026-07-08 17:57:02 +00:00
38 lines
967 B
C#
38 lines
967 B
C#
using System;
|
|
using System.Linq;
|
|
using Xunit;
|
|
|
|
namespace SabreTools.Text.Compare.Test
|
|
{
|
|
public class NaturalComparerTests
|
|
{
|
|
[Fact]
|
|
public void ListSort_Numeric()
|
|
{
|
|
// Setup arrays
|
|
string[] sortable = ["0", "100", "5", "2", "1000"];
|
|
string[] expected = ["0", "2", "5", "100", "1000"];
|
|
|
|
// Run sorting on array
|
|
Array.Sort(sortable, new NaturalComparer());
|
|
|
|
// Check the output
|
|
Assert.True(sortable.SequenceEqual(expected));
|
|
}
|
|
|
|
[Fact]
|
|
public void ListSort_Mixed()
|
|
{
|
|
// Setup arrays
|
|
string[] sortable = ["b3b", "c", "b", "a", "a1"];
|
|
string[] expected = ["a", "a1", "b", "b3b", "c"];
|
|
|
|
// Run sorting on array
|
|
Array.Sort(sortable, new NaturalComparer());
|
|
|
|
// Check the output
|
|
Assert.True(sortable.SequenceEqual(expected));
|
|
}
|
|
}
|
|
}
|