@@ -18,6 +18,8 void TestDataSeriesUtils::testFillDataHoles_data() | |||
|
18 | 18 | QTest::addColumn<std::vector<double> >("valuesData"); |
|
19 | 19 | QTest::addColumn<double>("resolution"); |
|
20 | 20 | QTest::addColumn<double>("fillValue"); |
|
21 | QTest::addColumn<double>("minBound"); | |
|
22 | QTest::addColumn<double>("maxBound"); | |
|
21 | 23 | QTest::addColumn<std::vector<double> >( |
|
22 | 24 | "expectedXAxisData"); // expected x-axis data after filling holes |
|
23 | 25 | QTest::addColumn<std::vector<double> >( |
@@ -27,34 +29,50 void TestDataSeriesUtils::testFillDataHoles_data() | |||
|
27 | 29 | |
|
28 | 30 | QTest::newRow("fillDataHoles (basic case)") |
|
29 | 31 | << std::vector<double>{0., 1., 5., 7., 14.} << std::vector<double>{0., 1., 2., 3., 4.} << 2. |
|
30 | << nan << std::vector<double>{0., 1., 3., 5., 7., 9., 11., 13., 14.} | |
|
32 | << nan << nan << nan << std::vector<double>{0., 1., 3., 5., 7., 9., 11., 13., 14.} | |
|
31 | 33 | << std::vector<double>{0., 1., nan, 2., 3., nan, nan, nan, 4.}; |
|
32 | 34 | |
|
33 | 35 | QTest::newRow("fillDataHoles (change nb components)") |
|
34 | 36 | << std::vector<double>{0., 1., 5., 7., 14.} |
|
35 | << std::vector<double>{0., 1., 2., 3., 4., 5., 6., 7., 8., 9.} << 2. << nan | |
|
37 | << std::vector<double>{0., 1., 2., 3., 4., 5., 6., 7., 8., 9.} << 2. << nan << nan << nan | |
|
36 | 38 | << std::vector<double>{0., 1., 3., 5., 7., 9., 11., 13., 14.} |
|
37 | 39 | << std::vector<double>{0., 1., 2., 3., nan, nan, 4., 5., 6., |
|
38 | 40 | 7., nan, nan, nan, nan, nan, nan, 8., 9.}; |
|
39 | 41 | |
|
40 | 42 | QTest::newRow("fillDataHoles (change resolution)") |
|
41 | 43 | << std::vector<double>{0., 1., 5., 7., 14.} << std::vector<double>{0., 1., 2., 3., 4.} |
|
42 | << 1.5 << nan << std::vector<double>{0., 1., 2.5, 4., 5., 6.5, 7., 8.5, 10., 11.5, 13., 14.} | |
|
44 | << 1.5 << nan << nan << nan | |
|
45 | << std::vector<double>{0., 1., 2.5, 4., 5., 6.5, 7., 8.5, 10., 11.5, 13., 14.} | |
|
43 | 46 | << std::vector<double>{0., 1., nan, nan, 2., nan, 3., nan, nan, nan, nan, 4.}; |
|
44 | 47 | |
|
45 | 48 | QTest::newRow("fillDataHoles (with no data (no changes made))") |
|
46 |
<< std::vector<double>{} << std::vector<double>{} << 2. << nan << |
|
|
47 | << std::vector<double>{}; | |
|
49 | << std::vector<double>{} << std::vector<double>{} << 2. << nan << nan << nan | |
|
50 | << std::vector<double>{} << std::vector<double>{}; | |
|
48 | 51 | |
|
49 | 52 | QTest::newRow("fillDataHoles (with no resolution (no changes made))") |
|
50 | 53 | << std::vector<double>{0., 1., 5., 7., 14.} << std::vector<double>{0., 1., 2., 3., 4.} << 0. |
|
51 | << nan << std::vector<double>{0., 1., 5., 7., 14.} | |
|
54 | << nan << nan << nan << std::vector<double>{0., 1., 5., 7., 14.} | |
|
52 | 55 | << std::vector<double>{0., 1., 2., 3., 4.}; |
|
53 | 56 | |
|
54 | 57 | QTest::newRow("fillDataHoles (change fill value)") |
|
55 | 58 | << std::vector<double>{0., 1., 5., 7., 14.} << std::vector<double>{0., 1., 2., 3., 4.} << 2. |
|
56 | << -1. << std::vector<double>{0., 1., 3., 5., 7., 9., 11., 13., 14.} | |
|
59 | << -1. << nan << nan << std::vector<double>{0., 1., 3., 5., 7., 9., 11., 13., 14.} | |
|
57 | 60 | << std::vector<double>{0., 1., -1., 2., 3., -1., -1., -1., 4.}; |
|
61 | ||
|
62 | QTest::newRow("fillDataHoles (add data holes to the beginning)") | |
|
63 | << std::vector<double>{5., 7., 9., 11., 13.} << std::vector<double>{0., 1., 2., 3., 4.} | |
|
64 | << 2. << nan << 0. << nan << std::vector<double>{1., 3., 5., 7., 9., 11., 13.} | |
|
65 | << std::vector<double>{nan, nan, 0., 1., 2., 3., 4.}; | |
|
66 | ||
|
67 | QTest::newRow("fillDataHoles (add data holes to the end)") | |
|
68 | << std::vector<double>{5., 7., 9., 11., 13.} << std::vector<double>{0., 1., 2., 3., 4.} | |
|
69 | << 2. << nan << nan << 21. << std::vector<double>{5., 7., 9., 11., 13., 15., 17., 19., 21.} | |
|
70 | << std::vector<double>{0., 1., 2., 3., 4., nan, nan, nan, nan}; | |
|
71 | ||
|
72 | QTest::newRow("fillDataHoles (invalid min/max bounds (no changes made))") | |
|
73 | << std::vector<double>{5., 7., 9., 11., 13.} << std::vector<double>{0., 1., 2., 3., 4.} | |
|
74 | << 2. << nan << 8. << 13. << std::vector<double>{5., 7., 9., 11., 13.} | |
|
75 | << std::vector<double>{0., 1., 2., 3., 4.}; | |
|
58 | 76 | } |
|
59 | 77 | |
|
60 | 78 | void TestDataSeriesUtils::testFillDataHoles() |
@@ -63,12 +81,15 void TestDataSeriesUtils::testFillDataHoles() | |||
|
63 | 81 | QFETCH(std::vector<double>, valuesData); |
|
64 | 82 | QFETCH(double, resolution); |
|
65 | 83 | QFETCH(double, fillValue); |
|
84 | QFETCH(double, minBound); | |
|
85 | QFETCH(double, maxBound); | |
|
66 | 86 | |
|
67 | 87 | QFETCH(std::vector<double>, expectedXAxisData); |
|
68 | 88 | QFETCH(std::vector<double>, expectedValuesData); |
|
69 | 89 | |
|
70 | 90 | // Executes method (xAxisData and valuesData are modified) |
|
71 |
DataSeriesUtils::fillDataHoles(xAxisData, valuesData, resolution, fillValue |
|
|
91 | DataSeriesUtils::fillDataHoles(xAxisData, valuesData, resolution, fillValue, minBound, | |
|
92 | maxBound); | |
|
72 | 93 | |
|
73 | 94 | // Checks results |
|
74 | 95 | auto equal = [](const auto &data, const auto &expectedData) { |
General Comments 0
You need to be logged in to leave comments.
Login now