CoolProp 8.0.0
An open-source fluid property and humid air property database
TestUtils.h
Go to the documentation of this file.
1// Shared helpers for Catch2 test TUs. Header-only.
2
3#ifndef COOLPROP_TESTS_TEST_UTILS_H
4#define COOLPROP_TESTS_TEST_UTILS_H
5
6#if defined(_WIN32)
7# include <process.h> // _getpid
8#else
9# include <unistd.h> // getpid
10#endif
11
12namespace CoolProp {
13namespace tests {
14
15// Portable process ID for tests that stage scratch files under
16// fs::temp_directory_path() — suffix the path with this so two
17// concurrent CatchTestRunner instances (preflight in two worktrees,
18// dev + CI, etc.) don't collide on the same hardcoded path. See
19// CoolProp-8ft.
20inline int test_pid() {
21#if defined(_WIN32)
22 return ::_getpid();
23#else
24 return ::getpid();
25#endif
26}
27
28} // namespace tests
29} // namespace CoolProp
30
31#endif // COOLPROP_TESTS_TEST_UTILS_H