質問編集履歴
1
c -> c++
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
例えば、以下のような自分で作ったコード(ユニットテスト対象)があったとして、ConcreteCalculatorは他人が作る部位で未完成のため、自分で作っているAddition::add()のユニットテストでは、calc.add関数をモックで置き換えたいのです。
|
4
4
|
|
5
|
-
```
|
5
|
+
```cpp:テスト対象
|
6
6
|
#include "target.h"
|
7
7
|
#include "concrete_calculator.h"
|
8
8
|
|
@@ -30,7 +30,7 @@
|
|
30
30
|
└── test_target.cpp
|
31
31
|
```
|
32
32
|
|
33
|
-
```
|
33
|
+
```cpp
|
34
34
|
calculator.h
|
35
35
|
#ifndef CALCULATOR_H
|
36
36
|
#define CALCULATOR_H
|
@@ -44,7 +44,7 @@
|
|
44
44
|
#endif //CALCULATOR_H
|
45
45
|
```
|
46
46
|
|
47
|
-
```
|
47
|
+
```cpp
|
48
48
|
concreate_calculator.h
|
49
49
|
#ifndef CONCRETE_CALCULATOR_H
|
50
50
|
#define CONCRETE_CALCULATOR_H
|
@@ -59,7 +59,7 @@
|
|
59
59
|
#endif //CONCRETE_CALCULATOR_H
|
60
60
|
```
|
61
61
|
|
62
|
-
```
|
62
|
+
```cpp
|
63
63
|
target.h
|
64
64
|
#ifndef TARGET_H
|
65
65
|
#define TARGET_H
|
@@ -74,7 +74,7 @@
|
|
74
74
|
#endif //TARGET_H
|
75
75
|
```
|
76
76
|
|
77
|
-
```
|
77
|
+
```cpp
|
78
78
|
target.cpp
|
79
79
|
#include "target.h"
|
80
80
|
#include "concrete_calculator.h"
|
@@ -85,7 +85,7 @@
|
|
85
85
|
}
|
86
86
|
```
|
87
87
|
|
88
|
-
```
|
88
|
+
```cpp
|
89
89
|
calculator-mock.h
|
90
90
|
#ifndef CALCULATOR_MOCK_H
|
91
91
|
#define CALCULATOR_MOCK_H
|
@@ -106,7 +106,7 @@
|
|
106
106
|
#endif //CALCULATOR_MOCK_H
|
107
107
|
```
|
108
108
|
|
109
|
-
```
|
109
|
+
```cpp
|
110
110
|
test_target.cpp
|
111
111
|
#include "CppUTest/CommandLineTestRunner.h"
|
112
112
|
#include "CppUTestExt/MockSupport.h"
|