diff --git a/utest/quoted.test.cpp b/utest/quoted.test.cpp index d26cc1d1..12120e87 100644 --- a/utest/quoted.test.cpp +++ b/utest/quoted.test.cpp @@ -1,5 +1,6 @@ /* @file fixed.test.cpp */ +#include "xo/indentlog/scope.hpp" #include "xo/indentlog/print/quoted.hpp" //#include "xo/indentlog/print/tag.hpp" #include "xo/indentlog/print/hex.hpp" @@ -26,6 +27,85 @@ namespace ut { std::string s_; }; /*quoted_tcase*/ + TEST_CASE("sstream.1char", "[quoted]") { + constexpr bool c_debug_flag = true; + + scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.sstream")); + + /* testing unexpected sstream behavior */ + { + std::stringstream ss; + + log && log("empty stream"); + + ss << '\\'; + + log && log("after: lone escaped backslash"); + log && log(hex_view(ss.view().begin(), ss.view().end(), true)); + + ss << 'n'; + + log && log("after: lone 'n' char"); + log && log(hex_view(ss.view().begin(), ss.view().end(), true)); + + log && log("ss.str()=[", ss.str(), "]"); + log && log("quoted(\"\\n\")=[", quoted("\\n"), "]"); + } + + /* testing unexpected sstream behavior */ + { + std::stringstream ss; + + log && log("empty stream"); + + ss << "\\n"; + + log && log("after: '\\n' escaped backslash + n"); + log && log(hex_view(ss.view().begin(), ss.view().end(), true)); + } + + /* testing unexpected sstream behavior */ + { + std::stringstream ss; + + log && log("empty stream"); + + ss << quoted("\n"); + + log && log("after: quoted('\\n')"); + log && log(hex_view(ss.view().begin(), ss.view().end(), true)); + } + + /* testing unexpected sstream behavior */ + { + std::stringstream ss; + + log && log("empty stream"); + + ss << quoted("foo\n"); + + log && log("after: quoted(\"foo\n\")"); + log && log(hex_view(ss.view().begin(), ss.view().end(), true)); + log && log("> ss.str ----------------"); + log && log(ss.str()); + log && log("< ss.str ----------------"); + } + + /* testing unexpected sstream behavior */ + { + std::stringstream ss; + + log && log("empty stream"); + + ss << unq("\n"); + + log && log("after: unq('\\n')"); + log && log(hex_view(ss.view().begin(), ss.view().end(), true)); + } + + } /*TEST_CASE(sstream)*/ + + std::vector s_quoted_tcase_v( { quoted_tcase("", true, "\"\""),