From: Shane Synan Date: Thu, 30 May 2019 20:19:18 +0000 (-0400) Subject: tests: Verify ExpressionMatch test data won't OOB X-Git-Tag: test-travis-01~55 X-Git-Url: https://git.quassel-irc.org/?a=commitdiff_plain;h=dd1d9d68c406b993230161208cbd17db55dc85a9;p=quassel.git 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. --- 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