-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve matcher algorithm for some edge cases
- Add direct return for single video and subtitle match - Implement merging of items with the same filename - Add unit test for MergeSameFilenameItems function
- Loading branch information
Showing
3 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
SubRenamer.Tests/MatcherTests/MergeSameFilenameItemsTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using SubRenamer.Core; | ||
using static SubRenamer.Core.MatcherHelper; | ||
|
||
namespace SubRenamer.Tests.MatcherTests; | ||
|
||
[TestFixture] | ||
public class MergeSameFilenameItemsTests | ||
{ | ||
[Test] | ||
public void Basic() | ||
{ | ||
var input = new List<MatchItem> | ||
{ | ||
new("", "a.mp4", ""), | ||
new("", "", "b.srt"), | ||
|
||
new("", "", "a.srt"), | ||
new("", "b.mp4", ""), | ||
|
||
|
||
new("", "v1.mp4", ""), | ||
new("", "", "s1.srt"), | ||
new("2", "v2.mp4", ""), | ||
new("2", "", "s2.srt"), | ||
}; | ||
var output = new List<MatchItem> | ||
{ | ||
new("a", "a.mp4", "a.srt"), | ||
new("b", "b.mp4", "b.srt"), | ||
|
||
new("", "v1.mp4", ""), | ||
new("", "", "s1.srt"), | ||
new("2", "v2.mp4", ""), | ||
new("2", "", "s2.srt"), | ||
}; | ||
|
||
var result = MergeSameFilenameItems(input); | ||
Assert.That(result, Is.EqualTo(output)); | ||
} | ||
} |