cpp-ipc/test/imp/test_imp_log.cpp
木头云 b35de5a154 fix(test): Update test.h include paths after master rebase
After rebasing onto master, test.h was moved to test/archive/.
Updated include paths in test subdirectories:
- test/imp/*.cpp: "test.h" -> "../archive/test.h"
- test/mem/*.cpp: "test.h" -> "../archive/test.h"
- test/concur/*.cpp: "test.h" -> "../archive/test.h"

This ensures all test files can properly find the test header
after the directory reorganization in master branch.
2025-12-03 08:28:37 +00:00

47 lines
825 B
C++

#include <iostream>
#include <string>
#include "../archive/test.h"
#include "libipc/imp/log.h"
TEST(log, logger) {
{
LIBIPC_LOG();
log.info("hello");
}
{
LIBIPC_LOG();
log.info("hello 2");
}
{
LIBIPC_LOG();
log.info("hello ", 3);
}
SUCCEED();
}
TEST(log, custom) {
struct log {
std::string i;
std::string e;
} ll_data;
auto ll = [&ll_data](auto &&ctx) {
auto s = ipc::fmt(ctx.params);
if (ctx.level == ipc::log::level::error) ll_data.e += s + " ";
else
if (ctx.level == ipc::log::level::info ) ll_data.i += s + " ";
};
LIBIPC_LOG(ll);
log.info ("hello", " world");
log.error("failed", ":");
log.info ("log", '-', "pt");
log.error("whatever");
EXPECT_EQ(ll_data.i, "hello world log-pt ");
EXPECT_EQ(ll_data.e, "failed: whatever ");
}