Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3 - chrono-test (Failed) #2337

Closed
phprus opened this issue Jun 3, 2021 · 5 comments
Closed

3 - chrono-test (Failed) #2337

phprus opened this issue Jun 3, 2021 · 5 comments

Comments

@phprus
Copy link
Contributor

phprus commented Jun 3, 2021

Commit: 760ca5c

OS: openSUSE Leap 15.2

Console locale:

LANG=ru_RU.UTF-8
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=

Locale ru_RU.UTF-8 is present:

phprus@phprus:~/tmp/fmt/2/fmt-master> date
Чт июн  3 16:03:19 +05 2021

Test error:

test 3
      Start  3: chrono-test

3: Test command: /home/phprus/tmp/fmt/2/fmt-master/bin/chrono-test
3: Test timeout computed to be: 10000000
3: [==========] Running 25 tests from 1 test suite.
3: [----------] Global test environment set-up.
3: [----------] 25 tests from chrono_test
3: [ RUN      ] chrono_test.format_tm
3: [       OK ] chrono_test.format_tm (0 ms)
3: [ RUN      ] chrono_test.grow_buffer
3: [       OK ] chrono_test.grow_buffer (0 ms)
3: [ RUN      ] chrono_test.format_to_empty_container
3: [       OK ] chrono_test.format_to_empty_container (0 ms)
3: [ RUN      ] chrono_test.empty_result
3: [       OK ] chrono_test.empty_result (0 ms)
3: [ RUN      ] chrono_test.localtime
3: [       OK ] chrono_test.localtime (0 ms)
3: [ RUN      ] chrono_test.gmtime
3: [       OK ] chrono_test.gmtime (0 ms)
3: [ RUN      ] chrono_test.time_point
3: [       OK ] chrono_test.time_point (0 ms)
3: [ RUN      ] chrono_test.format_default
3: [       OK ] chrono_test.format_default (0 ms)
3: [ RUN      ] chrono_test.format_wide
3: [       OK ] chrono_test.format_wide (0 ms)
3: [ RUN      ] chrono_test.align
3: [       OK ] chrono_test.align (0 ms)
3: [ RUN      ] chrono_test.format_specs
3: [       OK ] chrono_test.format_specs (0 ms)
3: [ RUN      ] chrono_test.invalid_specs
3: [       OK ] chrono_test.invalid_specs (0 ms)
3: [ RUN      ] chrono_test.locale
3: /home/phprus/tmp/fmt/2/fmt-master/test/chrono-test.cc:261: Failure
3: Expected equality of these values:
3:   format_tm(make_hour(14), "%OH", jp_loc)
3:     Which is: "\xE5\x8D\x81\xE5\x9B\x9B"
3:     As Text: "十四"
3:   fmt::format(jp_loc, "{:L" "%OH" "}", std::chrono::hours(14))
3:     Which is: "14"
3: /home/phprus/tmp/fmt/2/fmt-master/test/chrono-test.cc:262: Failure
3: Expected equality of these values:
3:   format_tm(make_hour(14), "%OI", jp_loc)
3:     Which is: "\xE4\xBA\x8C"
3:     As Text: "二"
3:   fmt::format(jp_loc, "{:L" "%OI" "}", std::chrono::hours(14))
3:     Which is: "02"
3: /home/phprus/tmp/fmt/2/fmt-master/test/chrono-test.cc:263: Failure
3: Expected equality of these values:
3:   format_tm(make_minute(42), "%OM", jp_loc)
3:     Which is: "\xE5\x9B\x9B\xE5\x8D\x81\xE4\xBA\x8C"
3:     As Text: "四十二"
3:   fmt::format(jp_loc, "{:L" "%OM" "}", std::chrono::minutes(42))
3:     Which is: "42"
3: /home/phprus/tmp/fmt/2/fmt-master/test/chrono-test.cc:264: Failure
3: Expected equality of these values:
3:   format_tm(make_second(42), "%OS", jp_loc)
3:     Which is: "\xE5\x9B\x9B\xE5\x8D\x81\xE4\xBA\x8C"
3:     As Text: "四十二"
3:   fmt::format(jp_loc, "{:L" "%OS" "}", std::chrono::seconds(42))
3:     Which is: "42"
3: /home/phprus/tmp/fmt/2/fmt-master/test/chrono-test.cc:270: Failure
3: Expected equality of these values:
3:   format_tm(time, "%r", jp_loc)
3:     Which is: "\xE5\x8D\x88\xE5\x89\x8D" "03\xE6\x99\x82" "25\xE5\x88\x86" "45\xE7\xA7\x92"
3:     As Text: "午前03時25分45秒"
3:   fmt::format(jp_loc, "{:L" "%r" "}", sec)
3:     Which is: "03:25:45 AM"
3: /home/phprus/tmp/fmt/2/fmt-master/test/chrono-test.cc:271: Failure
3: Expected equality of these values:
3:   format_tm(time, "%p", jp_loc)
3:     Which is: "\xE5\x8D\x88\xE5\x89\x8D"
3:     As Text: "午前"
3:   fmt::format(jp_loc, "{:L" "%p" "}", sec)
3:     Which is: "AM"
3: [  FAILED  ] chrono_test.locale (305 ms)
3: [ RUN      ] chrono_test.format_default_fp
3: [       OK ] chrono_test.format_default_fp (0 ms)
3: [ RUN      ] chrono_test.format_precision
3: [       OK ] chrono_test.format_precision (0 ms)
3: [ RUN      ] chrono_test.format_full_specs
3: [       OK ] chrono_test.format_full_specs (0 ms)
3: [ RUN      ] chrono_test.format_simple_q
3: [       OK ] chrono_test.format_simple_q (0 ms)
3: [ RUN      ] chrono_test.format_precision_q
3: [       OK ] chrono_test.format_precision_q (0 ms)
3: [ RUN      ] chrono_test.format_full_specs_q
3: [       OK ] chrono_test.format_full_specs_q (0 ms)
3: [ RUN      ] chrono_test.invalid_width_id
3: [       OK ] chrono_test.invalid_width_id (0 ms)
3: [ RUN      ] chrono_test.invalid_colons
3: [       OK ] chrono_test.invalid_colons (0 ms)
3: [ RUN      ] chrono_test.negative_durations
3: [       OK ] chrono_test.negative_durations (0 ms)
3: [ RUN      ] chrono_test.special_durations
3: [       OK ] chrono_test.special_durations (0 ms)
3: [ RUN      ] chrono_test.unsigned_duration
3: [       OK ] chrono_test.unsigned_duration (0 ms)
3: [ RUN      ] chrono_test.weekday
3: /home/phprus/tmp/fmt/2/fmt-master/test/chrono-test.cc:383: Failure
3: Expected equality of these values:
3:   fmt::format("{}", mon)
3:     Which is: "\xD0\x9F\xD0\xBD"
3:     As Text: "Пн"
3:   "Mon"
3: [  FAILED  ] chrono_test.weekday (0 ms)
3: [----------] 25 tests from chrono_test (306 ms total)
3: 
3: [----------] Global test environment tear-down
3: [==========] 25 tests from 1 test suite ran. (306 ms total)
3: [  PASSED  ] 23 tests.
3: [  FAILED  ] 2 tests, listed below:
3: [  FAILED  ] chrono_test.locale
3: [  FAILED  ] chrono_test.weekday
3: 
3:  2 FAILED TESTS
 3/18 Test  #3: chrono-test ......................***Failed    0.31 sec
