- succeed = success,
- failed =
- nonfatal failure, = ASSERT_* : don't abort the function
- fatal failure, = EXPECT_* : abort the function
- crash
custom failure message
ASSERT_EQ(x.size(), y.size()) << "Vectors x and y are of unequal length";
for (int i = 0; i < x.size(); ++i) {
EXPECT_EQ(x[i], y[i]) << "Vectors x and y differ at index " << i;
}
(testSuiteName, testName) - hould not contain any underscores (_)
//define texture
class MyTestTexture : public ::testing::Test {
protected:
void SetUp() override {
//init
}
void TearDown() override {
//deconstruction
}
// use texture
TEST_F(MyTestTexture, MyTestName) {
// assertions
}
RUN_ALL_TESTS(), which returns 0 if all the tests are successful, or 1 otherwise. Note that RUN_ALL_TESTS() runs all tests in your link unit–they can be from different test suites, or even different source files.
Most users should not need to write their own main function and instead link with gtest_main (as opposed to with gtest), which defines a suitable entry point.
sudo apt install cmake
https://matgomes.com/integrate-google-test-into-cmake/#gtest-cmake-tldr https://github.com/matheusgomes28/cmake-google-tests