mirror of
https://github.com/0xJ1M/MathsEngine.git
synced 2026-06-05 05:20:07 +00:00
31 lines
1014 B
C#
31 lines
1014 B
C#
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));
|
|
}
|
|
}
|
|
}
|