diff options
author | rebecca “wiggles” turner <rbt@sent.as> | 2024-03-29 16:20:14 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@lix> | 2024-03-29 16:20:14 +0000 |
commit | 877750b7c586ec612faba56ed0194ae265994156 (patch) | |
tree | 9cd3d0e5ed77060559b1e7b91b2aa38e6b677be1 /tests | |
parent | 6e5db5e4a226dc920a8959e8201d75f54c37dde2 (diff) | |
parent | 5ec2efb68677ccb5fd91c295cf6ae6039652ac73 (diff) |
Merge "Move `DebugChar` into its own file" into main
Diffstat (limited to 'tests')
4 files changed, 8 insertions, 32 deletions
diff --git a/tests/functional/repl_characterization/test-session.cc b/tests/functional/repl_characterization/test-session.cc index c35030fc7..50e27e58c 100644 --- a/tests/functional/repl_characterization/test-session.cc +++ b/tests/functional/repl_characterization/test-session.cc @@ -3,7 +3,7 @@ #include "test-session.hh" #include "util.hh" -#include "tests/debug-char.hh" +#include "escape-char.hh" namespace nix { @@ -60,7 +60,7 @@ std::ostream & operator<<(std::ostream & os, ReplOutputParser::State s) void ReplOutputParser::transition(State new_state, char responsible_char, bool wasPrompt) { if constexpr (DEBUG_REPL_PARSER) { - std::cerr << "transition " << new_state << " for " << DebugChar{responsible_char} + std::cerr << "transition " << new_state << " for " << MaybeHexEscapedChar{responsible_char} << (wasPrompt ? " [prompt]" : "") << "\n"; } state = new_state; @@ -118,7 +118,7 @@ bool TestSession::waitForPrompt() }); if constexpr (DEBUG_REPL_PARSER) { - std::cerr << "raw " << DebugChar{buf[i]} << (wasEaten ? " [eaten]" : "") << "\n"; + std::cerr << "raw " << MaybeHexEscapedChar{buf[i]} << (wasEaten ? " [eaten]" : "") << "\n"; } } diff --git a/tests/unit/libutil-support/tests/cli-literate-parser.cc b/tests/unit/libutil-support/tests/cli-literate-parser.cc index b3830e32c..08ebddebc 100644 --- a/tests/unit/libutil-support/tests/cli-literate-parser.cc +++ b/tests/unit/libutil-support/tests/cli-literate-parser.cc @@ -1,6 +1,6 @@ #include "cli-literate-parser.hh" #include "libexpr/print.hh" -#include "debug-char.hh" +#include "escape-char.hh" #include "types.hh" #include "util.hh" #include <ranges> @@ -77,7 +77,7 @@ CLILiterateParser::CLILiterateParser(std::string prompt, size_t indent) void CLILiterateParser::feed(char c) { if constexpr (DEBUG_PARSER) { - std::cout << stateDebug(state_) << " " << DebugChar{c} << "\n"; + std::cout << stateDebug(state_) << " " << MaybeHexEscapedChar{c} << "\n"; } if (c == '\n') { diff --git a/tests/unit/libutil-support/tests/debug-char.hh b/tests/unit/libutil-support/tests/debug-char.hh deleted file mode 100644 index 765d8553f..000000000 --- a/tests/unit/libutil-support/tests/debug-char.hh +++ /dev/null @@ -1,24 +0,0 @@ -///@file -#include <ostream> -#include <boost/io/ios_state.hpp> - -namespace nix { - -struct DebugChar -{ - char c; -}; - -inline std::ostream & operator<<(std::ostream & s, DebugChar c) -{ - boost::io::ios_flags_saver _ifs(s); - - if (isprint(c.c)) { - s << static_cast<char>(c.c); - } else { - s << std::hex << "0x" << (static_cast<unsigned int>(c.c) & 0xff); - } - return s; -} - -} diff --git a/tests/unit/libutil-support/tests/terminal-code-eater.cc b/tests/unit/libutil-support/tests/terminal-code-eater.cc index 51e1d565e..ad05ed1f6 100644 --- a/tests/unit/libutil-support/tests/terminal-code-eater.cc +++ b/tests/unit/libutil-support/tests/terminal-code-eater.cc @@ -1,5 +1,5 @@ #include "terminal-code-eater.hh" -#include "debug-char.hh" +#include "escape-char.hh" #include <assert.h> #include <cstdint> #include <iostream> @@ -14,7 +14,7 @@ void TerminalCodeEater::feed(char c, std::function<void(char)> on_char) auto isIntermediateChar = [](char v) -> bool { return v >= 0x20 && v <= 0x2f; }; auto isFinalChar = [](char v) -> bool { return v >= 0x40 && v <= 0x7e; }; if constexpr (DEBUG_EATER) { - std::cerr << "eater" << DebugChar{c} << "\n"; + std::cerr << "eater" << MaybeHexEscapedChar{c} << "\n"; } switch (state) { @@ -28,7 +28,7 @@ void TerminalCodeEater::feed(char c, std::function<void(char)> on_char) return; } if constexpr (DEBUG_EATER) { - std::cerr << "eater uneat" << DebugChar{c} << "\n"; + std::cerr << "eater uneat" << MaybeHexEscapedChar{c} << "\n"; } on_char(c); break; |