Files
nearby/cpp/platform_v2/public/logging_test.cc
T
Alexey Polyudov 6b27a508ed nearby: snapshot of cl/317978613
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: I4bf367877a986910bb03e1c54aa972b4bcd59942
2020-06-23 19:52:26 -07:00

39 lines
881 B
C++

#include "platform_v2/public/logging.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace {
TEST(LoggingTest, CanLog) {
NEARBY_LOG_SET_SEVERITY(INFO);
int num = 42;
NEARBY_LOG(INFO, "The answer to everything: %d", num++);
EXPECT_EQ(num, 43);
}
TEST(LoggingTest, CanLog_LoggingDisabled) {
NEARBY_LOG_SET_SEVERITY(ERROR);
int num = 42;
NEARBY_LOG(INFO, "The answer to everything: %d", num++);
// num++ should not be evaluated
EXPECT_EQ(num, 42);
}
TEST(LoggingTest, CanStream) {
NEARBY_LOG_SET_SEVERITY(INFO);
int num = 42;
NEARBY_LOGS(INFO) << "The answer to everything: " << num++;
EXPECT_EQ(num, 43);
}
TEST(LoggingTest, CanStream_LoggingDisabled) {
NEARBY_LOG_SET_SEVERITY(ERROR);
int num = 42;
NEARBY_LOGS(INFO) << "The answer to everything: " << num++;
// num++ should not be evaluated
EXPECT_EQ(num, 42);
}
} // namespace