From 3217fd1479b5c196b4a27c5905d0ede6b825e0da Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 14 Jun 2019 17:20:33 +0200 Subject: [PATCH] Fix for release builds deleting lexer test script strings before being finished with it --- tests/parser/LexerTests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/parser/LexerTests.cpp b/tests/parser/LexerTests.cpp index 763be63..1591b7c 100644 --- a/tests/parser/LexerTests.cpp +++ b/tests/parser/LexerTests.cpp @@ -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() == '+');