mirror of
https://github.com/0xJ1M/MathsEngine.git
synced 2026-06-05 02:00:06 +00:00
44 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|
|
} |