xo-umbrella2/xo-indentlog/utest/toppstr.test.cpp
Roland Conybeare 966c3903e1 git subrepo clone git@github.com:Rconybea/xo-indentlog.git xo-indentlog
subrepo:
  subdir:   "xo-indentlog"
  merged:   "0834c6ad"
upstream:
  origin:   "git@github.com:Rconybea/xo-indentlog.git"
  branch:   "main"
  commit:   "0834c6ad"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
2026-06-06 21:30:17 -04:00

55 lines
1.8 KiB
C++

/* @file toppstr.cpp */
#include "xo/indentlog/print/ppstr.hpp"
#include "xo/indentlog/print/tag.hpp"
#include <catch2/catch.hpp>
#include <sstream>
namespace ut {
using xo::toppstr;
using xo::toppstr2;
using xo::print::ppconfig;
using xo::print::ppstate;
TEST_CASE("toppstr_1", "[toppstr]") {
std::string s = toppstr();
REQUIRE(s.empty());
}
TEST_CASE("toppstr_2", "[toppstr]") {
std::string s = toppstr("hello");
REQUIRE(s == "hello");
}
TEST_CASE("toppstr_3", "[toppstr]") {
std::string s = toppstr("the", " quick", " brown", " fox", " jumps", " over", " the", " lazy", " dog");
REQUIRE(s == "the quick brown fox jumps over the lazy dog");
}
TEST_CASE("toppstr2_0", "[toppstr2]") {
ppconfig ppc;
ppc.right_margin_ = 40;
ppc.indent_width_ = 0;
std::string s = toppstr2(ppc, "the", " quick", " brown", " fox", " jumps", " over", " the", " lazy", " dog");
REQUIRE(s == "the\n quick\n brown\n fox\n jumps\n over\n the\n lazy\n dog");
}
TEST_CASE("toppstr2_1", "[toppstr2]") {
ppconfig ppc;
ppc.right_margin_ = 40;
ppc.indent_width_ = 2;
std::string s = toppstr2(ppc, "the", " quick", " brown", " fox", " jumps", " over", " the", " lazy", " dog");
REQUIRE(s == "the\n quick\n brown\n fox\n jumps\n over\n the\n lazy\n dog");
}
TEST_CASE("toppstr2_2", "[toppstr2]") {
ppconfig ppc;
ppc.right_margin_ = 40;
ppc.indent_width_ = 4;
std::string s = toppstr2(ppc, "the", " quick", " brown", " fox", " jumps", " over", " the", " lazy", " dog");
REQUIRE(s == "the\n quick\n brown\n fox\n jumps\n over\n the\n lazy\n dog");
}
}