mirror of
https://github.com/0xJ1M/MathsEngine.git
synced 2026-06-05 03:00:07 +00:00
Updated unit test coverage
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
using MathEngine.Parser.Tokeniser;
|
||||
|
||||
namespace EngineTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing the Tokeniser
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TokeniserTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Test the tokeniser on a basic string
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestTokeniseBasicString()
|
||||
{
|
||||
//Arrange
|
||||
string testString = "1+1";
|
||||
Token one = new("1", Token.Type.Numeric, Token.NumericType.Decimal, 0);
|
||||
List<Token> expectedValue = new()
|
||||
{
|
||||
one,
|
||||
Token.Plus,
|
||||
one
|
||||
};
|
||||
//Act
|
||||
List<Token> returnedValue = Tokeniser.Tokenise(testString);
|
||||
//Assert
|
||||
Assert.IsTrue(expectedValue.SequenceEqual(returnedValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the tokeniser on a basic string, but with significant ammounts of whitespace
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestTokeniseBasicStringWithWhiteSpace()
|
||||
{
|
||||
//Arrange
|
||||
string testString = " 1 + 1 ";
|
||||
Token one = new("1", Token.Type.Numeric, Token.NumericType.Decimal, 0);
|
||||
List<Token> expectedValue = new()
|
||||
{
|
||||
one,
|
||||
Token.Plus,
|
||||
one
|
||||
};
|
||||
//Act
|
||||
List<Token> returnedValue = Tokeniser.Tokenise(testString);
|
||||
//Assert
|
||||
Assert.IsTrue(expectedValue.SequenceEqual(returnedValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the tokeniser on a string which contains a number which is not formatted correctly
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestTokeniseStringWithInvalidNumbr()
|
||||
{
|
||||
//Arrange
|
||||
string testString = "1+11.2.5";
|
||||
//Act and Assert
|
||||
Assert.ThrowsException<Exception>(() => Tokeniser.Tokenise(testString));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user