mirror of
https://github.com/0xJ1M/MathsEngine.git
synced 2026-06-05 03:10:08 +00:00
Major refactor
This commit is contained in:
44
MathEngine/EngineTests/Tokenizer Tests/TokenTests.cs
Normal file
44
MathEngine/EngineTests/Tokenizer Tests/TokenTests.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Xunit;
|
||||
|
||||
using MathEngine.Tokenizer;
|
||||
|
||||
using static MathEngine.Tokenizer.Token;
|
||||
|
||||
namespace EngineTests.Tokeniser
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing the Token
|
||||
/// </summary>
|
||||
public class TokenTests
|
||||
{
|
||||
public static IEnumerable<object[]> TestConstructorCases
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<object[]> {
|
||||
new object[] { "123", Token.TokenType.Numeric, (uint)0 },
|
||||
new object[] { "+", Token.TokenType.Operator, (uint)0 },
|
||||
new object[] { "Sin", Token.TokenType.Function, (uint)1 }
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Test that Token constructor returns valid token
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[MemberData(nameof(TestConstructorCases))]
|
||||
public void TestTokenConstructorReturnsToken(string value, int type, uint arity = 0)
|
||||
{
|
||||
TokenType t_type = (TokenType)(type);
|
||||
Token token = new(value, t_type, arity);
|
||||
Assert.Equal(token.Value, value);
|
||||
Assert.Equal(token.Type, t_type);
|
||||
Assert.Equal(token.Arity, arity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user