mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Fix lexer calculing hex number length 1 too long
This commit is contained in:
parent
e40f1ec0b7
commit
e277de4517
@ -177,7 +177,7 @@ protected:
|
|||||||
if (numberLength == 0 || isalnum(*end) || *end == '_')
|
if (numberLength == 0 || isalnum(*end) || *end == '_')
|
||||||
throw ParsingException(GetPreviousCharacterPos(), "Invalid hex number");
|
throw ParsingException(GetPreviousCharacterPos(), "Invalid hex number");
|
||||||
|
|
||||||
m_current_line_offset += numberLength;
|
m_current_line_offset += numberLength - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_NODISCARD bool IsIntegerNumber() const
|
_NODISCARD bool IsIntegerNumber() const
|
||||||
|
@ -92,6 +92,25 @@ namespace test::parsing::header::impl::header_lexer
|
|||||||
REQUIRE(lexer.GetToken(0).m_type == HeaderParserValueType::END_OF_FILE);
|
REQUIRE(lexer.GetToken(0).m_type == HeaderParserValueType::END_OF_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("HeaderLexer: Ensure can parse simple hex numbers surrounded by symbols", "[parsing][header]")
|
||||||
|
{
|
||||||
|
const std::vector<std::string> lines
|
||||||
|
{
|
||||||
|
"0x25:0xABC,0x1a4",
|
||||||
|
};
|
||||||
|
|
||||||
|
MockParserLineStream mockStream(lines);
|
||||||
|
HeaderLexer lexer(&mockStream);
|
||||||
|
|
||||||
|
ExpectIntegerToken(lexer, 0x25);
|
||||||
|
ExpectCharacterToken(lexer, ':');
|
||||||
|
ExpectIntegerToken(lexer, 0xABC);
|
||||||
|
ExpectCharacterToken(lexer, ',');
|
||||||
|
ExpectIntegerToken(lexer, 0x1a4);
|
||||||
|
|
||||||
|
REQUIRE(lexer.GetToken(0).m_type == HeaderParserValueType::END_OF_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("HeaderLexer: Ensure throws exception when parsing incomplete hex number", "[parsing][header]")
|
TEST_CASE("HeaderLexer: Ensure throws exception when parsing incomplete hex number", "[parsing][header]")
|
||||||
{
|
{
|
||||||
const std::vector<std::string> lines
|
const std::vector<std::string> lines
|
||||||
|
Loading…
x
Reference in New Issue
Block a user