{"action":"created","issue":{"url":"https://api.github.com/repos/nlohmann/json/issues/709","repository_url":"https://api.github.com/repos/nlohmann/json","labels_url":"https://api.github.com/repos/nlohmann/json/issues/709/labels{/name}","comments_url":"https://api.github.com/repos/nlohmann/json/issues/709/comments","events_url":"https://api.github.com/repos/nlohmann/json/issues/709/events","html_url":"https://github.com/nlohmann/json/issues/709","id":252600165,"number":709,"title":"Gtest SEH Exception","user":{"login":"SimonEbner","id":570249,"avatar_url":"https://avatars0.githubusercontent.com/u/570249?v=4","gravatar_id":"","url":"https://api.github.com/users/SimonEbner","html_url":"https://github.com/SimonEbner","followers_url":"https://api.github.com/users/SimonEbner/followers","following_url":"https://api.github.com/users/SimonEbner/following{/other_user}","gists_url":"https://api.github.com/users/SimonEbner/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonEbner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonEbner/subscriptions","organizations_url":"https://api.github.com/users/SimonEbner/orgs","repos_url":"https://api.github.com/users/SimonEbner/repos","events_url":"https://api.github.com/users/SimonEbner/events{/privacy}","received_events_url":"https://api.github.com/users/SimonEbner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-08-24T13:23:29Z","updated_at":"2017-08-24T13:39:40Z","closed_at":null,"body":"Running the following test using GTest causes an SEH Exception for me using VS 2017 / gcc 5.4\r\n```cpp\r\nTEST(foo, fail1)\r\n{\r\n    auto obj = json{ {\"foo\", \"bar\"} };\r\n    ASSERT_THAT(obj, Eq(obj));\r\n}\r\n\r\nMATCHER(IsFooObject, \"\")\r\n{\r\n    return arg == json{ { \"foo\", \"bar\" } };\r\n}\r\n\r\nTEST(foo, fail2)\r\n{\r\n    auto obj = json{ { \"foo\", \"bar\" } };\r\n    ASSERT_THAT(obj, IsFooObject());\r\n}\r\n```\r\n\r\nThese 'simpler' tests, however, work fine. \r\n\r\n```cpp\r\nTEST(foo, success1)\r\n{\r\n    auto obj = json{ { \"foo\", \"bar\" } };\r\n    ASSERT_EQ(obj, obj);\r\n}\r\n\r\nTEST(foo, success2)\r\n{\r\n    auto obj = json{ { \"foo\", \"bar\" } };\r\n    ASSERT_TRUE(obj == obj);\r\n}\r\n```\r\n\r\nI could not find any information on how to make json.hpp together with Gtest work. Is there a chance to make custom matchers (MATCHER_P) work?"},"comment":{"url":"https://api.github.com/repos/nlohmann/json/issues/comments/324637913","html_url":"https://github.com/nlohmann/json/issues/709#issuecomment-324637913","issue_url":"https://api.github.com/repos/nlohmann/json/issues/709","id":324637913,"user":{"login":"SimonEbner","id":570249,"avatar_url":"https://avatars0.githubusercontent.com/u/570249?v=4","gravatar_id":"","url":"https://api.github.com/users/SimonEbner","html_url":"https://github.com/SimonEbner","followers_url":"https://api.github.com/users/SimonEbner/followers","following_url":"https://api.github.com/users/SimonEbner/following{/other_user}","gists_url":"https://api.github.com/users/SimonEbner/gists{/gist_id}","starred_url":"https://api.github.com/users/SimonEbner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimonEbner/subscriptions","organizations_url":"https://api.github.com/users/SimonEbner/orgs","repos_url":"https://api.github.com/users/SimonEbner/repos","events_url":"https://api.github.com/users/SimonEbner/events{/privacy}","received_events_url":"https://api.github.com/users/SimonEbner/received_events","type":"User","site_admin":false},"created_at":"2017-08-24T13:39:40Z","updated_at":"2017-08-24T13:39:40Z","body":"Certainly. So I use the latest version (commit `c38baf9858311e2887623465c8be433cfa585d2a`) of gtest / gmock from https://github.com/google/googletest. The complete mail file is as follows\r\n```cpp\r\n#include <gtest/gtest.h>\r\n#include <gmock/gmock.h>\r\n#include \"json.hpp\"\r\n\r\nusing namespace testing;\r\nusing namespace nlohmann;\r\n\r\nTEST(foo, fail1)\r\n{\r\n      auto obj = json{ {\"foo\", \"bar\"} };\r\n          ASSERT_THAT(obj, Eq(obj));\r\n}\r\n\r\nMATCHER(IsFooObject, \"\")\r\n{\r\n      return arg == json{ { \"foo\", \"bar\" } };\r\n}\r\n\r\nTEST(foo, fail2)\r\n{\r\n      auto obj = json{ { \"foo\", \"bar\" } };\r\n          ASSERT_THAT(obj, IsFooObject());\r\n}\r\n\r\nTEST(foo, success1)\r\n{\r\n      auto obj = json{ { \"foo\", \"bar\" } };\r\n          ASSERT_EQ(obj, obj);\r\n}\r\n\r\nTEST(foo, success2)\r\n{\r\n      auto obj = json{ { \"foo\", \"bar\" } };\r\n          ASSERT_TRUE(obj == obj);\r\n}\r\n\r\nint main(int argc, char** argv)\r\n{\r\n  InitGoogleTest(&argc, argv);\r\n  return RUN_ALL_TESTS();\r\n}\r\n```\r\nwhich I compile using `g++ json_test.cc --std=c++11 -lgtest -lgmock -lpthread -g`. I can run the successful tests using `./a.out --gtest_filter=\"*success*\"` whereas the other tests fail with `./a.out --gtest_filter=*fail1*` (or 2 respectively). When I run the test with gdb I get\r\n\r\n```(gdb) r\r\nThe program being debugged has been started already.\r\nStart it from the beginning? (y or n) y\r\nStarting program: /home/simon/dev/test_code/a.out \r\n[Thread debugging using libthread_db enabled]\r\nUsing host libthread_db library \"/lib/x86_64-linux-gnu/libthread_db.so.1\".\r\n[==========] Running 4 tests from 1 test case.\r\n[----------] Global test environment set-up.\r\n[----------] 4 tests from foo\r\n[ RUN      ] foo.fail1\r\n\r\nProgram received signal SIGSEGV, Segmentation fault.\r\n0x00007ffff7946d22 in std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) ()\r\n   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6\r\n(gdb) where\r\n#0  0x00007ffff7946d22 in std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) ()\r\n   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6\r\n#1  0x00007ffff7947168 in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6\r\n#2  0x00000000004100d6 in testing::internal::DefaultPrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (container=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:381\r\n#3  0x000000000040f89d in testing::internal::PrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:479\r\n#4  0x000000000040ea11 in testing::internal::UniversalPrinter<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::Print (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:720\r\n#5  0x000000000040c890 in testing::internal::UniversalPrint<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:869\r\n#6  0x000000000041017c in testing::internal::DefaultPrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (container=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:395\r\n#7  0x000000000040f89d in testing::internal::PrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:479\r\n#8  0x000000000040ea11 in testing::internal::UniversalPrinter<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::Print (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:720\r\n#9  0x000000000040c890 in testing::internal::UniversalPrint<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:869\r\n#10 0x000000000041017c in testing::internal::DefaultPrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (container=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:395\r\n#11 0x000000000040f89d in testing::internal::PrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:479\r\n#12 0x000000000040ea11 in testing::internal::UniversalPrinter<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::Print (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:720\r\n#13 0x000000000040c890 in testing::internal::UniversalPrint<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:869\r\n#14 0x000000000041017c in testing::internal::DefaultPrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (container=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:395\r\n#15 0x000000000040f89d in testing::internal::PrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:479\r\n#16 0x000000000040ea11 in testing::internal::UniversalPrinter<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::Print (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:720\r\n#17 0x000000000040c890 in testing::internal::UniversalPrint<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:869\r\n#18 0x000000000041017c in testing::internal::DefaultPrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (container=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:395\r\n#19 0x000000000040f89d in testing::internal::PrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:479\r\n#20 0x000000000040ea11 in testing::internal::UniversalPrinter<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::Print (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:720\r\n#21 0x000000000040c890 in testing::internal::UniversalPrint<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:869\r\n#22 0x000000000041017c in testing::internal::DefaultPrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (container=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:395\r\n#23 0x000000000040f89d in testing::internal::PrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:479\r\n#24 0x000000000040ea11 in testing::internal::UniversalPrinter<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::Print (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:720\r\n#25 0x000000000040c890 in testing::internal::UniversalPrint<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:869\r\n#26 0x000000000041017c in testing::internal::DefaultPrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (container=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:395\r\n#27 0x000000000040f89d in testing::internal::PrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:479\r\n#28 0x000000000040ea11 in testing::internal::UniversalPrinter<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> >::Print (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:720\r\n#29 0x000000000040c890 in testing::internal::UniversalPrint<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (value=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:869\r\n#30 0x000000000041017c in testing::internal::DefaultPrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (container=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:395\r\n#31 0x000000000040f89d in testing::internal::PrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlo\r\n---Type <return> to continue, or q <return> to quit---\r\n```\r\nThe list goes on forever, so I'm not sure how much of that information is helpful in this issue. Please let me know if you require further information."}}
{"actor":{"display_login":"SimonEbner"}}