|
| 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