回答編集履歴
1
.
answer
CHANGED
@@ -2,3 +2,10 @@
|
|
2
2
|
[My code calls a static/global function. Can I mock it?](https://google.github.io/googletest/gmock_faq.html#my-code-calls-a-staticglobal-function-can-i-mock-it)
|
3
3
|
|
4
4
|
大雑把に言うと「それはできないので、テスト対象コードを書き換える必要あり」です。
|
5
|
+
|
6
|
+
たとえば `MyClass` をパラメータ化するとか。
|
7
|
+
```c++
|
8
|
+
template <typename T> bool init(const SubClass& subClass) {
|
9
|
+
...
|
10
|
+
myclasptr = T::Create();
|
11
|
+
```
|