-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStringAstTransformTests.cs
More file actions
62 lines (49 loc) · 1.96 KB
/
StringAstTransformTests.cs
File metadata and controls
62 lines (49 loc) · 1.96 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
53
54
55
56
57
58
59
60
61
62
using NUnit.Framework;
using RegexParser.Patterns;
using RegexParser.Tests.Asserts;
using RegexParser.Transforms;
namespace RegexParser.Tests.Transforms
{
[TestFixture]
public class StringASTTransformTests
{
private BaseASTTransform transform = new StringASTTransform();
[Test]
public void OneChar()
{
string patternText = "x";
BasePattern expected = new GroupPattern(true,
new CharEscapePattern('x'));
RegexAssert.IsASTTransformCorrect(expected, patternText, transform);
}
[Test]
public void TwoChars()
{
string patternText = "cd";
BasePattern expected = new GroupPattern(true,
new StringPattern("cd"));
RegexAssert.IsASTTransformCorrect(expected, patternText, transform);
}
[Test]
public void ManyChars()
{
string patternText = @"A longer string\.";
BasePattern expected = new GroupPattern(true,
new StringPattern("A longer string."));
RegexAssert.IsASTTransformCorrect(expected, patternText, transform);
}
[Test]
public void ManyCharsWithClasses()
{
string patternText = @"ab[cd][efg]hijk\dm";
BasePattern expected = new GroupPattern(true,
new StringPattern("ab"),
new CharGroupPattern(true, "cd"),
new CharGroupPattern(true, "efg"),
new StringPattern("hijk"),
CharGroupPattern.DigitChar,
new CharEscapePattern('m'));
RegexAssert.IsASTTransformCorrect(expected, patternText, transform);
}
}
}