xo-indentlog: + cond utest
This commit is contained in:
parent
310dabde67
commit
922d250f36
2 changed files with 48 additions and 1 deletions
47
utest/cond.test.cpp
Normal file
47
utest/cond.test.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* @file cond.test.cpp */
|
||||
|
||||
#include "xo/indentlog/print/cond.hpp"
|
||||
#include "xo/indentlog/print/tag.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
#include <sstream>
|
||||
|
||||
using namespace xo;
|
||||
|
||||
namespace ut {
|
||||
TEST_CASE("cond", "[cond]") {
|
||||
tag_config::tag_color = color_spec_type::none();
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cond(true, "yes", "no");
|
||||
REQUIRE(ss.str() == "yes");
|
||||
}
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cond(false, "yes", "no");
|
||||
REQUIRE(ss.str() == "no");
|
||||
}
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cond(true, 42, "none");
|
||||
REQUIRE(ss.str() == "42");
|
||||
}
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << cond(false, 42, "none");
|
||||
REQUIRE(ss.str() == "none");
|
||||
}
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
int * ptr = nullptr;
|
||||
ss << cond(ptr != nullptr, xtag("ptr", 123), xtag("ptr", "null"));
|
||||
REQUIRE(ss.str() == " :ptr null");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* end cond.test.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue