From dd1d9d68c406b993230161208cbd17db55dc85a9 Mon Sep 17 00:00:00 2001 From: Shane Synan Date: Thu, 30 May 2019 16:19:18 -0400 Subject: [PATCH] tests: Verify ExpressionMatch test data won't OOB Verify that the ExpressionMatch test data for test trimMultiWildcardWhitespace won't try to access out of bounds data by changing EXPECT to ASSERT for patternPair.size() == 2. If the test data is wrong, the results will be undefined, so there's no point in continuing the test. Alternative: use std::vector's .at() function, which will raise a runtime error if out of bounds. --- tests/common/expressionmatchtest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/common/expressionmatchtest.cpp b/tests/common/expressionmatchtest.cpp index 8ba1bd77..a88f31da 100644 --- a/tests/common/expressionmatchtest.cpp +++ b/tests/common/expressionmatchtest.cpp @@ -425,7 +425,7 @@ TEST(ExpressionMatchTest, trimMultiWildcardWhitespace) QString result; for (auto&& patternPair : patterns) { // Make sure data is valid - EXPECT_TRUE(patternPair.size() == 2); + ASSERT_TRUE(patternPair.size() == 2); // Run transformation result = ExpressionMatch::trimMultiWildcardWhitespace(patternPair[PATTERN_SOURCE]); // Assert that source trims into expected pattern -- 2.20.1