Files
MathsEngine/MathEngine/EngineTests/Tokenizer Tests/TokenTests.cs
2025-10-14 17:59:24 +01:00

44 lines
1.1 KiB
C#

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