Expanded on diagnostics, make whitespace completely ignored
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#ifdef TESTS_BUILD
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch.hpp>
|
||||
#include "Lexer.hpp"
|
||||
|
||||
@@ -259,28 +258,22 @@ TEST_CASE( "Lex identifier", "[lexer]" ) {
|
||||
TEST_CASE( "Lex Start Position", "[lexer]" ) {
|
||||
Lexer lexer = Lexer("+ - bar 1234", nullptr);
|
||||
auto tokens = lexer.Lex();
|
||||
REQUIRE(tokens.size() == 8);
|
||||
REQUIRE(tokens.size() == 5);
|
||||
CHECK(((IdentifierToken*)tokens[0]) -> GetStartPosition() == 0);
|
||||
CHECK(((IdentifierToken*)tokens[1]) -> GetStartPosition() == 1);
|
||||
CHECK(((IdentifierToken*)tokens[2]) -> GetStartPosition() == 2);
|
||||
CHECK(((IdentifierToken*)tokens[3]) -> GetStartPosition() == 3);
|
||||
CHECK(((IdentifierToken*)tokens[4]) -> GetStartPosition() == 4);
|
||||
CHECK(((IdentifierToken*)tokens[5]) -> GetStartPosition() == 7);
|
||||
CHECK(((IdentifierToken*)tokens[6]) -> GetStartPosition() == 8);
|
||||
CHECK(((IdentifierToken*)tokens[7]) -> GetStartPosition() == 12);
|
||||
CHECK(((IdentifierToken*)tokens[1]) -> GetStartPosition() == 2);
|
||||
CHECK(((IdentifierToken*)tokens[2]) -> GetStartPosition() == 4);
|
||||
CHECK(((IdentifierToken*)tokens[3]) -> GetStartPosition() == 8);
|
||||
CHECK(((IdentifierToken*)tokens[4]) -> GetStartPosition() == 12);
|
||||
}
|
||||
|
||||
TEST_CASE( "Lex End Position", "[lexer]" ) {
|
||||
Lexer lexer = Lexer("+ - bar 1234", nullptr);
|
||||
auto tokens = lexer.Lex();
|
||||
REQUIRE(tokens.size() == 8);
|
||||
REQUIRE(tokens.size() == 5);
|
||||
CHECK(((IdentifierToken*)tokens[0]) -> GetEndPosition() == 0);
|
||||
CHECK(((IdentifierToken*)tokens[1]) -> GetEndPosition() == 1);
|
||||
CHECK(((IdentifierToken*)tokens[2]) -> GetEndPosition() == 2);
|
||||
CHECK(((IdentifierToken*)tokens[3]) -> GetEndPosition() == 3);
|
||||
CHECK(((IdentifierToken*)tokens[4]) -> GetEndPosition() == 6);
|
||||
CHECK(((IdentifierToken*)tokens[5]) -> GetEndPosition() == 7);
|
||||
CHECK(((IdentifierToken*)tokens[6]) -> GetEndPosition() == 11);
|
||||
CHECK(((IdentifierToken*)tokens[7]) -> GetEndPosition() == 12);
|
||||
CHECK(((IdentifierToken*)tokens[1]) -> GetEndPosition() == 2);
|
||||
CHECK(((IdentifierToken*)tokens[2]) -> GetEndPosition() == 6);
|
||||
CHECK(((IdentifierToken*)tokens[3]) -> GetEndPosition() == 11);
|
||||
CHECK(((IdentifierToken*)tokens[4]) -> GetEndPosition() == 12);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user