BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
axisitems.test.cpp File Reference

Implements class CLASS? More...

Include dependency graph for axisitems.test.cpp:

Go to the source code of this file.

Classes

class  AxisItemsTest
 Testing AxisItems. More...
 

Functions

 TEST_F (AxisItemsTest, fixedBinAxisFactory)
 Factory method for FixedBinAxisItem. More...
 
 TEST_F (AxisItemsTest, fixedBinAxisInitialState)
 Factory method for FixedBinAxisItem. More...
 
 TEST_F (AxisItemsTest, fixedBinAxisRange)
 Range method. More...
 
 TEST_F (AxisItemsTest, fixedBinAxisSetParameters)
 Factory method for FixedBinAxisItem. More...
 
 TEST_F (AxisItemsTest, PointwiseAxisCreate)
 
 TEST_F (AxisItemsTest, PointwiseAxisInitialState)
 
 TEST_F (AxisItemsTest, PointwiseAxisSetParameters)
 
 TEST_F (AxisItemsTest, viewportAxisInitialState)
 Initial state. More...
 
 TEST_F (AxisItemsTest, viewportAxisSetRange)
 ViewportAxisItem::setRange. More...
 

Detailed Description

Implements class CLASS?

Homepage:\n http://www.bornagainproject.org
License:\n GNU General Public License v3 or higher (see COPYING)
Authors
Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)

Definition in file axisitems.test.cpp.

Function Documentation

◆ TEST_F() [1/9]

TEST_F ( AxisItemsTest  ,
fixedBinAxisFactory   
)

Factory method for FixedBinAxisItem.

Definition at line 88 of file axisitems.test.cpp.

89 {
90  auto axis = FixedBinAxisItem::create(3, 1.0, 4.0);
91 
92  EXPECT_EQ(axis->property<int>(FixedBinAxisItem::P_NBINS), 3);
93  EXPECT_EQ(axis->property<double>(FixedBinAxisItem::P_MIN), 1.0);
94  EXPECT_EQ(axis->property<double>(FixedBinAxisItem::P_MAX), 4.0);
95 
96  std::vector<double> expected{1.5, 2.5, 3.5};
97  EXPECT_EQ(axis->binCenters(), expected);
98  EXPECT_EQ(axis->size(), 3);
99 }

References ModelView::FixedBinAxisItem::create(), ModelView::BasicAxisItem::P_MAX, ModelView::BasicAxisItem::P_MIN, and ModelView::FixedBinAxisItem::P_NBINS.

Here is the call graph for this function:

◆ TEST_F() [2/9]

TEST_F ( AxisItemsTest  ,
fixedBinAxisInitialState   
)

Factory method for FixedBinAxisItem.

Definition at line 57 of file axisitems.test.cpp.

58 {
59  FixedBinAxisItem axis;
60  EXPECT_EQ(axis.property<double>(FixedBinAxisItem::P_MIN), 0.0);
61  EXPECT_EQ(axis.property<double>(FixedBinAxisItem::P_MAX), 1.0);
62  EXPECT_EQ(axis.property<int>(FixedBinAxisItem::P_NBINS), 1);
63  EXPECT_EQ(axis.binCenters(), std::vector<double>{0.5});
64  EXPECT_EQ(axis.size(), 1);
65  auto [lower, upper] = axis.range();
66  EXPECT_EQ(lower, 0.0);
67  EXPECT_EQ(upper, 1.0);
68 }
Item to represent fixed bin axis.
Definition: axisitems.h:75
std::pair< double, double > range() const override
Definition: axisitems.cpp:88
std::vector< double > binCenters() const override
Definition: axisitems.cpp:98
int size() const override
Definition: axisitems.cpp:93
T property(const std::string &tag) const
Returns data stored in property item.
Definition: sessionitem.h:181

References ModelView::FixedBinAxisItem::binCenters(), ModelView::BasicAxisItem::P_MAX, ModelView::BasicAxisItem::P_MIN, ModelView::FixedBinAxisItem::P_NBINS, ModelView::SessionItem::property(), ModelView::FixedBinAxisItem::range(), and ModelView::FixedBinAxisItem::size().

Here is the call graph for this function:

◆ TEST_F() [3/9]

TEST_F ( AxisItemsTest  ,
fixedBinAxisRange   
)

Range method.

Definition at line 103 of file axisitems.test.cpp.

104 {
105  auto axis = FixedBinAxisItem::create(3, 1.0, 4.0);
106 
107  auto [lower, upper] = axis->range();
108  EXPECT_EQ(lower, 1.0);
109  EXPECT_EQ(upper, 4.0);
110 }

References ModelView::FixedBinAxisItem::create().

Here is the call graph for this function:

◆ TEST_F() [4/9]

TEST_F ( AxisItemsTest  ,
fixedBinAxisSetParameters   
)

Factory method for FixedBinAxisItem.

Definition at line 72 of file axisitems.test.cpp.

