23 lines
600 B
C++
23 lines
600 B
C++
#include <gtest/gtest.h>
|
|
#include "../src/calculator.h" // Include the header for the class we are testing
|
|
|
|
// Test fixture for Calculator class
|
|
class CalculatorTest : public ::testing::Test {
|
|
protected:
|
|
Calculator calc;
|
|
};
|
|
|
|
// Test case for the add method
|
|
TEST_F(CalculatorTest, Add) {
|
|
EXPECT_EQ(calc.add(2, 2), 4);
|
|
EXPECT_EQ(calc.add(-1, 1), 0);
|
|
EXPECT_EQ(calc.add(-5, -5), -10);
|
|
}
|
|
|
|
// Another test case for the add method for good measure
|
|
TEST_F(CalculatorTest, AddWithZero) {
|
|
EXPECT_EQ(calc.add(0, 5), 5);
|
|
EXPECT_EQ(calc.add(5, 0), 5);
|
|
EXPECT_EQ(calc.add(0, 0), 0);
|
|
}
|