00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "absl/base/internal/raw_logging.h"
00020
00021 #include <tuple>
00022
00023 #include "gtest/gtest.h"
00024 #include "absl/strings/str_cat.h"
00025
00026 namespace {
00027
00028 TEST(RawLoggingCompilationTest, Log) {
00029 ABSL_RAW_LOG(INFO, "RAW INFO: %d", 1);
00030 ABSL_RAW_LOG(INFO, "RAW INFO: %d %d", 1, 2);
00031 ABSL_RAW_LOG(INFO, "RAW INFO: %d %d %d", 1, 2, 3);
00032 ABSL_RAW_LOG(INFO, "RAW INFO: %d %d %d %d", 1, 2, 3, 4);
00033 ABSL_RAW_LOG(INFO, "RAW INFO: %d %d %d %d %d", 1, 2, 3, 4, 5);
00034 ABSL_RAW_LOG(WARNING, "RAW WARNING: %d", 1);
00035 ABSL_RAW_LOG(ERROR, "RAW ERROR: %d", 1);
00036 }
00037
00038 TEST(RawLoggingCompilationTest, PassingCheck) {
00039 ABSL_RAW_CHECK(true, "RAW CHECK");
00040 }
00041
00042
00043
00044
00045
00046 const char kExpectedDeathOutput[] = "";
00047
00048 TEST(RawLoggingDeathTest, FailingCheck) {
00049 EXPECT_DEATH_IF_SUPPORTED(ABSL_RAW_CHECK(1 == 0, "explanation"),
00050 kExpectedDeathOutput);
00051 }
00052
00053 TEST(RawLoggingDeathTest, LogFatal) {
00054 EXPECT_DEATH_IF_SUPPORTED(ABSL_RAW_LOG(FATAL, "my dog has fleas"),
00055 kExpectedDeathOutput);
00056 }
00057
00058 TEST(InternalLog, CompilationTest) {
00059 ABSL_INTERNAL_LOG(INFO, "Internal Log");
00060 std::string log_msg = "Internal Log";
00061 ABSL_INTERNAL_LOG(INFO, log_msg);
00062
00063 ABSL_INTERNAL_LOG(INFO, log_msg + " 2");
00064
00065 float d = 1.1f;
00066 ABSL_INTERNAL_LOG(INFO, absl::StrCat("Internal log ", 3, " + ", d));
00067 }
00068
00069 TEST(InternalLogDeathTest, FailingCheck) {
00070 EXPECT_DEATH_IF_SUPPORTED(ABSL_INTERNAL_CHECK(1 == 0, "explanation"),
00071 kExpectedDeathOutput);
00072 }
00073
00074 TEST(InternalLogDeathTest, LogFatal) {
00075 EXPECT_DEATH_IF_SUPPORTED(ABSL_INTERNAL_LOG(FATAL, "my dog has fleas"),
00076 kExpectedDeathOutput);
00077 }
00078
00079 }