This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Fix the get/put long_double_zh_CN tests on Windows
ClosedPublic

Authored by mstorsjo on Mar 3 2022, 3:57 AM.

Diff Detail

Event Timeline

mstorsjo created this revision.Mar 3 2022, 3:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2022, 3:57 AM
mstorsjo requested review of this revision.Mar 3 2022, 3:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2022, 3:57 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Quuxplusone requested changes to this revision.Mar 3 2022, 8:00 AM
Quuxplusone added inline comments.
libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
72–78

Naming nit: By the time I saw it again below, I'd forgotten that curr_text stood for currency_name and not current_string. I suggest spelling out currency_{symbol,name}, or even better, refactoring into a helper function as you suggest in your PR summary.

As in the previous PR, using a MultiStringType helper will eliminate the need for curr_x and w_curr_x to coexist.

libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
83

I suggest that this could be expressed as std::string(7 - curr_text.size(), ' ') and then inlined everywhere it's used. The name pad20 is awkward in that this string definitely isn't 20 bytes long. :)

This revision now requires changes to proceed.Mar 3 2022, 8:00 AM
mstorsjo updated this revision to Diff 412761.Mar 3 2022, 10:27 AM

Applied most of the suggestions; renamed variables for clarity, using a locale helper for the symbol, inlined the padding string expansion.

Still using separate variables for currency_symbol instead of inlineing the call to the multistring locale helper, because there's no operator for e.g. operator+(MultiString, const char*) that would reduce the multistring implicitly to the desired string type. Using ifdefs for the definition of the international name with/without trailing space.

Thanks for this improvement, please update the summary.
In general LGTM, but I would like to consider the duplication before approving.

libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
151

I'm not too fond of std::string(7 - currency_symbol.size(), ' ') duplicated a lot of times.
@Quuxplusone, @mstorsjo How about making one padding variable without 20 in the name and use that?
(I know Arthur asked this change, just want to confirm both of you like the way it looks now.)

mstorsjo edited the summary of this revision. (Show Details)Mar 3 2022, 1:48 PM
mstorsjo added inline comments.Mar 3 2022, 1:54 PM
libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
151

I'm totally ok with e.g. std::string currency_symbol_padding = std::string(7 - currency_symbol.size(), ' '); and using that instead - that would indeed make it less cluttered. (That's what I would prefer here actually, but I'm ok with whatever you guys prefer.)

mstorsjo updated this revision to Diff 412839.Mar 3 2022, 2:19 PM

Rebased on latest main, moved the padding back to a variable for brevity.

Quuxplusone accepted this revision.Mar 3 2022, 3:15 PM

LGTM

libcxx/test/support/locale_helpers.h
91–93

Not a blocker; maybe I just like Unicode character names too much. ;)

This revision is now accepted and ready to land.Mar 3 2022, 3:15 PM
mstorsjo added inline comments.Mar 4 2022, 12:17 AM
libcxx/test/support/locale_helpers.h
91–93

Sure, will amend that. (I actually considered adding such comments to begin with, but I didn't find a good reference for the character names with a couple minutes of browsing.)