Skip to content

Commit 64c7f40

Browse files
committed
Update README.md and MANUAL.md
1 parent 2e02ee9 commit 64c7f40

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

MANUAL.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@ To use the expectations, you must:
167167
168168
| OPTION | Description |
169169
| - | - |
170-
| `-i, --input <input> ` | Input file |
171-
| `-m, --mock-output <mock-output>` | Mock output path |
172-
| `-e, --expect-output <expect-output>` | Expectation output path |
170+
| `-i, --input <input> ` | Input file path |
171+
| `-m, --mock-output <mock-output>` | Mock output directory or file path |
172+
| `-e, --expect-output <expect-output>` | Expectation output directory or file path |
173173
| `-x, --cpp` | Force interpretation of the input file as C++ |
174174
| `-s, --std` | Set language standard (c\+\+14, c\+\+17, etc.)|
175175
| `-I, --include-path <path>` | Include path |
176+
| `-B, --base-directory <path>` | Base directory path |
176177
| `-t, --type-override <expr>` | Override generic type |
177178
| `-f, --config-file <file>` | Configuration file to be parsed for options |
178179
| `-v, --version` | Print version |
@@ -190,6 +191,16 @@ To force the interpretation of a header file as C++ use the `-x` / `--cpp` optio
190191
191192
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.
192193
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 _&lt;project-path&gt;/sources/MockedClass/MockedClass.h_ into _&lt;project-path&gt;/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 _&lt;project-path&gt;/sources/MockedClass/MockedClass.h_ into _&lt;project-path&gt;/tests/mocks/_ using the option `-B <project-path>/sources`, the mocked header will be included as `#include "MockedClass/MockedClass.h"`.
203+
193204
#### Language
194205
195206
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).

README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ On Ubuntu systems you can install CppUMockGen from the [CppUMockGen PPA reposito
108108
109109
| OPTION | Description |
110110
| - | - |
111-
| `-i, --input <input> ` | Input file |
112-
| `-m, --mock-output <mock-output>` | Mock output path |
113-
| `-e, --expect-output <expect-output>` | Expectation output path |
111+
| `-i, --input <input> ` | Input file path |
112+
| `-m, --mock-output <mock-output>` | Mock output directory or file path |
113+
| `-e, --expect-output <expect-output>` | Expectation output directory or file path |
114114
| `-x, --cpp` | Force interpretation of the input file as C++ |
115115
| `-s, --std` | Set language standard (c\+\+14, c\+\+17, etc.)|
116116
| `-I, --include-path <path>` | Include path |
117+
| `-B, --base-directory <path>` | Base directory path |
117118
| `-t, --type-override <expr>` | Override generic type |
118119
| `-f, --config-file <file>` | Configuration file to be parsed for options |
119120
| `-v, --version` | Print version |
@@ -123,7 +124,9 @@ To generate a mock from a header file containing the functions that you want to
123124
124125
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).
125126
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).
127130
128131
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.
129132

0 commit comments

Comments
 (0)