Skip to content

Commit 08a0528

Browse files
committed
next test
1 parent b311a58 commit 08a0528

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/test_stream_io.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,34 @@ void test_wide_io()
177177

178178
void test_main(int /*argc*/, char** /*argv*/)
179179
{
180+
{
181+
const auto& c = *new std::codecvt_byname<wchar_t, char, std::mbstate_t>("en_US.UTF-8");
182+
for(int repeats = 1; repeats <= 1000; repeats++) {
183+
std::string one = "\xf0\xa0\x82\x8a"; // U+2008A
184+
std::string res;
185+
res.reserve(one.size() * repeats);
186+
for(int i = 0; i < repeats; i++)
187+
res += one;
188+
std::locale l("en_US.UTF-8");
189+
//&c = std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(l);
190+
wchar_t buf[2048];
191+
const char* nextIn;
192+
wchar_t* nextOut;
193+
std::mbstate_t st;
194+
c.in(st, res.data(), res.data() + res.size(), nextIn, buf, std::end(buf), nextOut);
195+
std::cout << "================= " << repeats << "================\n";
196+
std::cout << "Converted " << (nextIn - res.data()) << "/" << res.size() << " bytes to " << (nextOut - buf)
197+
<< " wide characters\n";
198+
for(int i = 0; i < nextOut - buf; i += 2) {
199+
if(buf[i] != 0xD840 || buf[i + 1] != 0xDC8A) {
200+
std::cout << "Mismatch at position " << i << ": " << std::hex << unsigned(buf[i]) << " "
201+
<< unsigned(buf[i + 1]) << "\n";
202+
break;
203+
}
204+
}
205+
}
206+
}
207+
return;
180208
for(const std::string& backendName : boost::locale::localization_backend_manager::global().get_all_backends()) {
181209
boost::locale::localization_backend_manager tmp_backend = boost::locale::localization_backend_manager::global();
182210
tmp_backend.select(backendName);

0 commit comments

Comments
 (0)