removed lots of asserts
Some of them relied on the side effects of evaluating their argument but
for most of them it just makes more sense to use CHECK.
diff --git a/aos/common/logging/logging_impl_test.cc b/aos/common/logging/logging_impl_test.cc
index 34bcdd1..8331c37 100644
--- a/aos/common/logging/logging_impl_test.cc
+++ b/aos/common/logging/logging_impl_test.cc
@@ -1,10 +1,11 @@
#include <string>
+#include <inttypes.h>
+
#include "gtest/gtest.h"
#include "aos/common/logging/logging_impl.h"
#include "aos/common/time.h"
-#include <inttypes.h>
using ::testing::AssertionResult;
using ::testing::AssertionSuccess;
@@ -19,6 +20,11 @@
virtual void DoLog(log_level level, const char *format, va_list ap) {
internal::FillInMessage(level, format, ap, &message_);
+ if (level == FATAL) {
+ internal::PrintMessage(stderr, message_);
+ abort();
+ }
+
used_ = true;
}
@@ -82,8 +88,6 @@
first = false;
Init();
- // We'll end up with several of them stacked up, but it really doesn't
- // matter.
AddImplementation(log_implementation = new TestLogImplementation());
}
@@ -133,13 +137,20 @@
EXPECT_TRUE(WasLogged(WARNING, expected.str()));
}
-#ifndef __VXWORKS__
TEST_F(LoggingDeathTest, Fatal) {
ASSERT_EXIT(LOG(FATAL, "this should crash it\n"),
::testing::KilledBySignal(SIGABRT),
"this should crash it");
}
-#endif
+
+TEST_F(LoggingDeathTest, PCHECK) {
+ EXPECT_DEATH(PCHECK(fprintf(stdin, "nope")),
+ ".*fprintf\\(stdin, \"nope\"\\).*failed.*");
+}
+
+TEST_F(LoggingTest, PCHECK) {
+ EXPECT_EQ(7, PCHECK(printf("abc123\n")));
+}
TEST_F(LoggingTest, PrintfDirectives) {
LOG(INFO, "test log %%1 %%d\n");