Menu

False positive - error/syntaxError

biwipo4118
2020-09-30
2020-09-30
  • biwipo4118

    biwipo4118 - 2020-09-30
    #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

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.