##// END OF EJS Templates
Unit tests (1)...
Alexandre Leroux -
r864:05c98ddf38b8
parent child
Show More
@@ -0,0 +1,90
1 #include "DataSeriesBuilders.h"
2
3 #include <Data/ScalarSeries.h>
4 #include <Data/SpectrogramSeries.h>
5 #include <Data/VectorSeries.h>
6 #include <Data/Unit.h>
7
8 // ///////////// //
9 // ScalarBuilder //
10 // ///////////// //
11
12 ScalarBuilder &ScalarBuilder::setX(std::vector<double> xData)
13 {
14 m_XAxisData = std::move(xData);
15 return *this;
16 }
17
18 ScalarBuilder &ScalarBuilder::setValues(std::vector<double> valuesData)
19 {
20 m_ValuesData =std::move(valuesData);
21 return *this;
22 }
23
24 std::shared_ptr<ScalarSeries> ScalarBuilder::build()
25 {
26 return std::make_shared<ScalarSeries>(std::move(m_XAxisData), std::move(m_ValuesData), Unit{},
27 Unit{});
28 }
29
30 // ////////////////// //
31 // SpectrogramBuilder //
32 // ////////////////// //
33
34 SpectrogramBuilder &SpectrogramBuilder::setX(std::vector<double> xData)
35 {
36 m_XAxisData = std::move(xData);
37 return *this;
38 }
39
40 SpectrogramBuilder &SpectrogramBuilder::setY(std::vector<double> yData)
41 {
42 m_YAxisData =std::move(yData);
43 return *this;
44 }
45
46 SpectrogramBuilder &SpectrogramBuilder::setValues(std::vector<double> valuesData)
47 {
48 m_ValuesData =std::move(valuesData);
49 return *this;
50 }
51
52 std::shared_ptr<SpectrogramSeries> SpectrogramBuilder::build()
53 {
54 return std::make_shared<SpectrogramSeries>(std::move(m_XAxisData), std::move(m_YAxisData), std::move(m_ValuesData), Unit{},
55 Unit{}, Unit{});
56 }
57
58 // ///////////// //
59 // VectorBuilder //
60 // ///////////// //
61
62 VectorBuilder &VectorBuilder::setX(std::vector<double> xData)
63 {
64 m_XAxisData = std::move(xData);
65 return *this;
66 }
67
68 VectorBuilder &VectorBuilder::setXValues(std::vector<double> xValuesData)
69 {
70 m_XValuesData =std::move(xValuesData);
71 return *this;
72 }
73
74 VectorBuilder &VectorBuilder::setYValues(std::vector<double> yValuesData)
75 {
76 m_YValuesData =std::move(yValuesData);
77 return *this;
78 }
79
80 VectorBuilder &VectorBuilder::setZValues(std::vector<double> zValuesData)
81 {
82 m_ZValuesData =std::move(zValuesData);
83 return *this;
84 }
85
86 std::shared_ptr<VectorSeries> VectorBuilder::build()
87 {
88 return std::make_shared<VectorSeries>(std::move(m_XAxisData), std::move(m_XValuesData), std::move(m_YValuesData), std::move(m_ZValuesData), Unit{},
89 Unit{});
90 }
@@ -0,0 +1,74
1 #ifndef SCIQLOP_DATASERIESBUILDERS_H
2 #define SCIQLOP_DATASERIESBUILDERS_H
3
4 #include <memory>
5 #include <vector>
6
7 class ScalarSeries;
8 class SpectrogramSeries;
9 class VectorSeries;
10
11 /**
12 * @brief The ScalarBuilder class aims to facilitate the creation of a ScalarSeries for unit tests
13 * @sa ScalarSeries
14 */
15 class ScalarBuilder {
16 public:
17 /// Sets x-axis data of the series
18 ScalarBuilder & setX(std::vector<double> xData);
19 /// Sets values data of the series
20 ScalarBuilder & setValues(std::vector<double> valuesData);
21 /// Creates the series
22 std::shared_ptr<ScalarSeries> build();
23
24 private:
25 std::vector<double> m_XAxisData{};
26 std::vector<double> m_ValuesData{};
27 };
28
29 /**
30 * @brief The SpectrogramBuilder class aims to facilitate the creation of a SpectrogramSeries for unit tests
31 * @sa SpectrogramSeries
32 */
33 class SpectrogramBuilder {
34 public:
35 /// Sets x-axis data of the series
36 SpectrogramBuilder & setX(std::vector<double> xData);
37 /// Sets y-axis data of the series
38 SpectrogramBuilder & setY(std::vector<double> yData);
39 /// Sets values data of the series
40 SpectrogramBuilder & setValues(std::vector<double> valuesData);
41 /// Creates the series
42 std::shared_ptr<SpectrogramSeries> build();
43
44 private:
45 std::vector<double> m_XAxisData{};
46 std::vector<double> m_YAxisData{};
47 std::vector<double> m_ValuesData{};
48 };
49
50 /**
51 * @brief The VectorBuilder class aims to facilitate the creation of a VectorSeries for unit tests
52 * @sa VectorSeries
53 */
54 class VectorBuilder {
55 public:
56 /// Sets x-axis data of the series
57 VectorBuilder & setX(std::vector<double> xData);
58 /// Sets x-values data of the series
59 VectorBuilder & setXValues(std::vector<double> xValuesData);
60 /// Sets y-values data of the series
61 VectorBuilder & setYValues(std::vector<double> yValuesData);
62 /// Sets z-values data of the series
63 VectorBuilder & setZValues(std::vector<double> zValuesData);
64 /// Creates the series
65 std::shared_ptr<VectorSeries> build();
66
67 private:
68 std::vector<double> m_XAxisData{};
69 std::vector<double> m_XValuesData{};
70 std::vector<double> m_YValuesData{};
71 std::vector<double> m_ZValuesData{};
72 };
73
74 #endif // SCIQLOP_DATASERIESBUILDERS_H
General Comments 0
You need to be logged in to leave comments. Login now