encfs/vendor/github.com/muflihun/easyloggingpp/test/custom-format-specifier-test.h
Valient Gough 5f0806c5cc Add "easylogging" from "https://github.com/muflihun/easyloggingpp@master"
git-vendor-name: easylogging
git-vendor-dir: vendor/github.com/muflihun/easyloggingpp
git-vendor-repository: https://github.com/muflihun/easyloggingpp
git-vendor-ref: master
2017-08-05 23:23:41 -07:00

34 lines
1.1 KiB
C++

#ifndef CUSTOM_FORMAT_SPECIFIER_TEST_H
#define CUSTOM_FORMAT_SPECIFIER_TEST_H
#include "test.h"
const char* getIp(const el::LogMessage*) {
return "127.0.0.1";
}
TEST(CustomFormatSpecifierTest, TestInstall) {
EXPECT_FALSE(el::Helpers::hasCustomFormatSpecifier("%ip"));
el::Helpers::installCustomFormatSpecifier(el::CustomFormatSpecifier("%ip", getIp));
EXPECT_TRUE(el::Helpers::hasCustomFormatSpecifier("%ip"));
}
TEST(CustomFormatSpecifierTest, TestResolution) {
Configurations c;
c.setGlobally(el::ConfigurationType::Format, "%datetime{%a %b %d, %H:%m} %ip: %msg");
el::Loggers::reconfigureLogger(consts::kDefaultLoggerId, c);
LOG(INFO) << "My ip test";
std::string s = BUILD_STR(getDate() << " 127.0.0.1: My ip test\n");
EXPECT_EQ(s, tail(1));
// Reset back
reconfigureLoggersForTest();
}
TEST(CustomFormatSpecifierTest, TestUnInstall) {
EXPECT_TRUE(el::Helpers::hasCustomFormatSpecifier("%ip"));
el::Helpers::uninstallCustomFormatSpecifier("%ip");
EXPECT_FALSE(el::Helpers::hasCustomFormatSpecifier("%ip"));
}
#endif // CUSTOM_FORMAT_SPECIFIER_TEST_H