@phprus
Copy link
Contributor Author

phprus commented Jun 3, 2021

Branch with the installed of the locales package for CI: https://github.com/phprus/fmt/tree/locale-1

Test errors:

The following tests FAILED:
	  3 - chrono-test (Failed)
	 14 - unicode-test (Failed)

@phprus
Copy link
Contributor Author

phprus commented Jun 4, 2021

CentOS 7 + clang-9 + libc++:

[ RUN      ] chrono_test.locale
unknown file: Failure
C++ exception with description "failed to format time" thrown in the test body.
[  FAILED  ] chrono_test.locale (14 ms)

@phprus
Copy link
Contributor Author

phprus commented Jun 10, 2021

Check locale:

# LANG=ru_RU.UTF-8 date
Чт июн 10 16:29:03 +05 2021
# LANG=C date
Thu Jun 10 16:29:03 +05 2021

Test code:

#include <locale>
#include <ctime>
#include <sstream>
#include <iostream>

void print(const std::locale &loc)
{
    auto time = std::tm();
    time.tm_wday = 1;
    auto&& os = std::ostringstream();
    using iterator = std::ostreambuf_iterator<char>;
    const auto& facet = std::use_facet<std::time_put<char, iterator>>( loc );
    facet.put(os, os, ' ', &time, 'a', 0);
    std::cerr << "locale " << loc.name() <<": " << os.str() << std::endl;
}

int main()
{
    auto loc_c = std::locale::classic();
    auto loc = std::locale("ru_RU.UTF-8");

    print(loc_c);
    auto old = std::locale::global(loc);
    print(loc);
    print(loc_c);
    print(old);

    return 0;
}

Unexpected output:

locale C: Mon
locale ru_RU.UTF-8: Пн
locale C: Пн
locale C: Пн

After replace main function to:

int main()
{
    auto loc = std::locale("ru_RU.UTF-8");
    print(loc);
    return 0;
}

Output is:

locale ru_RU.UTF-8: Mon

System: openSUSE Leap 15.2
Compiler: gcc version 10.2.1 20200825 [revision c0746a1beb1ba073c7981eb09f55b3d993b32e5c] (SUSE Linux)
glibc-2.26-lp152.26.6.1.x86_64

I don't understand why it works this way...

@vitaut
Copy link
Contributor

vitaut commented Jun 14, 2021

Is it fixed by #2349?

@phprus
Copy link
Contributor Author

phprus commented Jun 14, 2021

Yes

@phprus phprus closed this as completed Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants