-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathQuantifierPatternTests.cs
More file actions
52 lines (45 loc) · 2.15 KB
/
QuantifierPatternTests.cs
File metadata and controls
52 lines (45 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using RegexParser.Patterns;
namespace RegexParser.Tests.Patterns
{
[TestFixture]
public class QuantifierPatternTests
{
[Test]
public void Quantifiers()
{
BasePattern actual = BasePattern.CreatePattern(@"\d*\s?\W+x*?\n??y+?");
BasePattern expected = new GroupPattern(
true,
new BasePattern[]
{
new QuantifierPattern(CharGroupPattern.DigitChar, 0, null, true),
new QuantifierPattern(CharGroupPattern.WhitespaceChar, 0, 1, true),
new QuantifierPattern(CharGroupPattern.WordChar.Negated, 1, null, true),
new QuantifierPattern(new CharEscapePattern('x'), 0, null, false),
new QuantifierPattern(new CharEscapePattern('\n'), 0, 1, false),
new QuantifierPattern(new CharEscapePattern('y'), 1, null, false)
});
Assert.AreEqual(expected, actual);
}
[Test]
public void Doubled()
{
BasePattern actual = BasePattern.CreatePattern(@"((ab)+)+");
BasePattern expected = new GroupPattern(true,
new QuantifierPattern(
new GroupPattern(true,
new QuantifierPattern(
new GroupPattern(true,
new CharEscapePattern('a'),
new CharEscapePattern('b')),
1, null, true)),
1, null, true));
Assert.AreEqual(expected, actual, "With parentheses");
}
}
}