73 {
74  FixedBinAxisItem axis;
75  axis.setParameters(3, 1.0, 4.0);
76 
77  EXPECT_EQ(axis.property<int>(FixedBinAxisItem::P_NBINS), 3);
78  EXPECT_EQ(axis.property<double>(FixedBinAxisItem::P_MIN), 1.0);
79  EXPECT_EQ(axis.property<double>(FixedBinAxisItem::P_MAX), 4.0);
80 
81  std::vector<double> expected{1.5, 2.5, 3.5};
82  EXPECT_EQ(axis.binCenters(), expected);
83  EXPECT_EQ(axis.size(), 3);
84 }
void setParameters(int nbins, double xmin, double xmax)
Definition: axisitems.cpp:74

References ModelView::FixedBinAxisItem::binCenters(), ModelView::BasicAxisItem::P_MAX, ModelView::BasicAxisItem::P_MIN, ModelView::FixedBinAxisItem::P_NBINS, ModelView::SessionItem::property(), ModelView::FixedBinAxisItem::setParameters(), and ModelView::FixedBinAxisItem::size().

Here is the call graph for this function:

◆ TEST_F() [5/9]

TEST_F ( AxisItemsTest  ,
PointwiseAxisCreate   
)

Definition at line 129 of file axisitems.test.cpp.

130 {
131  std::vector<double> expected_centers{1.0, 2.0, 3.0};
132  auto axis = PointwiseAxisItem::create(expected_centers);
133  EXPECT_EQ(axis->binCenters(), expected_centers);
134  EXPECT_EQ(axis->size(), 3);
135 }

References ModelView::PointwiseAxisItem::create().

Here is the call graph for this function:

◆ TEST_F() [6/9]

TEST_F ( AxisItemsTest  ,
PointwiseAxisInitialState   
)

Definition at line 112 of file axisitems.test.cpp.

113 {
114  PointwiseAxisItem axis;
115  std::vector<double> expected_centers = {0.0, 1.0};
116  EXPECT_EQ(axis.binCenters(), expected_centers);
117  EXPECT_EQ(axis.size(), 2);
118 }
Item to represent pointwise axis.
Definition: axisitems.h:94
std::vector< double > binCenters() const override
Definition: axisitems.cpp:146
int size() const override
Definition: axisitems.cpp:141

References ModelView::PointwiseAxisItem::binCenters(), and ModelView::PointwiseAxisItem::size().

Here is the call graph for this function:

◆ TEST_F() [7/9]

TEST_F ( AxisItemsTest  ,
PointwiseAxisSetParameters   
)

Definition at line 120 of file axisitems.test.cpp.

121 {
122  std::vector<double> expected_centers{1.0, 2.0, 3.0};
123  PointwiseAxisItem axis;
124  axis.setParameters(expected_centers);
125  EXPECT_EQ(axis.binCenters(), expected_centers);
126  EXPECT_EQ(axis.size(), 3);
127 }
void setParameters(const std::vector< double > &data)
Definition: axisitems.cpp:122

References ModelView::PointwiseAxisItem::binCenters(), ModelView::PointwiseAxisItem::setParameters(), and ModelView::PointwiseAxisItem::size().

Here is the call graph for this function:

◆ TEST_F() [8/9]

TEST_F ( AxisItemsTest  ,
viewportAxisInitialState   
)

Initial state.

Definition at line 31 of file axisitems.test.cpp.

32 {
33  ViewportAxisItem axis;
34  EXPECT_EQ(axis.property<double>(ViewportAxisItem::P_MIN), 0.0);
35  EXPECT_EQ(axis.property<double>(ViewportAxisItem::P_MAX), 1.0);
36  EXPECT_FALSE(axis.property<bool>(ViewportAxisItem::P_IS_LOG));
37 }
Item to represent viewport axis.
Definition: axisitems.h:43

References ModelView::ViewportAxisItem::P_IS_LOG, ModelView::BasicAxisItem::P_MAX, ModelView::BasicAxisItem::P_MIN, and ModelView::SessionItem::property().

Here is the call graph for this function:

◆ TEST_F() [9/9]

TEST_F ( AxisItemsTest  ,
viewportAxisSetRange   
)

ViewportAxisItem::setRange.

Definition at line 41 of file axisitems.test.cpp.

42 {
43  ViewportAxisItem axis;
44 
45  // default range
46  auto [lower, upper] = axis.range();
47  EXPECT_EQ(lower, 0.0);
48  EXPECT_EQ(upper, 1.0);
49 
50  axis.set_range(1.0, 2.0);
51  EXPECT_EQ(axis.property<double>(ViewportAxisItem::P_MIN), 1.0);
52  EXPECT_EQ(axis.property<double>(ViewportAxisItem::P_MAX), 2.0);
53 }
void set_range(double lower, double upper)
Sets lower, upper range of axis to given values.
Definition: axisitems.cpp:51
std::pair< double, double > range() const
Returns pair of lower, upper axis range.
Definition: axisitems.cpp:44

References ModelView::BasicAxisItem::P_MAX, ModelView::BasicAxisItem::P_MIN, ModelView::SessionItem::property(), ModelView::ViewportAxisItem::range(), and ModelView::ViewportAxisItem::set_range().

Here is the call graph for this function: