27 lines
899 B
C#
27 lines
899 B
C#
|
|
using TeamUp.SharedKernel.Metrics;
|
||
|
|
using Xunit;
|
||
|
|
|
||
|
|
namespace TeamUp.IntegrationTests;
|
||
|
|
|
||
|
|
/// <summary>Unit coverage for the north-star metric helper (no database).</summary>
|
||
|
|
public sealed class EditDistanceTests
|
||
|
|
{
|
||
|
|
[Theory]
|
||
|
|
[InlineData("", "", 0)]
|
||
|
|
[InlineData("abc", "abc", 0)]
|
||
|
|
[InlineData("", "abc", 3)]
|
||
|
|
[InlineData("abc", "", 3)]
|
||
|
|
[InlineData("kitten", "sitting", 3)]
|
||
|
|
[InlineData("spec v1", "spec v2", 1)]
|
||
|
|
public void Levenshtein_counts_edits(string a, string b, int expected) =>
|
||
|
|
Assert.Equal(expected, EditDistance.Levenshtein(a, b));
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void Normalized_is_zero_when_unchanged() =>
|
||
|
|
Assert.Equal(0d, EditDistance.Normalized("approved as-is", "approved as-is"));
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void Normalized_is_between_zero_and_one() =>
|
||
|
|
Assert.InRange(EditDistance.Normalized("the AI wrote this", "the human edited this"), 0d, 1d);
|
||
|
|
}
|