Upsilon/UpsilonTests/GeneralTests/BasicMathExpressions.cs

62 lines
1.9 KiB
C#
Raw Permalink Normal View History

2018-11-26 15:55:10 +00:00
using Upsilon;
2018-11-10 12:11:36 +00:00
using Upsilon.Evaluator;
using Xunit;
2018-11-23 13:38:45 +00:00
namespace UpsilonTests.GeneralTests
2018-11-10 12:11:36 +00:00
{
2018-11-23 11:55:28 +00:00
public class BasicMathExpressions : TestClass
2018-11-10 12:11:36 +00:00
{
2018-11-23 11:55:28 +00:00
public BasicMathExpressions(StaticScriptFixture fix) : base(fix)
{
}
2018-11-10 12:11:36 +00:00
[Theory]
[InlineData("1+1", 2)]
[InlineData("1000+1", 1001)]
[InlineData("1+1000", 1001)]
[InlineData("1 + 1000", 1001)]
[InlineData("8612648+6153205", 14765853)]
[InlineData("0.5 + 2", 2.5)]
[InlineData("0.005 + 2.2", 2.205)]
public void Addition(string input, double expectedOutput)
{
2018-11-26 15:55:10 +00:00
var actual = Executor.EvaluateScript<double>(input, Options);
Assert.Equal(expectedOutput, actual, 8);
2018-11-10 12:11:36 +00:00
}
[Theory]
[InlineData("1-1", 0)]
[InlineData("100-45", 55)]
[InlineData("1-1200", -1199)]
[InlineData("341564-5646843", -5305279)]
[InlineData("1-0.5", 0.5)]
[InlineData("10.256-2.8546", 7.4014)]
public void Subtraction(string input, double expectedOutput)
{
2018-11-26 15:55:10 +00:00
var actual = Executor.EvaluateScript<double>(input, Options);
Assert.Equal(expectedOutput, actual, 8);
2018-11-10 12:11:36 +00:00
}
[Theory]
[InlineData("1*1", 1)]
[InlineData("100 * 100", 10000)]
[InlineData("21312 * 41684", 888369408)]
public void Multiplication(string input, double expectedOutput)
{
2018-11-26 15:55:10 +00:00
var actual = Executor.EvaluateScript<double>(input, Options);
Assert.Equal(expectedOutput, actual, 8);
2018-11-10 12:11:36 +00:00
}
[Theory]
[InlineData("1/1", 1)]
[InlineData("1000 / 10", 100)]
[InlineData("656486 / 5146", 127.57209483)]
[InlineData("656486 / 5146.0", 127.57209483)]
2018-11-10 12:11:36 +00:00
public void Divison(string input, double expectedOutput)
{
2018-11-26 15:55:10 +00:00
var actual = Executor.EvaluateScript<double>(input, Options);
Assert.Equal(expectedOutput, actual, 8);
2018-11-10 12:11:36 +00:00
}
}
}