Skip to content

Commit aebb72c

Browse files
committed
TestThreadExecutor: added some showtime tests
1 parent 3d261a1 commit aebb72c

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

test/testthreadexecutor.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class TestThreadExecutor : public TestFixture {
105105
TEST_CASE(one_error_less_files);
106106
TEST_CASE(one_error_several_files);
107107
TEST_CASE(markup);
108+
TEST_CASE(showtime_top5);
109+
TEST_CASE(showtime_file);
108110
}
109111

110112
void deadlock_with_many_errors() {
@@ -235,6 +237,38 @@ class TestThreadExecutor : public TestFixture {
235237
output.str());*/
236238
settings = settingsOld;
237239
}
240+
241+
// TODO: provide data which actually shows values above 0
242+
243+
template<typename T>
244+
std::size_t find_all_of(const std::string& str, T sub) {
245+
std::size_t n = 0;
246+
std::string::size_type pos = 0;
247+
while ((pos = str.find(sub, pos)) != std::string::npos) {
248+
++pos;
249+
++n;
250+
}
251+
return n;
252+
}
253+
254+
void showtime_top5() {
255+
REDIRECT;
256+
check(1, 2, 0,
257+
"int main() {}",
258+
true, SHOWTIME_MODES::SHOWTIME_TOP5);
259+
// for each file: top5 results + overall + empty line
260+
const std::string output_s = GET_REDIRECT_OUTPUT;
261+
ASSERT_EQUALS((5 + 1 + 1) * 2, find_all_of(output_s, '\n'));
262+
}
263+
264+
void showtime_file() {
265+
REDIRECT;
266+
check(1, 2, 0,
267+
"int main() {}",
268+
true, SHOWTIME_MODES::SHOWTIME_FILE);
269+
const std::string output_s = GET_REDIRECT_OUTPUT;
270+
ASSERT_EQUALS(2, find_all_of(output_s, "Overall time:"));
271+
}
238272
};
239273

240274
REGISTER_TEST(TestThreadExecutor)

0 commit comments

Comments
 (0)