Commit 70c95fa6 by Martin Radev Committed by Commit Bot

Add function in MatchOutputCodeTest to find occurrence of a string

The patch adds a function in MatchOutputCodeTest to get the position of the first occurrence of an expression in the translated output code. This can help design more complicated tests like a test which checks for the order of simple expressions. BUG=angleproject:2062 TEST=angle_unittests Change-Id: I1249d4762c247848c4eec64ecb8c1357b5e8d40a Reviewed-on: https://chromium-review.googlesource.com/563659Reviewed-by: 's avatarOlli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 88318b44
......@@ -140,14 +140,19 @@ bool MatchOutputCodeTest::compileWithSettings(ShShaderOutput output,
bool MatchOutputCodeTest::foundInCode(ShShaderOutput output, const char *stringToFind) const
{
return findInCode(output, stringToFind) != std::string::npos;
}
size_t MatchOutputCodeTest::findInCode(ShShaderOutput output, const char *stringToFind) const
{
const auto code = mOutputCode.find(output);
EXPECT_NE(mOutputCode.end(), code);
if (code == mOutputCode.end())
{
return false;
return std::string::npos;
}
return code->second.find(stringToFind) != std::string::npos;
return code->second.find(stringToFind);
}
bool MatchOutputCodeTest::foundInCode(ShShaderOutput output,
......
......@@ -64,6 +64,9 @@ class MatchOutputCodeTest : public testing::Test
}
bool foundInCode(ShShaderOutput output, const char *stringToFind) const;
// Returns the position of the first character of the first match in the translated output
// source. If no matches are found, then string::npos is returned.
size_t findInCode(ShShaderOutput output, const char *stringToFind) const;
// Test that the string occurs for exactly expectedOccurrences times
bool foundInCode(ShShaderOutput output,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment