c++ unittest in ros

#include <gtest/gtest.h>

// Example class to be tested
class Calculator {
public:
    int add(int a, int b) {
        return a + b;
    }

    int subtract(int a, int b) {
        return a - b;
    }
};

// Test fixture for Calculator class
class CalculatorTest : public ::testing::Test {
protected:
    Calculator calc;
};

// Test case for the add function
TEST_F(CalculatorTest, AddTest) {
    ASSERT_EQ(calc.add(2, 3), 5);
    ASSERT_EQ(calc.add(-1, 1), 0);
    ASSERT_EQ(calc.add(0, 0), 0);
}

// Test case for the subtract function
TEST_F(CalculatorTest, SubtractTest) {
    ASSERT_EQ(calc.subtract(5, 3), 2);
    ASSERT_EQ(calc.subtract(1, -1), 2);
    ASSERT_EQ(calc.subtract(0, 0), 0);
}

// Main function to run the tests
int main(int argc, char argv) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}