Skip to content

Commit 093eb37

Browse files
Add tests to WildCardMatcher
1 parent 1562c6b commit 093eb37

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Algorithms.Strings.PatternMatching;
2+
using NUnit.Framework;
3+
4+
namespace Algorithms.Tests.Strings.PatternMatching;
5+
6+
public static class WildCardMatcherTests
7+
{
8+
[TestCase("aab", "c*a*b", true)]
9+
[TestCase("aaa", "aa", false)]
10+
[TestCase("aaa", "a.a", true)]
11+
[TestCase("aaab", "aa*", false)]
12+
[TestCase("aaab", ".*", true)]
13+
[TestCase("a", "bbbb", false)]
14+
[TestCase("", "bbbb", false)]
15+
[TestCase("a", "", false)]
16+
[TestCase("", "", true)]
17+
public static void MatchPattern(string inputString, string pattern, bool expected)
18+
{
19+
// Act
20+
var result = WildCardMatcher.MatchPattern(inputString, pattern);
21+
22+
// Assert
23+
Assert.That(result, Is.EqualTo(expected));
24+
}
25+
26+
[Test]
27+
public static void MatchPatternThrowsArgumentException()
28+
{
29+
// Arrange
30+
var inputString = "abc";
31+
var pattern = "*abc";
32+
33+
// Assert
34+
Assert.Throws<System.ArgumentException>(() => WildCardMatcher.MatchPattern(inputString, pattern));
35+
}
36+
}

0 commit comments

Comments
 (0)