Major refactor

This commit is contained in:
Jim
2025-07-10 20:02:32 +01:00
committed by 0xJ1M
parent fb81730adb
commit c527e59b57
37 changed files with 1252 additions and 1493 deletions

View 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);
}
}
}