From 8a53e3c6c097a6871845de5b884265894dcfee61 Mon Sep 17 00:00:00 2001 From: dhthwy <302825+dhthwy@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:32:51 -0500 Subject: [PATCH] try to fix tests --- library/SDLConsole.test.cpp | 49 ++++++++++++++++++++++++------- library/include/SDLConsole_impl.h | 2 +- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/library/SDLConsole.test.cpp b/library/SDLConsole.test.cpp index 4552723864..92ace8bae5 100644 --- a/library/SDLConsole.test.cpp +++ b/library/SDLConsole.test.cpp @@ -133,41 +133,68 @@ TEST(SDLConsole, find_next_word) { TEST(SDLConsole, find_wspace_range) { std::u32string tstr; std::pair ret; + std::pair exp; tstr = U" "; ret = text::find_wspace_range(tstr, 1); - ASSERT_EQ(ret, std::make_pair(0, 2)); + exp.first = 0; + exp.second = 2; + ASSERT_EQ(ret.first, exp.first); + ASSERT_EQ(ret.second, exp.second); - tstr = U"foo bar"; + tstr = U"foo bar"; ret = text::find_wspace_range(tstr, 3); - ASSERT_EQ(ret, std::make_pair(3, 5)); + exp.first = 3; + exp.second = 5; + ASSERT_EQ(ret.first, exp.first); + ASSERT_EQ(ret.second, exp.second); tstr = U"foobar "; ret = text::find_wspace_range(tstr, 6); - ASSERT_EQ(ret, std::make_pair(6, 7)); + exp.first = 6; + exp.second = 7; + ASSERT_EQ(ret.first, exp.first); + ASSERT_EQ(ret.second, exp.second); tstr = U"foobar "; ret = text::find_wspace_range(tstr, 6); - ASSERT_EQ(ret, std::make_pair(6, 6)); - + exp.first = 6; + exp.second = 6; + ASSERT_EQ(ret.first, exp.first); + ASSERT_EQ(ret.second, exp.second); + tstr = U""; ret = text::find_wspace_range(tstr, 0); - ASSERT_EQ(ret, std::make_pair(0, 0)); + exp.first = 0; + exp.second = 0; + ASSERT_EQ(ret.first, exp.first); + ASSERT_EQ(ret.second, exp.second); + } TEST(SDLConsole, find_text_range) { std::u32string tstr; std::pair ret; + std::pair exp; - tstr = U"foo"; + tstr = U"foo"; ret = text::find_text_range(tstr, 0); - ASSERT_EQ(ret, std::make_pair(0, 2)); + exp.first = 0; + exp.second = 2; + ASSERT_EQ(ret.first, exp.first); + ASSERT_EQ(ret.second, exp.second); tstr = U"foo bar"; ret = text::find_text_range(tstr, 5); - ASSERT_EQ(ret, std::make_pair(4, 6)); + exp.first = 4; + exp.second = 6; + ASSERT_EQ(ret.first, exp.first); + ASSERT_EQ(ret.second, exp.second); tstr = U"foo bar "; ret = text::find_text_range(tstr, 5); - ASSERT_EQ(ret, std::make_pair(4, 6)); + exp.first = 4; + exp.second = 6; + ASSERT_EQ(ret.first, exp.first); + ASSERT_EQ(ret.second, exp.second); } diff --git a/library/include/SDLConsole_impl.h b/library/include/SDLConsole_impl.h index 84ea718ce8..8f36300509 100644 --- a/library/include/SDLConsole_impl.h +++ b/library/include/SDLConsole_impl.h @@ -5,7 +5,7 @@ #include namespace sdl_console { -namespace text { +namespace text { size_t skip_wspace(const std::u32string& text, size_t pos); size_t skip_wspace_reverse(const std::u32string& text, size_t pos);