< Summary - calculator unit test code coverage (Linux)

Information
Class: /home/runner/work/cpp-cmake-ctest-template/cpp-cmake-ctest-template/src/tests/calculator/calculator_test.cpp
Assembly: Default
File(s): /home/runner/work/cpp-cmake-ctest-template/cpp-cmake-ctest-template/src/tests/calculator/calculator_test.cpp
Line coverage
100%
Covered lines: 26
Uncovered lines: 0
Coverable lines: 26
Total lines: 57
Line coverage: 100%
Branch coverage
18%
Covered branches: 14
Total branches: 77
Branch coverage: 18.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 09/30/2026 - 03:06:01 Line coverage: 100% (26/26) Branch coverage: 18.1% (14/77) Total lines: 57 09/30/2026 - 03:06:01 Line coverage: 100% (26/26) Branch coverage: 18.1% (14/77) Total lines: 57

File(s)

/home/runner/work/cpp-cmake-ctest-template/cpp-cmake-ctest-template/src/tests/calculator/calculator_test.cpp

#LineLine coverage
 1//#define ENABLE_CALCULATOR_TEST  // Uncomment this line to enable the Calculator tests
 2
 3#include "gtest/gtest.h"
 4#include "../../calculator/header/calculator.h"  // Adjust this include path based on your project structure
 5
 6using namespace Coruh::Calculator;
 7
 8class CalculatorTest : public ::testing::Test {
 9protected:
 510  void SetUp() override {
 11    // Setup test data
 512  }
 13
 514  void TearDown() override {
 15    // Clean up test data
 516  }
 17};
 18
 419TEST_F(CalculatorTest, TestAdd) {
 120  double result = Calculator::add(5.0, 3.0);
 121  EXPECT_DOUBLE_EQ(result, 8.0);
 122}
 23
 424TEST_F(CalculatorTest, TestSubtract) {
 125  double result = Calculator::subtract(5.0, 3.0);
 126  EXPECT_DOUBLE_EQ(result, 2.0);
 127}
 28
 429TEST_F(CalculatorTest, TestMultiply) {
 130  double result = Calculator::multiply(5.0, 3.0);
 131  EXPECT_DOUBLE_EQ(result, 15.0);
 132}
 33
 434TEST_F(CalculatorTest, TestDivide) {
 135  double result = Calculator::divide(6.0, 3.0);
 136  EXPECT_DOUBLE_EQ(result, 2.0);
 137}
 38
 439TEST_F(CalculatorTest, TestDivideByZero) {
 140  EXPECT_THROW(Calculator::divide(5.0, 0.0), std::invalid_argument);
 141}
 42
 43/**
 44 * @brief The main function of the test program.
 45 *
 46 * @param argc The number of command-line arguments.
 47 * @param argv An array of command-line argument strings.
 48 * @return int The exit status of the program.
 49 */
 3950int main(int argc, char** argv) {
 51#ifdef ENABLE_CALCULATOR_TEST
 3952  ::testing::InitGoogleTest(&argc, argv);
 3953  return RUN_ALL_TESTS();
 54#else
 55  return 0;
 56#endif
 57}