This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Change the generic_string_alloc test to do a conversion that also does something on windows
ClosedPublic

Authored by mstorsjo on May 12 2021, 1:07 PM.

Details

Summary

On windows, the native path char type is wchar_t - therefore, this test
didn't actually do the conversion that the test was supposed to exercise.
Instead use a type that ends up converted on all current platforms
(char32_t), and use the typedef CharT instead of hardcoding wchar_t in
multiple places.

The charset conversions on windows do cause extra allocations outside of
the provided allocator though, so that bit of the test has to be waived
now that the test actually does something. (Other tests have similar
TEST_NOT_WIN32() for allocation checks for charset conversions.)

Diff Detail

Event Timeline

mstorsjo requested review of this revision.May 12 2021, 1:07 PM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2021, 1:07 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Quuxplusone added a subscriber: Quuxplusone.

Seems reasonable to me. (The existing code's MultiStringType is insane — took me a while to figure out why casting it to (const char*) on line 47 wasn't a bug — but that's not your problem.)

curdeius accepted this revision.May 13 2021, 10:35 AM
curdeius added a subscriber: curdeius.

LGTM. What do you think, would there be any value in testing different char types?

This revision is now accepted and ready to land.May 13 2021, 10:35 AM
mstorsjo updated this revision to Diff 345248.May 13 2021, 12:09 PM

Test all char types in generic_string_alloc, fix a typo, and add testing of char8_t in path.native.obs/string_alloc too.

LGTM. What do you think, would there be any value in testing different char types?

Hmm, I guess it would be good to test all cases, just for completeness - amended the patch.

curdeius accepted this revision.May 14 2021, 12:15 AM