mirror of
https://github.com/0xJ1M/MathsEngine.git
synced 2026-06-05 01:10:08 +00:00
Inital Commit
This commit is contained in:
30
MathEngine/EngineTests/Parser Tests/TreeNodeTests.cs
Normal file
30
MathEngine/EngineTests/Parser Tests/TreeNodeTests.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using MathEngine.Parser.Tokeniser;
|
||||
using MathEngine.Parser.Parser;
|
||||
namespace EngineTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing the TreeNode class
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TreeNodeTests
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Test to see if a simple expression is constructed correctly
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestTreeNodexpression()
|
||||
{
|
||||
string testExp = "3+4";
|
||||
TreeNode exptectedTree = new(Token.Plus);
|
||||
Token tokfour = new("4", Token.Type.Numeric, Token.NumericType.Decimal, 0);
|
||||
Token tokthree = new("3", Token.Type.Numeric, Token.NumericType.Decimal, 0);
|
||||
TreeNode four = new(tokfour);
|
||||
TreeNode three = new(tokthree);
|
||||
exptectedTree.AddChildNode(four);
|
||||
exptectedTree.AddChildNode(three);
|
||||
ExpressionTree returnedTree = new (testExp);
|
||||
Assert.IsTrue(exptectedTree.Equals(returnedTree));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user