Canon/Canon.Tests/LexicalParserTests/DelimiterTests.cs
jackfiled 4b6635796c refeat: ILexer接口适配 (#38)
Co-authored-by: Huaps <1183155719@qq.com>
Co-authored-by: duqoo <92306417+duqoo@users.noreply.github.com>
Reviewed-on: PostGuard/Canon#38
2024-04-18 16:34:32 +08:00

31 lines
1.1 KiB
C#

using Canon.Core.Enums;
using Canon.Core.LexicalParser;
using Canon.Tests.Utils;
using Canon.Core.Abstractions;
namespace Canon.Tests.LexicalParserTests;
public class DelimiterTests
{
private readonly ILexer _lexer = new Lexer();
[Theory]
[InlineData(",123", DelimiterType.Comma)]
// [InlineData(".123", DelimiterType.Period)]
[InlineData(":123", DelimiterType.Colon)]
[InlineData(";123", DelimiterType.Semicolon)]
[InlineData("(123)", DelimiterType.LeftParenthesis)]
[InlineData(").", DelimiterType.RightParenthesis)]
[InlineData("[asd", DelimiterType.LeftSquareBracket)]
[InlineData("]asd", DelimiterType.RightSquareBracket)]
public void SmokeTest(string input, DelimiterType type)
{
IEnumerable<SemanticToken> tokensEnumerable = _lexer.Tokenize(new StringSourceReader(input));
List<SemanticToken> tokens = tokensEnumerable.ToList();
SemanticToken token = tokens[0];
Assert.Equal(SemanticTokenType.Delimiter, token.TokenType);
DelimiterSemanticToken delimiterSemanticToken = (DelimiterSemanticToken)token;
Assert.Equal(type, delimiterSemanticToken.DelimiterType);
}
}