-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathParserTest.cs
More file actions
74 lines (70 loc) · 1.98 KB
/
ParserTest.cs
File metadata and controls
74 lines (70 loc) · 1.98 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
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using NFluent;
using ReClassNET.AddressParser;
using Xunit;
namespace ReClass.NET_Tests.AddressParser
{
public class ParserTest
{
[Theory]
[InlineData("-")]
[InlineData("+")]
[InlineData("*")]
[InlineData("/")]
[InlineData(",")]
[InlineData("(")]
[InlineData(")")]
[InlineData("[")]
[InlineData("]")]
[InlineData("1-")]
[InlineData("1(")]
[InlineData("1)")]
[InlineData("1[")]
[InlineData("1]")]
[InlineData("(1")]
[InlineData(")1")]
[InlineData("[1")]
[InlineData("]1")]
[InlineData("1+(")]
[InlineData("1+)")]
[InlineData("1 + ()")]
[InlineData("(1 + 2")]
[InlineData("1 + 2)")]
[InlineData("[1 + 2)")]
[InlineData("(1 + 2]")]
[InlineData("[1,")]
[InlineData("[1,]")]
[InlineData("[1,2]")]
[InlineData("1,")]
[InlineData("1,2")]
public void InvalidExpressionTests(string expression)
{
Check.ThatCode(() => Parser.Parse(expression)).Throws<ParseException>();
}
[Theory]
[InlineData("1", typeof(ConstantExpression))]
[InlineData("1 + 2", typeof(AddExpression))]
[InlineData("1 - 2", typeof(SubtractExpression))]
[InlineData("1 * 2", typeof(MultiplyExpression))]
[InlineData("1 / 2", typeof(DivideExpression))]
[InlineData("1 + 2 * 3", typeof(AddExpression))]
[InlineData("(1 + 2) * 3", typeof(MultiplyExpression))]
[InlineData("1 + (2 * 3)", typeof(AddExpression))]
[InlineData("(1 + (2 * 3))", typeof(AddExpression))]
[InlineData("[1]", typeof(ReadMemoryExpression))]
[InlineData("[1,4]", typeof(ReadMemoryExpression))]
[InlineData("[1,8]", typeof(ReadMemoryExpression))]
[InlineData("<test>", typeof(ModuleExpression))]
[InlineData("[<test>]", typeof(ReadMemoryExpression))]
public void ValidExpressionTests(string expression, Type type)
{
Check.That(Parser.Parse(expression)).IsInstanceOfType(type);
}
[Fact]
public void ReadMemoryDefaultByteCountCheck()
{
var expression = (ReadMemoryExpression)Parser.Parse("[1]");
Check.That(expression.ByteCount).IsEqualTo(IntPtr.Size);
}
}
}