| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright Contributors to the OpenVDB Project | ||
| 2 | // SPDX-License-Identifier: MPL-2.0 | ||
| 3 | |||
| 4 | /// @file test/integration/TestHarness.h | ||
| 5 | /// | ||
| 6 | /// @authors Francisco Gochez, Nick Avramoussis | ||
| 7 | /// | ||
| 8 | /// @brief Test harness and base methods | ||
| 9 | |||
| 10 | #ifndef OPENVDB_POINTS_UNITTEST_TEST_HARNESS_INCLUDED | ||
| 11 | #define OPENVDB_POINTS_UNITTEST_TEST_HARNESS_INCLUDED | ||
| 12 | |||
| 13 | #include "CompareGrids.h" | ||
| 14 | |||
| 15 | #include <openvdb_ax/ast/Tokens.h> | ||
| 16 | #include <openvdb_ax/compiler/Compiler.h> | ||
| 17 | #include <openvdb_ax/compiler/CustomData.h> | ||
| 18 | |||
| 19 | #include <openvdb/points/PointAttribute.h> | ||
| 20 | #include <openvdb/points/PointScatter.h> | ||
| 21 | |||
| 22 | #include <cppunit/TestCase.h> | ||
| 23 | |||
| 24 | #include <unordered_map> | ||
| 25 | |||
| 26 | extern int sGenerateAX; | ||
| 27 | |||
| 28 | namespace unittest_util | ||
| 29 | { | ||
| 30 | |||
| 31 | std::string loadText(const std::string& codeFileName); | ||
| 32 | |||
| 33 | bool wrapExecution(openvdb::points::PointDataGrid& grid, | ||
| 34 | const std::string& codeFileName, | ||
| 35 | const std::string * const group, | ||
| 36 | openvdb::ax::Logger& logger, | ||
| 37 | const openvdb::ax::CustomData::Ptr& data, | ||
| 38 | const openvdb::ax::CompilerOptions& opts, | ||
| 39 | const bool createMissing); | ||
| 40 | |||
| 41 | bool wrapExecution(openvdb::GridPtrVec& grids, | ||
| 42 | const std::string& codeFileName, | ||
| 43 | openvdb::ax::Logger& logger, | ||
| 44 | const openvdb::ax::CustomData::Ptr& data, | ||
| 45 | const openvdb::ax::CompilerOptions& opts, | ||
| 46 | const bool createMissing); | ||
| 47 | |||
| 48 | /// @brief Structure for wrapping up most of the existing integration | ||
| 49 | /// tests with a simple interface | ||
| 50 | struct AXTestHarness | ||
| 51 | { | ||
| 52 | |||
| 53 | 147 | AXTestHarness() : | |
| 54 | mInputPointGrids() | ||
| 55 | , mOutputPointGrids() | ||
| 56 | , mInputSparseVolumeGrids() | ||
| 57 | , mInputDenseVolumeGrids() | ||
| 58 | , mOutputSparseVolumeGrids() | ||
| 59 | , mOutputDenseVolumeGrids() | ||
| 60 | , mUseVolumes(true) | ||
| 61 | , mUseSparseVolumes(true) | ||
| 62 | , mUseDenseVolumes(true) | ||
| 63 | , mUsePoints(true) | ||
| 64 | , mVolumeBounds({0,0,0},{7,7,7}) | ||
| 65 | , mSparseVolumeConfig({ | ||
| 66 | {1, { openvdb::Coord(-7), openvdb::Coord(-15)}}, // 2 leaf level tiles | ||
| 67 | {2, { openvdb::Coord(0) }} // 1 leaf parent tiles (4k leaf level tiles) | ||
| 68 | }) | ||
| 69 | , mOpts(openvdb::ax::CompilerOptions()) | ||
| 70 |
1/2✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
|
294 | , mCustomData(openvdb::ax::CustomData::create()) |
| 71 | , mErrors() | ||
| 72 |
11/30✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 147 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 147 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 294 times.
✓ Branch 11 taken 147 times.
✓ Branch 12 taken 294 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 147 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 147 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 147 times.
✗ Branch 20 not taken.
✓ Branch 24 taken 147 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 147 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
|
1486 | , mLogger([this](const std::string& msg) { this->mErrors += msg; } ) |
| 73 | { | ||
| 74 |
1/2✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
|
147 | reset(); |
| 75 | 147 | } | |
| 76 | |||
| 77 | void addInputGroups(const std::vector<std::string>& names, const std::vector<bool>& defaults); | ||
| 78 | void addExpectedGroups(const std::vector<std::string>& names, const std::vector<bool>& defaults); | ||
| 79 | |||
| 80 | /// @brief adds attributes to input data set | ||
| 81 | template <typename T> | ||
| 82 | 1476 | void addInputAttributes(const std::vector<std::string>& names, | |
| 83 | const std::vector<T>& values) | ||
| 84 | { | ||
| 85 |
2/2✓ Branch 0 taken 737 times.
✓ Branch 1 taken 1 times.
|
1476 | if (mUsePoints) addInputPtAttributes<T>(names, values); |
| 86 |
4/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 735 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
|
1476 | if (mUseSparseVolumes || mUseDenseVolumes) addInputVolumes(names, values); |
| 87 | 1476 | } | |
| 88 | |||
| 89 | template <typename T> | ||
| 90 | 1 | void addInputAttribute(const std::string& name, const T& inputVal) | |
| 91 | { | ||
| 92 |
7/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
2 | addInputAttributes<T>({name}, {inputVal}); |
| 93 | 1 | } | |
| 94 | |||
| 95 | /// @brief adds attributes to expected output data sets | ||
| 96 | template <typename T> | ||
| 97 | 1495 | void addExpectedAttributes(const std::vector<std::string>& names, | |
| 98 | const std::vector<T>& values) | ||
| 99 | { | ||
| 100 |
2/2✓ Branch 0 taken 748 times.
✓ Branch 1 taken 1 times.
|
1495 | if (mUsePoints) addExpectedPtAttributes<T>(names, values); |
| 101 |
4/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 746 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
|
1495 | if (mUseSparseVolumes || mUseDenseVolumes) addExpectedVolumes<T>(names, values); |
| 102 | 1495 | } | |
| 103 | |||
| 104 | /// @brief adds attributes to both input and expected data | ||
| 105 | template <typename T> | ||
| 106 |
1/2✓ Branch 0 taken 737 times.
✗ Branch 1 not taken.
|
1474 | void addAttributes(const std::vector<std::string>& names, |
| 107 | const std::vector<T>& inputValues, | ||
| 108 | const std::vector<T>& expectedValues) | ||
| 109 | { | ||
| 110 |
2/4✓ Branch 0 taken 737 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 737 times.
|
1474 | if (inputValues.size() != expectedValues.size() || |
| 111 | inputValues.size() != names.size()) { | ||
| 112 | ✗ | throw std::runtime_error("bad unittest setup - input/expected value counts don't match"); | |
| 113 | } | ||
| 114 | 1474 | addInputAttributes(names, inputValues); | |
| 115 | 1474 | addExpectedAttributes(names, expectedValues); | |
| 116 | 1474 | } | |
| 117 | |||
| 118 | /// @brief adds attributes to both input and expected data, with input data set to 0 values | ||
| 119 | template <typename T> | ||
| 120 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
210 | void addAttributes(const std::vector<std::string>& names, |
| 121 | const std::vector<T>& expectedValues) | ||
| 122 | { | ||
| 123 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
218 | std::vector<T> zeroVals(expectedValues.size(), openvdb::zeroVal<T>()); |
| 124 |
1/2✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
|
210 | addAttributes(names, zeroVals, expectedValues); |
| 125 | 210 | } | |
| 126 | |||
| 127 | template <typename T> | ||
| 128 | 1206 | void addAttribute(const std::string& name, const T& inVal, const T& expVal) | |
| 129 | { | ||
| 130 |
19/35✓ Branch 1 taken 597 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 597 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 597 times.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 597 times.
✓ Branch 11 taken 6 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 597 times.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 597 times.
✓ Branch 17 taken 603 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 569 times.
✓ Branch 20 taken 6 times.
✓ Branch 21 taken 575 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 6 times.
✓ Branch 25 taken 6 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 6 times.
✓ Branch 29 taken 6 times.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
|
3574 | addAttributes<T>({name}, {inVal}, {expVal}); |
| 131 | 1206 | } | |
| 132 | |||
| 133 | template <typename T> | ||
| 134 | 471 | void addAttribute(const std::string& name, const T& expVal) | |
| 135 | { | ||
| 136 |
80/160✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 13 taken 10 times.
✗ Branch 14 not taken.
✓ Branch 17 taken 8 times.
✗ Branch 18 not taken.
✓ Branch 21 taken 8 times.
✗ Branch 22 not taken.
✓ Branch 25 taken 7 times.
✗ Branch 26 not taken.
✓ Branch 29 taken 4 times.
✗ Branch 30 not taken.
✓ Branch 33 taken 4 times.
✗ Branch 34 not taken.
✓ Branch 37 taken 4 times.
✗ Branch 38 not taken.
✓ Branch 41 taken 4 times.
✗ Branch 42 not taken.
✓ Branch 45 taken 4 times.
✗ Branch 46 not taken.
✓ Branch 49 taken 4 times.
✗ Branch 50 not taken.
✓ Branch 53 taken 4 times.
✗ Branch 54 not taken.
✓ Branch 57 taken 4 times.
✗ Branch 58 not taken.
✓ Branch 61 taken 4 times.
✗ Branch 62 not taken.
✓ Branch 65 taken 4 times.
✗ Branch 66 not taken.
✓ Branch 69 taken 4 times.
✗ Branch 70 not taken.
✓ Branch 73 taken 4 times.
✗ Branch 74 not taken.
✓ Branch 77 taken 3 times.
✗ Branch 78 not taken.
✓ Branch 81 taken 3 times.
✗ Branch 82 not taken.
✓ Branch 85 taken 3 times.
✗ Branch 86 not taken.
✓ Branch 89 taken 3 times.
✗ Branch 90 not taken.
✓ Branch 93 taken 3 times.
✗ Branch 94 not taken.
✓ Branch 97 taken 3 times.
✗ Branch 98 not taken.
✓ Branch 101 taken 3 times.
✗ Branch 102 not taken.
✓ Branch 105 taken 3 times.
✗ Branch 106 not taken.
✓ Branch 109 taken 3 times.
✗ Branch 110 not taken.
✓ Branch 113 taken 3 times.
✗ Branch 114 not taken.
✓ Branch 117 taken 3 times.
✗ Branch 118 not taken.
✓ Branch 121 taken 3 times.
✗ Branch 122 not taken.
✓ Branch 125 taken 3 times.
✗ Branch 126 not taken.
✓ Branch 129 taken 3 times.
✗ Branch 130 not taken.
✓ Branch 133 taken 3 times.
✗ Branch 134 not taken.
✓ Branch 137 taken 2 times.
✗ Branch 138 not taken.
✓ Branch 141 taken 2 times.
✗ Branch 142 not taken.
✓ Branch 145 taken 2 times.
✗ Branch 146 not taken.
✓ Branch 149 taken 2 times.
✗ Branch 150 not taken.
✓ Branch 153 taken 2 times.
✗ Branch 154 not taken.
✓ Branch 157 taken 2 times.
✗ Branch 158 not taken.
✓ Branch 161 taken 2 times.
✗ Branch 162 not taken.
✓ Branch 165 taken 2 times.
✗ Branch 166 not taken.
✓ Branch 169 taken 2 times.
✗ Branch 170 not taken.
✓ Branch 173 taken 2 times.
✗ Branch 174 not taken.
✓ Branch 177 taken 2 times.
✗ Branch 178 not taken.
✓ Branch 181 taken 2 times.
✗ Branch 182 not taken.
✓ Branch 185 taken 2 times.
✗ Branch 186 not taken.
✓ Branch 189 taken 2 times.
✗ Branch 190 not taken.
✓ Branch 193 taken 2 times.
✗ Branch 194 not taken.
✓ Branch 197 taken 2 times.
✗ Branch 198 not taken.
✓ Branch 201 taken 2 times.
✗ Branch 202 not taken.
✓ Branch 205 taken 2 times.
✗ Branch 206 not taken.
✓ Branch 209 taken 2 times.
✗ Branch 210 not taken.
✓ Branch 213 taken 2 times.
✗ Branch 214 not taken.
✓ Branch 217 taken 2 times.
✗ Branch 218 not taken.
✓ Branch 221 taken 2 times.
✗ Branch 222 not taken.
✓ Branch 225 taken 2 times.
✗ Branch 226 not taken.
✓ Branch 229 taken 2 times.
✗ Branch 230 not taken.
✓ Branch 233 taken 2 times.
✗ Branch 234 not taken.
✓ Branch 237 taken 2 times.
✗ Branch 238 not taken.
✓ Branch 241 taken 2 times.
✗ Branch 242 not taken.
✓ Branch 245 taken 2 times.
✗ Branch 246 not taken.
✓ Branch 249 taken 2 times.
✗ Branch 250 not taken.
✓ Branch 253 taken 2 times.
✗ Branch 254 not taken.
✓ Branch 257 taken 2 times.
✗ Branch 258 not taken.
✓ Branch 261 taken 2 times.
✗ Branch 262 not taken.
✓ Branch 265 taken 2 times.
✗ Branch 266 not taken.
✓ Branch 269 taken 2 times.
✗ Branch 270 not taken.
✓ Branch 273 taken 2 times.
✗ Branch 274 not taken.
✓ Branch 277 taken 2 times.
✗ Branch 278 not taken.
✓ Branch 281 taken 2 times.
✗ Branch 282 not taken.
✓ Branch 285 taken 2 times.
✗ Branch 286 not taken.
✓ Branch 289 taken 2 times.
✗ Branch 290 not taken.
✓ Branch 293 taken 2 times.
✗ Branch 294 not taken.
✓ Branch 297 taken 2 times.
✗ Branch 298 not taken.
✓ Branch 301 taken 2 times.
✗ Branch 302 not taken.
✓ Branch 305 taken 2 times.
✗ Branch 306 not taken.
✓ Branch 309 taken 2 times.
✗ Branch 310 not taken.
✓ Branch 313 taken 2 times.
✗ Branch 314 not taken.
✓ Branch 317 taken 1 times.
✗ Branch 318 not taken.
|
720 | addAttribute<T>(name, openvdb::zeroVal<T>(), expVal); |
| 137 | 471 | } | |
| 138 | |||
| 139 | template <typename T> | ||
| 140 | 8 | void addExpectedAttribute(const std::string& name, const T& expVal) | |
| 141 | { | ||
| 142 |
7/16✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 4 times.
✓ Branch 14 taken 4 times.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
16 | addExpectedAttributes<T>({name}, {expVal}); |
| 143 | 8 | } | |
| 144 | |||
| 145 | /// @brief excecutes a snippet of code contained in a file to the input data sets | ||
| 146 | bool executeCode(const std::string& codeFile, | ||
| 147 | const std::string* const group = nullptr, | ||
| 148 | const bool createMissing = false); | ||
| 149 | |||
| 150 | /// @brief rebuilds the input and output data sets to their default harness states. This | ||
| 151 | /// sets the bounds of volumes to a single voxel, with a single and four point grid | ||
| 152 | void reset(); | ||
| 153 | |||
| 154 | /// @brief reset the input data to a set amount of points per voxel within a given bounds | ||
| 155 | /// @note The bounds is also used to fill the volume data of numerical vdb volumes when | ||
| 156 | /// calls to addAttribute functions are made, where as points have their positions | ||
| 157 | /// generated here | ||
| 158 | void reset(const openvdb::Index64, const openvdb::CoordBBox&); | ||
| 159 | |||
| 160 | /// @brief reset all grids without changing the harness data. This has the effect of zeroing | ||
| 161 | /// out all volume voxel data and point data attributes (except for position) without | ||
| 162 | /// changing the number of points or voxels | ||
| 163 | void resetInputsToZero(); | ||
| 164 | |||
| 165 | /// @brief compares the input and expected point grids and outputs a report of differences to | ||
| 166 | /// the provided stream | ||
| 167 | bool checkAgainstExpected(std::ostream& sstream); | ||
| 168 | |||
| 169 | /// @brief clears the errors and logger | ||
| 170 | void clear() { | ||
| 171 | 1719 | mErrors.clear(); | |
| 172 |
1/4✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1719 | mLogger.clear(); |
| 173 | 278 | } | |
| 174 | |||
| 175 | const std::string& errors() const { | ||
| 176 |
1/2✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
|
206 | return mErrors; |
| 177 | } | ||
| 178 | /// @brief Toggle whether to execute tests for points or volumes | ||
| 179 | void testVolumes(const bool); | ||
| 180 | void testSparseVolumes(const bool); | ||
| 181 | void testDenseVolumes(const bool); | ||
| 182 | void testPoints(const bool); | ||
| 183 | |||
| 184 | template <typename T> | ||
| 185 | void addInputPtAttributes(const std::vector<std::string>& names, const std::vector<T>& values); | ||
| 186 | |||
| 187 | template <typename T> | ||
| 188 | void addInputVolumes(const std::vector<std::string>& names, const std::vector<T>& values); | ||
| 189 | |||
| 190 | template <typename T> | ||
| 191 | void addExpectedPtAttributes(const std::vector<std::string>& names, const std::vector<T>& values); | ||
| 192 | |||
| 193 | template <typename T> | ||
| 194 | void addExpectedVolumes(const std::vector<std::string>& names, const std::vector<T>& values); | ||
| 195 | |||
| 196 | std::vector<openvdb::points::PointDataGrid::Ptr> mInputPointGrids; | ||
| 197 | std::vector<openvdb::points::PointDataGrid::Ptr> mOutputPointGrids; | ||
| 198 | |||
| 199 | openvdb::GridPtrVec mInputSparseVolumeGrids; | ||
| 200 | openvdb::GridPtrVec mInputDenseVolumeGrids; | ||
| 201 | openvdb::GridPtrVec mOutputSparseVolumeGrids; | ||
| 202 | openvdb::GridPtrVec mOutputDenseVolumeGrids; | ||
| 203 | |||
| 204 | bool mUseVolumes; | ||
| 205 | bool mUseSparseVolumes; | ||
| 206 | bool mUseDenseVolumes; | ||
| 207 | bool mUsePoints; | ||
| 208 | openvdb::CoordBBox mVolumeBounds; | ||
| 209 | std::map<openvdb::Index, std::vector<openvdb::Coord>> mSparseVolumeConfig; | ||
| 210 | |||
| 211 | openvdb::ax::CompilerOptions mOpts; | ||
| 212 | openvdb::ax::CustomData::Ptr mCustomData; | ||
| 213 | std::string mErrors; | ||
| 214 | openvdb::ax::Logger mLogger; | ||
| 215 | }; | ||
| 216 | |||
| 217 | class AXTestCase : public CppUnit::TestCase | ||
| 218 | { | ||
| 219 | public: | ||
| 220 | 146 | void tearDown() override | |
| 221 | { | ||
| 222 | std::string out; | ||
| 223 |
2/2✓ Branch 0 taken 129 times.
✓ Branch 1 taken 146 times.
|
275 | for (auto& test : mTestFiles) { |
| 224 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
129 | if (!test.second) out += test.first + "\n"; |
| 225 | } | ||
| 226 |
7/14✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 146 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 146 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 146 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 146 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 146 times.
✗ Branch 20 not taken.
|
292 | CPPUNIT_ASSERT_MESSAGE("unused tests left in test case:\n" + out, |
| 227 | out.empty()); | ||
| 228 | 146 | } | |
| 229 | |||
| 230 | // @todo make pure | ||
| 231 | ✗ | virtual std::string dir() const { return ""; } | |
| 232 | |||
| 233 | /// @brief Register an AX code snippet with this test. If the tests | ||
| 234 | /// have been launched with -g, the code is also serialized | ||
| 235 | /// into the test directory | ||
| 236 |
1/2✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
|
129 | void registerTest(const std::string& code, |
| 237 | const std::string& filename, | ||
| 238 | const std::ios_base::openmode flags = std::ios_base::out) | ||
| 239 | { | ||
| 240 |
1/2✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
|
129 | if (flags & std::ios_base::out) { |
| 241 |
7/14✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 129 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 129 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 129 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 129 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 129 times.
✗ Branch 20 not taken.
|
387 | CPPUNIT_ASSERT_MESSAGE( |
| 242 | "duplicate test file found during test setup:\n" + filename, | ||
| 243 | mTestFiles.find(filename) == mTestFiles.end()); | ||
| 244 | 129 | mTestFiles[filename] = false; | |
| 245 | } | ||
| 246 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
|
129 | if (flags & std::ios_base::app) { |
| 247 | ✗ | CPPUNIT_ASSERT_MESSAGE( | |
| 248 | "test not found during ofstream append:\n" + filename, | ||
| 249 | mTestFiles.find(filename) != mTestFiles.end()); | ||
| 250 | } | ||
| 251 | |||
| 252 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
|
129 | if (sGenerateAX) { |
| 253 | ✗ | std::ofstream outfile; | |
| 254 | ✗ | outfile.open(this->dir() + "/" + filename, flags); | |
| 255 | outfile << code << std::endl; | ||
| 256 | ✗ | outfile.close(); | |
| 257 | } | ||
| 258 | 129 | } | |
| 259 | |||
| 260 | template <typename ...Args> | ||
| 261 | 148 | void execute(const std::string& filename, Args&&... args) | |
| 262 | { | ||
| 263 |
9/18✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 148 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 148 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 148 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 148 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 148 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 148 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 148 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 148 times.
✗ Branch 26 not taken.
|
444 | CPPUNIT_ASSERT_MESSAGE( |
| 264 | "test not found during execution:\n" + this->dir() + "/" + filename, | ||
| 265 | mTestFiles.find(filename) != mTestFiles.end()); | ||
| 266 | 148 | mTestFiles[filename] = true; // has been used | |
| 267 | |||
| 268 | // execute | ||
| 269 |
2/4✓ Branch 2 taken 148 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 148 times.
✗ Branch 6 not taken.
|
444 | const bool success = mHarness.executeCode(this->dir() + "/" + filename, args...); |
| 270 |
8/16✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 148 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 148 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 148 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 148 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 148 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 148 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 148 times.
✗ Branch 23 not taken.
|
296 | CPPUNIT_ASSERT_MESSAGE("error thrown during test: " + filename + "\n" + mHarness.errors(), |
| 271 | success); | ||
| 272 | |||
| 273 | // check | ||
| 274 | 148 | std::stringstream out; | |
| 275 |
1/2✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
|
148 | const bool correct = mHarness.checkAgainstExpected(out); |
| 276 | //CPPUNIT_ASSERT(correct); | ||
| 277 |
6/12✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 148 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 148 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 148 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 148 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 148 times.
✗ Branch 17 not taken.
|
296 | CPPUNIT_ASSERT_MESSAGE(out.str(), correct); |
| 278 | 148 | } | |
| 279 | |||
| 280 | protected: | ||
| 281 | AXTestHarness mHarness; | ||
| 282 | std::unordered_map<std::string, bool> mTestFiles; | ||
| 283 | }; | ||
| 284 | |||
| 285 | } // namespace unittest_util | ||
| 286 | |||
| 287 | |||
| 288 | #define GET_TEST_DIRECTORY() \ | ||
| 289 | std::string(__FILE__).substr(0, std::string(__FILE__).find_last_of('.')); \ | ||
| 290 | |||
| 291 | #define AXTESTS_STANDARD_ASSERT_HARNESS(harness) \ | ||
| 292 | { std::stringstream out; \ | ||
| 293 | const bool correct = harness.checkAgainstExpected(out); \ | ||
| 294 | CPPUNIT_ASSERT_MESSAGE(out.str(), correct); } | ||
| 295 | |||
| 296 | #define AXTESTS_STANDARD_ASSERT() \ | ||
| 297 | AXTESTS_STANDARD_ASSERT_HARNESS(mHarness); | ||
| 298 | |||
| 299 | #endif // OPENVDB_POINTS_UNITTEST_TEST_HARNESS_INCLUDED | ||
| 300 | |||
| 301 |