-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Gtest SEH Exception #709
Comments
Thanks for reporting. I have no experience with Gtest. Can you post the exact exception/error message, and maybe a complete example program so I can try to reproduce/debug? |
Certainly. So I use the latest version (commit #include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "json.hpp"
using namespace testing;
using namespace nlohmann;
TEST(foo, fail1)
{
auto obj = json{ {"foo", "bar"} };
ASSERT_THAT(obj, Eq(obj));
}
MATCHER(IsFooObject, "")
{
return arg == json{ { "foo", "bar" } };
}
TEST(foo, fail2)
{
auto obj = json{ { "foo", "bar" } };
ASSERT_THAT(obj, IsFooObject());
}
TEST(foo, success1)
{
auto obj = json{ { "foo", "bar" } };
ASSERT_EQ(obj, obj);
}
TEST(foo, success2)
{
auto obj = json{ { "foo", "bar" } };
ASSERT_TRUE(obj == obj);
}
int main(int argc, char** argv)
{
InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} which I compile using
The 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. |
We had this issue at work a long time ago (happened with We added this in a namespace nlohmann
{
inline void PrintTo(json const& json, std::ostream* os)
{
*os << json.dump();
}
} |
Looks like a stack overflow due to infinite recursion. It's these 4 functions repeating over and over. #10 0x000000000041017c in testing::internal::DefaultPrintTo<nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer> > (container=..., os=0x7fffffffd4a0) at /usr/local/include/gtest/gtest-printers.h:395 |
Yes, I agree @theodelrieu , and here's a PR to googletest that purports to fix the issue. google/googletest#1186 |
@SimonEbner If you could try out that PR version and report in that PR that it fixes your issue, then that might help the PR get approved. |
awesome, thank you @theodelrieu for the local fix and @gregmarr for pointint out the PR, both solutions work for me. |
I just stumbled upon the same problem simply doing: nlohmann::json j;
j = 1;
EXPECT_EQ(j, 0); GoogleTest has (had?) problems printing j in case of test-failure. |
Running the following test using GTest causes an SEH Exception for me using VS 2017 / gcc 5.4
These 'simpler' tests, however, work fine.
I 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?
The text was updated successfully, but these errors were encountered: