Branch data Line data Source code
1 : : /**
2 : : * @file: point_sources_test.cxx
3 : : * @brief: unit tests to test PDT-SPACE with point sources.
4 : : * Runs PDT-SPACE with point sources and compares the result with pre-computed golden results.
5 : : *
6 : : * @author: Shuran Wang
7 : : * @date: July 22, 2020
8 : : */
9 : :
10 : : #include "gtest/gtest.h"
11 : : #include "pdt_plan.h"
12 : : #include "test_common.h"
13 : :
14 : : #include <vector>
15 : :
16 : : #define POINT_SOURCES_PARAMS_FILE "/unit-tests/input_params/tumor4_params_630nm_point.xml"
17 : : #define POINT_SOURCES_GOLDEN_V100 "/unit-tests/golden_results/point_sources_v100.txt"
18 : : #define POINT_SOURCES_GOLDEN_FLUENCE "/unit-tests/golden_results/point_sources_final_fluence.txt"
19 : :
20 [ + - ][ + - ]: 32 : GTEST_TEST(PowerAllocationTests, PointSourcesTest)
[ + - ][ - + ]
21 : : {
22 : : /** Run PDT_SPACE */
23 [ + - ][ + - ]: 4 : pdt_plan* plan = new pdt_plan(string(PDT_SPACE_SRC_DIR) + POINT_SOURCES_PARAMS_FILE);
[ + - ][ + - ]
24 : :
25 [ + - ]: 8 : vector<double> v_alpha = run_pdt_space(plan);
26 : :
27 : : // Get final fluence
28 [ + - ][ + - ]: 8 : vector<double> final_fluence = plan->get_final_fluence();
29 : :
30 : : /** Compare Results */
31 : : // Compute v100 average error
32 [ + - ][ + - ]: 8 : vector<double> golden_v100 = readGoldenResult (string(PDT_SPACE_SRC_DIR) + POINT_SOURCES_GOLDEN_V100);
[ + - ]
33 : :
34 [ + - ][ + - ]: 4 : compare_results (golden_v100, v_alpha, 0.05, "v100");
[ + - ][ + - ]
35 : :
36 : : // Compute fluence average error
37 [ + - ][ + - ]: 8 : vector<double> golden_fluence = readGoldenResult (string(PDT_SPACE_SRC_DIR) + POINT_SOURCES_GOLDEN_FLUENCE);
[ + - ]
38 : :
39 [ + - ][ + - ]: 4 : compare_results (golden_fluence, final_fluence, 0.05, "fluence");
[ + - ][ + - ]
40 : :
41 [ + - ]: 4 : delete plan;
42 [ + - ][ + - ]: 20 : }
|