Compare containers with GoogleTest

20,521

You're just missing gtest's testing namespace qualifier:

EXPECT_THAT(test1, ::testing::ContainerEq(test2));
Share:
20,521
Stefano
Author by

Stefano

Updated on January 26, 2021

Comments

  • Stefano
    Stefano over 3 years

    I'm trying to get a working googletest test that compares two vectors. For this I'm using google mock with its matchers but I get a C3861 error saying "ContainerEq identifier not found" and also C2512 saying "testing::AssertionResult has not a proper default constructor available". Why?

    TEST(MyTestSuite, MyTest)
    {
        std::vector<int> test1;
        std::vector<int> test2;
    
        ...
    
        EXPECT_THAT(test1, ContainerEq(test2));
    }