mirror of
https://github.com/0xJ1M/MathsEngine.git
synced 2026-06-05 02:00:06 +00:00
31 lines
1022 B
C#
31 lines
1022 B
C#
using Xunit;
|
|
|
|
namespace EngineTests.Expression
|
|
{
|
|
public class ExpressionTests
|
|
{
|
|
/// <summary>
|
|
/// Test that Evaluate returns valid output
|
|
/// </summary>
|
|
[Fact]
|
|
public void TestTokenizeBasicExpressionEvalutesToCorrectResult()
|
|
{
|
|
MathEngine.Expression.Expression test_expression = new("1+1");
|
|
MathEngine.Expression.Expression expected_result = new("2");
|
|
Assert.Equivalent(expected_result, test_expression.Evaluate(), true);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Test that Expression involing all basic operators returns valid reuslt
|
|
/// </summary>
|
|
[Fact]
|
|
public void TestTokenizeBasicExpressionAllOperatorsEvalutesToCorrectResult()
|
|
{
|
|
MathEngine.Expression.Expression test_expression = new("1+1-2*3/4");
|
|
MathEngine.Expression.Expression expected_result = new("0.5");
|
|
Assert.Equivalent(expected_result, test_expression.Evaluate(), true);
|
|
}
|
|
}
|
|
}
|