BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
customplot_test_utils.test.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/tests/testview/customplot_test_utils.test.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #include "customplot_test_utils.h"
16 #include "google_test.h"
17 #include "qcustomplot.h"
18 
19 using namespace ModelView;
20 
21 //! Testing "utilr for testing" defined in TestUtils namespace.
22 
23 class CustomplotTestUtilsTest : public ::testing::Test {
24 public:
26 };
27 
29 
30 //! Check methods to access graph bin centers and values.
31 
32 TEST_F(CustomplotTestUtilsTest, binCentersbinValues)
33 {
34  QCustomPlot custom_plot;
35 
36  auto graph = custom_plot.addGraph();
37  graph->setData(QVector<double>({1, 2, 3}), QVector<double>({10, 20, 30}));
38 
39  EXPECT_EQ(TestUtils::binCenters(graph), std::vector<double>({1, 2, 3}));
40  EXPECT_EQ(TestUtils::binValues(graph), std::vector<double>({10, 20, 30}));
41 }
42 
43 //! Check methods to access graph errors.
44 
46 {
47  QCustomPlot custom_plot;
48 
49  auto graph = custom_plot.addGraph();
50  graph->setData(QVector<double>({1, 2, 3}), QVector<double>({10, 20, 30}));
51 
52  EXPECT_EQ(TestUtils::binErrors(graph), std::vector<double>());
53 
54  QCPErrorBars* errorBars = new QCPErrorBars(custom_plot.xAxis, custom_plot.yAxis);
55  errorBars->removeFromLegend();
56  errorBars->setDataPlottable(graph);
57  errorBars->setData(QVector<double>({0.1, 0.2, 0.3}));
58 
59  EXPECT_EQ(TestUtils::binErrors(graph), std::vector<double>({0.1, 0.2, 0.3}));
60 }
Testing "utilr for testing" defined in TestUtils namespace.
Defines class CLASS?
TEST_F(CustomplotTestUtilsTest, binCentersbinValues)
Check methods to access graph bin centers and values.
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
std::vector< double > binValues(const QCPGraph *graph)
Returns vector representing y-values on QCPgraph.
std::vector< double > binErrors(const QCPGraph *graph)
Returns vector representing bin errors of QCPGraph.
std::vector< double > binCenters(const QCPGraph *graph)
Returns vector representing bin centers on QCPgraph.