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

Test suite fails in en_GB.UTF-8 #500

Closed
mikecrowe opened this issue Mar 13, 2017 · 6 comments
Closed

Test suite fails in en_GB.UTF-8 #500

mikecrowe opened this issue Mar 13, 2017 · 6 comments
Assignees
Milestone

Comments

@mikecrowe
Copy link

As requested in #492 (comment) , the test suite appears to fail for me under Debian 9 (Stretch) amd64:

$ git rev-parse HEAD
c5cf32e34d19573e2fefde373ca7a48bdae52be3
$ locale
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC=en_GB.utf8
LC_TIME=en_GB.utf8
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY=en_GB.utf8
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER=en_GB.utf8
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT=en_GB.utf8
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
$ mkdir build && cd build && cmake ..
$ make -j8 && make -j8 test
$ cat Testing/Temporary/LastTest.log
Start testing: Mar 13 12:26 GMT
----------------------------------------------------------
1/2 Testing: json_unit_default
1/2 Test: json_unit_default
Command: "/home/mac/git/json/build/test/json_unit"
Directory: /home/mac/git/json
"json_unit_default" start time: Mar 13 12:26 GMT
Output:
----------------------------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
json_unit is a Catch v1.8.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
regression tests
  issue #378 - locale-independent num-to-str
-------------------------------------------------------------------------------
/home/mac/git/json/test/src/unit-regression.cpp:459
...............................................................................

/home/mac/git/json/test/src/unit-regression.cpp:469: FAILED:
  CHECK( strcmp(buf.data(), "12345,67") == 0 )
with expansion:
  2 == 0

-------------------------------------------------------------------------------
regression tests
  issue #379 - locale-independent str-to-num
-------------------------------------------------------------------------------
/home/mac/git/json/test/src/unit-regression.cpp:479
...............................................................................

/home/mac/git/json/test/src/unit-regression.cpp:488: FAILED:
  CHECK( std::strtod("3,14", nullptr) == 3.14 )
with expansion:
  3.0 == 3.14

/home/mac/git/json/test/src/unit-regression.cpp:491: FAILED:
  CHECK( std::strtod("3.14", nullptr) == 3 )
with expansion:
  3.14 == 3

===============================================================================
test cases:      49 |      48 passed | 1 failed
assertions: 2305788 | 2305785 passed | 3 failed

<end of output>
Test time =   6.12 sec
----------------------------------------------------------
Test Failed.
"json_unit_default" end time: Mar 13 12:26 GMT
"json_unit_default" time elapsed: 00:00:06
----------------------------------------------------------
2/2 Testing: json_unit_all
2/2 Test: json_unit_all
Command: "/home/mac/git/json/build/test/json_unit" "*"
Directory: /home/mac/git/json
"json_unit_all" start time: Mar 13 12:26 GMT
Output:
----------------------------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
json_unit is a Catch v1.8.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
regression tests
  issue #378 - locale-independent num-to-str
-------------------------------------------------------------------------------
/home/mac/git/json/test/src/unit-regression.cpp:459
...............................................................................

/home/mac/git/json/test/src/unit-regression.cpp:469: FAILED:
  CHECK( strcmp(buf.data(), "12345,67") == 0 )
with expansion:
  2 == 0

-------------------------------------------------------------------------------
regression tests
  issue #379 - locale-independent str-to-num
-------------------------------------------------------------------------------
/home/mac/git/json/test/src/unit-regression.cpp:479
...............................................................................

/home/mac/git/json/test/src/unit-regression.cpp:488: FAILED:
  CHECK( std::strtod("3,14", nullptr) == 3.14 )
with expansion:
  3.0 == 3.14

/home/mac/git/json/test/src/unit-regression.cpp:491: FAILED:
  CHECK( std::strtod("3.14", nullptr) == 3 )
with expansion:
  3.14 == 3

===============================================================================
test cases:       53 |       52 passed | 1 failed
assertions: 11202857 | 11202854 passed | 3 failed

<end of output>
Test time =  47.87 sec
----------------------------------------------------------
Test Failed.
"json_unit_all" end time: Mar 13 12:27 GMT
"json_unit_all" time elapsed: 00:00:47
----------------------------------------------------------

End testing: Mar 13 12:27 GMT

I've tried using a French locale and that doesn't seem to help. I must be doing something wrong, but I've no idea what!

@nlohmann
Copy link
Owner

Thanks for reporting. I hoped this was fixed...

@nlohmann
Copy link
Owner

