From 030734b6c96076290567e4381dfa26af5405d867 Mon Sep 17 00:00:00 2001 From: Vivek Kale <11766050+vlkale@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:37:14 -0700 Subject: [PATCH] test_parscan.cpp: fix occurrences variable --- tests/sampler/test_parscan.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/sampler/test_parscan.cpp b/tests/sampler/test_parscan.cpp index 8dffe97cb..9ac7cee7d 100644 --- a/tests/sampler/test_parscan.cpp +++ b/tests/sampler/test_parscan.cpp @@ -85,12 +85,14 @@ TEST(SamplerTest, ktoEnvVarDefault) { EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: sample 15 calling"))); int occurrences = 0; - while (std::string::size_type pos = 0; - (pos = s.find("calling child-begin function", pos)) != - std::string::npos) { + std::string::size_type pos = 0; + std::string samplerTestOutput(output.str()); + std::string target("calling child-begin function"); + while ((pos = samplerTestOutput.find(target, pos)) != std::string::npos) { ++occurrences; pos += target.length(); } + EXPECT_EQ(occurrences, 2); EXPECT_THAT(output.str(), Not(HasSubstr("KokkosP: FATAL: No child library of "