[libcxx-commits] [PATCH] D120317: [libcxx] [test] Fix get/put long_double_ru_RU on Glibc, FreeBSD and Windows

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 3 22:50:20 PST 2022


mstorsjo added a comment.

In D120317#3359172 <https://reviews.llvm.org/D120317#3359172>, @uabelho wrote:

> Hello,
>
> I see the following failures with this commit:
>
> Any idea?

Sorry about that. It would seem like there are differences in the `ru_RU.UTF-8` locale in your installation than in the ones used in CI and in my local environment. What glibc version are you running (as it would seem we require to selectively expect different results on different versions of glibc)?

Can you rerun the `put_long_double_ru_RU.pass.cpp` test with this diff applied?

  diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
  index ae5071907aca..a7156e78132e 100644
  --- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
  +++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
  @@ -77,6 +77,9 @@ int main(int, char**)
           char str[100];
           cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), false, ios, '*', v);
           std::string ex(str, base(iter));
  +        for (char c : ex)
  +            fprintf(stderr, "%02x ", c);
  +        fprintf(stderr, "\n");                 
           assert(ex == "0,00");
       }      
       {   // negative one

Alternatively, even better, can you provide the output of this test program:

  #include <locale.h>
  #include <stdio.h>
  
  int main(int argc, char **argv) {
      const char *locale = "ru_RU.UTF-8";
      if (argc > 1)
          locale = argv[1];
      if (!setlocale(LC_ALL, locale)) {
          printf("setlocale(%s) failed\n", locale);
          return 1;
      }
      struct lconv *lconv = localeconv();
      printf("mon_thousands_sep: \"%s\",", lconv->mon_thousands_sep);
      for (const char *c = lconv->mon_thousands_sep; *c; c++)
          printf(" %02x", (unsigned char)*c);
      printf("\n");
      printf("thousands_sep: \"%s\",", lconv->thousands_sep);
      for (const char *c = lconv->thousands_sep; *c; c++)
          printf(" %02x", (unsigned char)*c);
      printf("\n");
      printf("int_curr_symbol: \"%s\"\n", lconv->int_curr_symbol);
      printf("currency_symbol: \"%s\",", lconv->currency_symbol);
      for (const char *c = lconv->currency_symbol; *c; c++)
          printf(" %02x", (unsigned char)*c);
      printf("\n");
      printf("decimal_point: \"%s\",", lconv->decimal_point);
      for (const char *c = lconv->decimal_point; *c; c++)
          printf(" %02x", (unsigned char)*c);
      printf("\n");
      printf("mon_decimal_point: \"%s\",", lconv->mon_decimal_point);
      for (const char *c = lconv->mon_decimal_point; *c; c++)
          printf(" %02x", (unsigned char)*c);
      printf("\n");
      printf("negative_sign: \"%s\"\n", lconv->negative_sign);
      printf("positive_sign: \"%s\"\n", lconv->positive_sign);
      printf("n_sign_posn: %d\n", lconv->n_sign_posn);
      printf("p_sign_posn: %d\n", lconv->p_sign_posn);
  #ifndef _WIN32
      printf("int_n_sign_posn: %d\n", lconv->int_n_sign_posn);
      printf("int_p_sign_posn: %d\n", lconv->int_p_sign_posn);
  #endif
      return 0;
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120317/new/

https://reviews.llvm.org/D120317



More information about the libcxx-commits mailing list