Unfortunately, I cannot reproduce the error with macOS (see below). I may have to check on a Linux system. Any help appreciated!

 niels@megan  ~/Documents/repositories/json   develop ●  git rev-parse HEAD
c5cf32e34d19573e2fefde373ca7a48bdae52be3
 niels@megan  ~/Documents/repositories/json   develop ●  locale
LANG="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_CTYPE="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_ALL="en_GB.UTF-8"
 niels@megan  ~/Documents/repositories/json   develop ●  mkdir build && cd build && cmake ..
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- cotire 1.7.9 loaded.
-- CXX target json_unit cotired without unity build.
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/niels/Documents/repositories/json/build
 niels@megan  ~/Documents/repositories/json/build   develop ●  make -j8 && make -j8 test
Scanning dependencies of target catch_main
[  2%] Building CXX object test/CMakeFiles/catch_main.dir/src/unit.cpp.o
[  2%] Built target catch_main
[  5%] Generating CXX prefix source test/cotire/json_unit_CXX_prefix.cxx
[  7%] Generating CXX prefix header test/cotire/json_unit_CXX_prefix.hxx
[ 10%] Building CXX precompiled header test/cotire/json_unit_CXX_prefix.hxx.pch
Scanning dependencies of target json_unit
[ 12%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-algorithms.cpp.o
[ 15%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-allocator.cpp.o
[ 17%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-cbor.cpp.o
[ 20%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-class_const_iterator.cpp.o
[ 22%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-class_iterator.cpp.o
[ 25%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-class_lexer.cpp.o
[ 27%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-class_parser.cpp.o
[ 30%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-capacity.cpp.o
[ 32%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-comparison.cpp.o
[ 35%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-concepts.cpp.o
[ 37%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-constructor1.cpp.o
[ 40%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-constructor2.cpp.o
[ 42%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-convenience.cpp.o
[ 45%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-conversions.cpp.o
[ 47%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-deserialization.cpp.o
[ 50%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-element_access1.cpp.o
[ 52%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-element_access2.cpp.o
[ 55%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-inspection.cpp.o
[ 57%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-iterator_wrapper.cpp.o
[ 60%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-iterators1.cpp.o
[ 62%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-iterators2.cpp.o
[ 65%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-json_patch.cpp.o
[ 67%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-json_pointer.cpp.o
[ 70%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-meta.cpp.o
[ 72%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-modifiers.cpp.o
[ 75%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-msgpack.cpp.o
[ 77%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-noexcept.cpp.o
[ 80%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-pointer_access.cpp.o
[ 82%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-readme.cpp.o
[ 85%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-reference_access.cpp.o
[ 87%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-regression.cpp.o
[ 90%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-serialization.cpp.o
[ 92%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-testsuites.cpp.o
[ 95%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-udt.cpp.o
[ 97%] Building CXX object test/CMakeFiles/json_unit.dir/src/unit-unicode.cpp.o
[100%] Linking CXX executable json_unit
[100%] Built target json_unit
Running tests...
Test project /Users/niels/Documents/repositories/json/build
    Start 1: json_unit_default
1/2 Test #1: json_unit_default ................   Passed   22.26 sec
    Start 2: json_unit_all
2/2 Test #2: json_unit_all ....................   Passed  124.02 sec

100% tests passed, 0 tests failed out of 2

Total Test time (real) = 146.30 sec

@TurpentineDistillery
Copy link

TurpentineDistillery commented Mar 13, 2017

Note that the checks are failing in the code that checks the preconditions for the real check - that the standard library on the target platform respects the locale's settings. I'm hypothesizing that de_DE.UTF-8 locale is not supported on OP's platform.

I think we can leave the library-specific checks in place and dispense with the precondition-checks that the locale-specific behavior was induced.

@nlohmann
Copy link
Owner

@TurpentineDistillery Good observation!

@mikecrowe Could you please try the tests with the (patched) file unit-regression.cpp.zip?

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Mar 13, 2017
@mikecrowe
Copy link
Author

I can confirm that either enabling the de_DE.UTF-8 locale on my machine, or using your updated unit-regression.cpp makes the tests pass.

Thanks!

@nlohmann
Copy link
Owner

Thanks for the quick response!

nlohmann added a commit that referenced this issue Mar 14, 2017
Removed a check that already failed in MSVC.
@nlohmann nlohmann added this to the Release 3.0.0 milestone Mar 14, 2017
@nlohmann nlohmann removed the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Mar 14, 2017
@nlohmann nlohmann self-assigned this Mar 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants