You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| `-x, --cpp` | Force interpretation of the input file as C++ |
174
174
| `-s, --std` | Set language standard (c\+\+14, c\+\+17, etc.)|
175
175
| `-I, --include-path <path>` | Include path |
176
+
| `-B, --base-directory <path>` | Base directory path |
176
177
| `-t, --type-override <expr>` | Override generic type |
177
178
| `-f, --config-file <file>` | Configuration file to be parsed for options |
178
179
| `-v, --version` | Print version |
@@ -190,6 +191,16 @@ To force the interpretation of a header file as C++ use the `-x` / `--cpp` optio
190
191
191
192
CppUMockGen, just as any C/C++ compiler, needs to know where to find other header files included by the input file in order to interpret it properly. Pass the paths to the necessary include directories by using the `-I` / `--include-path` option. Like with most compilers, you may use this option several times to indicate multiple include directories.
192
193
194
+
#### Base Directory
195
+
196
+
Mocks and expectations generated by CppUMockGen need to include the mocked header file. By default, the mocked header file will be referenced with a relative path from the directory where the mocks/expectations are generated.
197
+
198
+
> **Example:** When generating a mock for a file in _<project-path>/sources/MockedClass/MockedClass.h_ into _<project-path>/tests/mocks/_, the mocked header will be included as `#include "../../sources/MockedClass/MockedClass.h"`.
199
+
200
+
This behavior may be overriden (e.g., to generate files that can be moved in the directory structure) using the `-B` / `--base-directory` option to set a base directory to reference included mocked headers (e.g., set it to a directory that is in the include path when compiling tests).
201
+
202
+
> **Example:** When generating a mock for a file in _<project-path>/sources/MockedClass/MockedClass.h_ into _<project-path>/tests/mocks/_ using the option `-B <project-path>/sources`, the mocked header will be included as `#include "MockedClass/MockedClass.h"`.
203
+
193
204
#### Language
194
205
195
206
CppUMockGen parses C code according to the `gnu11` language standard, and parses C\+\+ code according to the `gnu++14` language standard. To indicate a different standard, use the `-s` / `--std` and pass a supported language standard. The list of supported language standards can be found in the [Clang compiler command line help](https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-std).
| `-x, --cpp` | Force interpretation of the input file as C++ |
115
115
| `-s, --std` | Set language standard (c\+\+14, c\+\+17, etc.)|
116
116
| `-I, --include-path <path>` | Include path |
117
+
| `-B, --base-directory <path>` | Base directory path |
117
118
| `-t, --type-override <expr>` | Override generic type |
118
119
| `-f, --config-file <file>` | Configuration file to be parsed for options |
119
120
| `-v, --version` | Print version |
@@ -123,7 +124,9 @@ To generate a mock from a header file containing the functions that you want to
123
124
124
125
To generate expectations, pass the path where you want the files with the expectation to be generated as output using the `-e` / `--expect-output` option (additionally to or instead of the `-m` option).
125
126
126
-
CppUMock, just as any C/C++ compiler, needs to know where to find other include files referenced by the input file in order to interpret it properly. Pass the paths to the necessary include directories by using the `-I` / `--include-path` option. Like with most compilers, you may use this option several times to indicate multiple include directories.
127
+
CppUMockGen, just as any C/C++ compiler, needs to know where to find other include files referenced by the input file in order to interpret it properly. Pass the paths to the necessary include directories by using the `-I` / `--include-path` option. Like with most compilers, you may use this option several times to indicate multiple include directories.
128
+
129
+
Mocks and expectations generated by CppUMockGen need to include the mocked header file. By default, the mocked header file will be referenced with a relative path from the directory where the mocks/expectations are generated. This behavior may be overriden using the `-B` / `--base-directory` option to set a base directory to reference included mocked headers (e.g., set it to a directory that is in the include path when compiling tests).
127
130
128
131
CppUMockGen deduces the data types to use with CppUMock from the actual function parameters and return types. If the API that you are mocking is well designed (e.g. pointers to non-const values are not used for input parameters), CppUMockGen will guess properly in most cases the correct types. Nevertheless, mocked data types can be overridden by using `-t` / `--type-override` options to indicate the type of function parameters or function returns. Type overriding can be defined in generic form, which apply to any function parameter or return types that match the specified type, or can be defined in function-specific form, which apply to parameters and return types of the specified function.
0 commit comments