Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support std::u16string message formatting #1558

Open
grhoten opened this issue Mar 5, 2019 · 0 comments
Open

Support std::u16string message formatting #1558

grhoten opened this issue Mar 5, 2019 · 0 comments

Comments

@grhoten
Copy link
Contributor

grhoten commented Mar 5, 2019

Description
It would be nice if UTF-16 strings were converted to UTF-8 strings automatically for when reporting failures. If you're working with UTF-16 strings frequently, it would make it easier and faster if I didn't have to prefix these failures with INFO lines that convert std::u16string to std::string to actually see what these string values actually were.

Additional context
Here is a sample test case that uses catch.hpp version 2.6.1. It requires C++11 or later to work.

TEST_CASE("UnicodeComparisonFormatting")
{
    ::std::u16string str1(u"str1");
    ::std::u16string str2(u"str2");
    CHECK(str1 == str2);
    REQUIRE(str1 == str2);
}

Here is the current output. I changed the path to ... for brevity.

...UnicodeComparisonFormatting.cpp:13: FAILED:
  CHECK( str1 == str2 )
with expansion:
  { 115, 116, 114, 49 }
  ==
  { 115, 116, 114, 50 }

...UnicodeComparisonFormatting.cpp:14: FAILED:
  REQUIRE( str1 == str2 )
with expansion:
  { 115, 116, 114, 49 }
  ==
  { 115, 116, 114, 50 }

Here is the desired output with the exact same code

...UnicodeComparisonFormatting.cpp:13: FAILED:
  CHECK( str1 == str2 )
with expansion:
  u"str1" == u"str2"

...UnicodeComparisonFormatting.cpp:14: FAILED:
  REQUIRE( str1 == str2 )
with expansion:
  u"str1" == u"str2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant