Skip to content

Commit

Permalink
wip linux
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Parpart <[email protected]>
  • Loading branch information
christianparpart committed Apr 21, 2024
1 parent 551eac8 commit 3f9ba36
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/libunicode/grapheme_line_segmenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ class grapheme_line_segmenter<OptionalEventListener>
// If not, we need to stop processing and return the current line.
// If the input is exhausted, we need to return the current line.
assert(processedTotalWidth < maxWidth);
auto const* start = next();
[[maybe_unused]] auto const* start = next();
auto const chunk = detail::process_only_complex_unicode(
_eventHandler, _complexUnicodeState, _complexUnicodeState.utf8DecodeNext, end(), maxWidth);
assert(_complexUnicodeState.utf8DecodeNext <= chunk.end);
Expand Down
32 changes: 23 additions & 9 deletions src/libunicode/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,42 @@
namespace
{

struct SetupTeardown
struct setup_teardown
{
SetupTeardown()
#if defined(_WIN32)
const DWORD stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
const DWORD savedOutputCP = GetConsoleOutputCP();
const DWORD savedOutputMode = []() -> DWORD {
DWORD mode;
GetConsoleMode(stdoutHandle, &mode);
return mode;
}();
#endif

setup_teardown()
{
#if defined(_WIN32)
const auto stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
const auto stdoutCP = GetConsoleOutputCP();
DWORD stdoutMode;
GetConsoleMode(stdoutHandle, &stdoutMode);
SetConsoleMode(stdoutHandle, ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
SetConsoleMode(stdoutHandle,
savedOutputMode | ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT
| ENABLE_VIRTUAL_TERMINAL_PROCESSING);
SetConsoleOutputCP(CP_UTF8);
#endif
}

~SetupTeardown() = default;
~setup_teardown()
{
#if defined(_WIN32)
SetConsoleMode(stdoutHandle, savedOutputMode);
SetConsoleOutputCP(savedOutputCP);
#endif
}
};

} // namespace

int main(int argc, char* argv[])
{
auto const _ = SetupTeardown {};
[[maybe_unused]] auto const _ = setup_teardown {};

int result = Catch::Session().run(argc, argv);

Expand Down

0 comments on commit 3f9ba36

Please sign in to comment.