update error class unit test

This commit is contained in:
Axel Kohlmeyer 2021-05-05 18:18:05 -04:00
parent a23e034ced
commit 8fd0595f1b
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 15 additions and 15 deletions

View File

@ -39,7 +39,7 @@ TEST_F(Error_class, message)
auto output = CAPTURE_OUTPUT([&] { auto output = CAPTURE_OUTPUT([&] {
error->message(FLERR, "one message"); error->message(FLERR, "one message");
}); });
EXPECT_THAT(output, MatchesRegex("one message .*test_error_class.cpp:.*")); ASSERT_THAT(output, MatchesRegex("one message .*test_error_class.cpp:.*"));
}; };
TEST_F(Error_class, warning) TEST_F(Error_class, warning)
@ -48,8 +48,8 @@ TEST_F(Error_class, warning)
auto output = CAPTURE_OUTPUT([&] { auto output = CAPTURE_OUTPUT([&] {
error->warning(FLERR, "one warning"); error->warning(FLERR, "one warning");
}); });
EXPECT_THAT(output, MatchesRegex("WARNING: one warning .*test_error_class.cpp:.*")); ASSERT_THAT(output, MatchesRegex("WARNING: one warning .*test_error_class.cpp:.*"));
EXPECT_THAT(error->get_maxwarn(), 100); ASSERT_THAT(error->get_maxwarn(), 100);
// warnings disabled // warnings disabled
HIDE_OUTPUT([&] { HIDE_OUTPUT([&] {
@ -58,7 +58,7 @@ TEST_F(Error_class, warning)
output = CAPTURE_OUTPUT([&] { output = CAPTURE_OUTPUT([&] {
error->warning(FLERR, "one warning"); error->warning(FLERR, "one warning");
}); });
EXPECT_THAT(error->get_maxwarn(), -1); ASSERT_THAT(error->get_maxwarn(), -1);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("thermo_modify warn 2"); command("thermo_modify warn 2");
@ -66,48 +66,48 @@ TEST_F(Error_class, warning)
error->warning(FLERR, "one warning"); error->warning(FLERR, "one warning");
error->warning(FLERR, "one warning"); error->warning(FLERR, "one warning");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
EXPECT_THAT(error->get_maxwarn(), 2); ASSERT_THAT(error->get_maxwarn(), 2);
EXPECT_THAT(error->get_numwarn(), 4); ASSERT_THAT(error->get_numwarn(), 5);
output = CAPTURE_OUTPUT([&] { output = CAPTURE_OUTPUT([&] {
thermo->lost_check(); thermo->lost_check();
}); });
EXPECT_THAT(output, MatchesRegex("WARNING: Too many warnings: 4 vs 2. All future.*")); ASSERT_THAT(output, MatchesRegex("WARNING: Too many warnings: 5 vs 2. All future.*"));
output = CAPTURE_OUTPUT([&] { output = CAPTURE_OUTPUT([&] {
error->warning(FLERR, "one warning"); error->warning(FLERR, "one warning");
}); });
EXPECT_EQ(output, ""); ASSERT_EQ(output, "");
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("thermo_modify warn reset"); command("thermo_modify warn reset");
thermo->lost_check(); thermo->lost_check();
error->warning(FLERR, "one warning"); error->warning(FLERR, "one warning");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
EXPECT_THAT(error->get_maxwarn(), 2); ASSERT_THAT(error->get_maxwarn(), 2);
EXPECT_THAT(error->get_numwarn(), 1); ASSERT_THAT(error->get_numwarn(), 1);
output = CAPTURE_OUTPUT([&] { output = CAPTURE_OUTPUT([&] {
error->warning(FLERR, "one warning"); error->warning(FLERR, "one warning");
}); });
EXPECT_THAT(output, MatchesRegex("WARNING: one warning.*")); ASSERT_THAT(output, MatchesRegex("WARNING: one warning.*"));
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("thermo_modify warn default"); command("thermo_modify warn default");
thermo->lost_check(); thermo->lost_check();
error->warning(FLERR, "one warning"); error->warning(FLERR, "one warning");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
EXPECT_THAT(error->get_maxwarn(), 100); ASSERT_THAT(error->get_maxwarn(), 100);
EXPECT_THAT(error->get_numwarn(), 1); ASSERT_THAT(error->get_numwarn(), 1);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("thermo_modify warn always"); command("thermo_modify warn always");
thermo->lost_check(); thermo->lost_check();
error->warning(FLERR, "one warning"); error->warning(FLERR, "one warning");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
EXPECT_THAT(error->get_maxwarn(), 0); ASSERT_THAT(error->get_maxwarn(), 0);
EXPECT_THAT(error->get_numwarn(), 1); ASSERT_THAT(error->get_numwarn(), 2);
}; };
TEST_F(Error_class, one) TEST_F(Error_class, one)