Skip to content

Commit 236b899

Browse files
committed
add code to be tested
1 parent b665782 commit 236b899

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ project(gtest_coverage)
33

44
set(CMAKE_CXX_STANDARD 20)
55

6-
add_executable(gtest_coverage main.cpp)
6+
add_executable(gtest_coverage main.cpp src/testsubject.cpp)

main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#include <iostream>
22

3+
#include "src/testsubject.h"
4+
35
int main() {
4-
std::cout << "Hello, World!" << std::endl;
6+
int evenNum = 2;
7+
int oddNum = 3;
8+
std::cout << "Square of " << evenNum << " is: " << TestSubject::square(evenNum) << std::endl;
9+
std::cout << "Square of " << oddNum << " is: " << TestSubject::square(oddNum) << std::endl;
510
return 0;
611
}

src/testsubject.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "testsubject.h"
2+
3+
bool TestSubject::isEven(int x) {
4+
return (x % 2 == 0);
5+
}
6+
7+
int TestSubject::square(int x) {
8+
if (isEven(x)) {
9+
return x * x;
10+
} else {
11+
// Intentionally made wrong
12+
return x + x;
13+
}
14+
}

src/testsubject.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
class TestSubject {
4+
public:
5+
static bool isEven(int x);
6+
7+
static int square(int x);
8+
};

0 commit comments

Comments
 (0)