This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Fix testcases that fail on systems with 16 bit wchar_t
ClosedPublic

Authored by mstorsjo on Jan 25 2022, 2:04 PM.

Details

Summary

Don't decode a UTF-8 character that is out of range for a 16 bit
wchar_t.

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Jan 25 2022, 2:04 PM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2022, 2:04 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

IMHO it might be better to add your new test, but keep the existing test under an if (sizeof(wchar_t) >= 4) or if (WCHAR_MAX > 100003-or-whatever), something like that. It feels important to test that on platforms with 32-bit wchar_t, we can actually use all 32 bits and aren't silently truncating to 16 bits somewhere internally.
(That said, what the heck, why is this test discarding the value of .from_bytes instead of asserting on it.)
It's possible both of my comments are sufficiently addressed by test coverage elsewhere in the test suite, in which case, looks great, ship it!

IMHO it might be better to add your new test, but keep the existing test under an if (sizeof(wchar_t) >= 4) or if (WCHAR_MAX > 100003-or-whatever), something like that. It feels important to test that on platforms with 32-bit wchar_t, we can actually use all 32 bits and aren't silently truncating to 16 bits somewhere internally.
(That said, what the heck, why is this test discarding the value of .from_bytes instead of asserting on it.)

I presume the main intent of this test is to test some other aspect (move constructor), not test the conversion itself, and therefore it doesn't really functionally test the conversion.

It's possible both of my comments are sufficiently addressed by test coverage elsewhere in the test suite, in which case, looks great, ship it!

Not sure offhand, but this as this test only is for the move constructor, I would guess so.

ldionne accepted this revision.Jan 27 2022, 2:04 PM

I think the test that Arthur is talking about is handled in libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp. Therefore, this LGTM.

This revision is now accepted and ready to land.Jan 27 2022, 2:04 PM