#include <gmock/gmock.h> #include <gtest/gtest.h> bool IsTrue() { return true; } template<typename ValueT> class TestStruct { public: TestStruct() : return_test(nullptr) {} ValueT* operator->() const { if (IsTrue()) { throw std::out_of_range("operator->()"); } return return_test; } ValueT* return_test; }; TEST(test_cppcheck, cppcheck) { TestStruct<int> it; ASSERT_THROW(it.operator->(), std::out_of_range); }
error/syntaxError: syntax error: operator
I am using --library=googletest
Thanks! I believe this was a bug in the googletest.cfg file. The expanded code did have a syntax error. I have fixed this with https://github.com/danmar/cppcheck/commit/1548bf226790b5b08e7240ef4a19fc0227e3504b
googletest.cfg
Log in to post a comment.
error/syntaxError: syntax error: operator
I am using --library=googletest
Thanks! I believe this was a bug in the
googletest.cfg
file. The expanded code did have a syntax error. I have fixed this with https://github.com/danmar/cppcheck/commit/1548bf226790b5b08e7240ef4a19fc0227e3504b