mirror of
https://github.com/0xJ1M/MathsEngine.git
synced 2026-06-05 03:00:07 +00:00
WIP
This commit is contained in:
@@ -19,8 +19,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNodeFactoryBinaryNodesOnDefinedOperations()
|
||||
{
|
||||
NumericNode node1 = new(new DecimalValue(200));
|
||||
NumericNode node2 = new(new DecimalValue(100));
|
||||
NumericNode<DecimalValue> node1 = new(new DecimalValue(200));
|
||||
NumericNode<DecimalValue> node2 = new(new DecimalValue(100));
|
||||
|
||||
Token plus = Token.Plus;
|
||||
Token minus = Token.Minus;
|
||||
@@ -39,8 +39,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNodeFactoryBinaryNodesOnExponentiationRaisesException()
|
||||
{
|
||||
NumericNode<decimal> node1 = new(200);
|
||||
NumericNode<decimal> node2 = new(100);
|
||||
NumericNode<DecimalValue> node1 = new(new DecimalValue(200));
|
||||
NumericNode<DecimalValue> node2 = new(new DecimalValue(100));
|
||||
|
||||
Token exp = new("^", TokenType.Exponentiation);
|
||||
try
|
||||
@@ -59,8 +59,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNodeFactoryBinaryNodesOnInvalidOperationTokenRaisesException()
|
||||
{
|
||||
NumericNode<decimal> node1 = new(200);
|
||||
NumericNode<decimal> node2 = new(100);
|
||||
NumericNode<DecimalValue> node1 = new(new DecimalValue(200));
|
||||
NumericNode<DecimalValue> node2 = new(new DecimalValue(100));
|
||||
|
||||
Token invalid = new("(", TokenType.OpenBracket);
|
||||
try
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Xunit;
|
||||
|
||||
using MathEngine.AST.Nodes;
|
||||
using MathEngine.Types;
|
||||
|
||||
namespace EngineTests.Parser_Tests.Nodes
|
||||
{
|
||||
@@ -15,8 +16,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNumericNodeAdd()
|
||||
{
|
||||
NumericNode<decimal> testNode1 = new(100);
|
||||
NumericNode<decimal> testNode2 = new(100);
|
||||
NumericNode<DecimalValue> testNode1 = new(new DecimalValue(100));
|
||||
NumericNode<DecimalValue> testNode2 = new(new DecimalValue(100));
|
||||
BaseNode result = testNode1 + testNode2;
|
||||
Assert.Equal("200", result.ToString());
|
||||
}
|
||||
@@ -27,8 +28,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNumericNodeAddDifferentTypesRaisesException()
|
||||
{
|
||||
NumericNode<int> testNode1 = new(100);
|
||||
NumericNode<decimal> testNode2 = new(100);
|
||||
NumericNode<DecimalValue> testNode1 = new(new DecimalValue(100));
|
||||
NumericNode<DecimalValue> testNode2 = new(new DecimalValue(100));
|
||||
try
|
||||
{
|
||||
BaseNode result = testNode1 + testNode2;
|
||||
@@ -46,8 +47,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNumericNodeSubtract()
|
||||
{
|
||||
NumericNode<decimal> testNode1 = new(100);
|
||||
NumericNode<decimal> testNode2 = new(100);
|
||||
NumericNode<DecimalValue> testNode1 = new(new DecimalValue(100));
|
||||
NumericNode<DecimalValue> testNode2 = new(new DecimalValue(100));
|
||||
BaseNode result = testNode1 - testNode2;
|
||||
Assert.Equal("0", result.ToString());
|
||||
}
|
||||
@@ -58,8 +59,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNumericNodeSubtractDifferentTypesRaisesException()
|
||||
{
|
||||
NumericNode<int> testNode1 = new(100);
|
||||
NumericNode<decimal> testNode2 = new(100);
|
||||
NumericNode<DecimalValue> testNode1 = new(new DecimalValue(100));
|
||||
NumericNode<DecimalValue> testNode2 = new(new DecimalValue(100));
|
||||
try
|
||||
{
|
||||
BaseNode result = testNode1 - testNode2;
|
||||
@@ -77,8 +78,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNumericNodeMultiply()
|
||||
{
|
||||
NumericNode<decimal> testNode1 = new(100);
|
||||
NumericNode<decimal> testNode2 = new(100);
|
||||
NumericNode<DecimalValue> testNode1 = new(new DecimalValue(100));
|
||||
NumericNode<DecimalValue> testNode2 = new(new DecimalValue(100));
|
||||
BaseNode result = testNode1 * testNode2;
|
||||
Assert.Equal("10000", result.ToString());
|
||||
}
|
||||
@@ -89,8 +90,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNumericNodeMultiplyDifferentTypesRaisesException()
|
||||
{
|
||||
NumericNode<int> testNode1 = new(100);
|
||||
NumericNode<decimal> testNode2 = new(100);
|
||||
NumericNode<DecimalValue> testNode1 = new(new DecimalValue(100));
|
||||
NumericNode<DecimalValue> testNode2 = new(new DecimalValue(100));
|
||||
try
|
||||
{
|
||||
BaseNode result = testNode1 * testNode2;
|
||||
@@ -108,8 +109,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNumericNodeDivide()
|
||||
{
|
||||
NumericNode<decimal> testNode1 = new(100);
|
||||
NumericNode<decimal> testNode2 = new(100);
|
||||
NumericNode<DecimalValue> testNode1 = new(new DecimalValue(100));
|
||||
NumericNode<DecimalValue> testNode2 = new(new DecimalValue(100));
|
||||
BaseNode result = testNode1 / testNode2;
|
||||
Assert.Equal("1", result.ToString());
|
||||
}
|
||||
@@ -120,8 +121,8 @@ namespace EngineTests.Parser_Tests.Nodes
|
||||
[Fact]
|
||||
public void TestNumericNodeDividedDifferentTypesRaisesException()
|
||||
{
|
||||
NumericNode<int> testNode1 = new(100);
|
||||
NumericNode<decimal> testNode2 = new(100);
|
||||
NumericNode<DecimalValue> testNode1 = new(new DecimalValue(100));
|
||||
NumericNode<DecimalValue> testNode2 = new(new DecimalValue(100));
|
||||
try
|
||||
{
|
||||
BaseNode result = testNode1 / testNode2;
|
||||
|
||||
20
MathEngine/EngineTests/Types/DecimalValueTests.cs
Normal file
20
MathEngine/EngineTests/Types/DecimalValueTests.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Xunit;
|
||||
|
||||
using MathEngine.Types;
|
||||
|
||||
namespace EngineTests.Types
|
||||
{
|
||||
public class DecimalValueTests
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Test that an ArgumentException is raised if zero is given for SegmentSize
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ConstructorReturnsValidDecimalValueInstance()
|
||||
{
|
||||
decimal expected = 123;
|
||||
var value1 = new DecimalValue(123);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user