Support std::u16string message formatting
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
**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"
```
Contributor guide
Research direction
Start by reproducing the supplied UnicodeComparisonFormatting example with Catch2 v2.6.1 and compare its current failure output with the requested output. Done means failed CHECK and REQUIRE assertions involving std::u16string display u"str1" and u"str2" rather than numeric character values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100