Fix for release builds deleting lexer test script strings before being finished with it
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-06-14 17:20:33 +02:00
parent a9def6c539
commit 3217fd1479
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 4 additions and 4 deletions

View File

@ -8,16 +8,16 @@ TEST_CASE( "When at end of script return terminator", "[lexer]" ) {
}
TEST_CASE( "Peek doesn't advance", "[lexer]" ) {
auto script = "5 + 5";
Lexer lexer = Lexer(script, nullptr);
auto script = new string("5 + 5"); // Create as reference to ensure the compiler plays nice with it in release builds
Lexer lexer = Lexer(*script, nullptr);
REQUIRE(lexer.Peek() == '5');
REQUIRE(lexer.Peek() == '5');
REQUIRE(lexer.Peek() == '5');
}
TEST_CASE( "Next does advance", "[lexer]" ) {
auto script = "5 + 5";
Lexer lexer = Lexer(script, nullptr);
auto script = new string("5 + 5"); // Create as reference to ensure the compiler plays nice with it in release builds
Lexer lexer = Lexer(*script, nullptr);
REQUIRE(lexer.Next() == '5');
REQUIRE(lexer.Next() == ' ');
REQUIRE(lexer.Next() == '+');