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

Implements class CLASS? More...

Include dependency graph for vectoritem.test.cpp:

Go to the source code of this file.

Classes

class  VectorItemTest
 VectorItem tests. More...
 

Functions

 TEST_F (VectorItemTest, initialState)
 Initial state of item when it is created outside of model context. More...
 
 TEST_F (VectorItemTest, initialStateFromModel)
 Initial state of item in model context. 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 vectoritem.test.cpp.

Function Documentation

◆ TEST_F() [1/2]

TEST_F ( VectorItemTest  ,
initialState   
)

Initial state of item when it is created outside of model context.

Definition at line 33 of file vectoritem.test.cpp.

34 {
35  VectorItem item;
36 
37  EXPECT_TRUE(Utils::IsSinglePropertyTag(item, VectorItem::P_X));
38  EXPECT_TRUE(Utils::IsSinglePropertyTag(item, VectorItem::P_Y));
39  EXPECT_TRUE(Utils::IsSinglePropertyTag(item, VectorItem::P_Z));
40 
41  EXPECT_FALSE(item.isEditable());
42 
43  EXPECT_EQ(item.property<double>(VectorItem::P_X), 0.0);
44  EXPECT_EQ(item.property<double>(VectorItem::P_Y), 0.0);
45  EXPECT_EQ(item.property<double>(VectorItem::P_Z), 0.0);
46 
47  // default label
48  EXPECT_EQ(item.data<std::string>(), "(0, 0, 0)");
49 }
bool isEditable() const
Returns true if this item has editable flag set.
T data(int role=ItemDataRole::DATA) const
Returns data of given type T for given role.
Definition: sessionitem.h:148
T property(const std::string &tag) const
Returns data stored in property item.
Definition: sessionitem.h:181
Vector item with three x,y,z property items.
Definition: vectoritem.h:24
static const QString P_Z
Definition: VectorItem.h:26
static const QString P_Y
Definition: VectorItem.h:25
static const QString P_X
Definition: VectorItem.h:24
MVVM_MODEL_EXPORT bool IsSinglePropertyTag(const SessionItem &item, const std::string &tag)
Returns true if given item has registered tag, and it belongs to single property.
Definition: itemutils.cpp:91

References ModelView::SessionItem::data(), ModelView::SessionItem::isEditable(), ModelView::Utils::IsSinglePropertyTag(), ModelView::VectorItem::P_X, ModelView::VectorItem::P_Y, ModelView::VectorItem::P_Z, and ModelView::SessionItem::property().

Here is the call graph for this function:

◆ TEST_F() [2/2]

TEST_F ( VectorItemTest  ,
initialStateFromModel   
)

Initial state of item in model context.

Definition at line 53 of file vectoritem.test.cpp.

54 {
55  SessionModel model;
56  auto item = model.insertItem<VectorItem>();
57 
58  EXPECT_EQ(item->property<double>(VectorItem::P_X), 0.0);
59  EXPECT_EQ(item->property<double>(VectorItem::P_Y), 0.0);
60  EXPECT_EQ(item->property<double>(VectorItem::P_Z), 0.0);
61 
62  // default label
63  EXPECT_EQ(item->data<std::string>(), "(0, 0, 0)");
64 
65  // changing vector component
66  item->setProperty(VectorItem::P_X, 1.0);
67  EXPECT_EQ(item->data<std::string>(), "(1, 0, 0)");
68 }
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
T * insertItem(SessionItem *parent=nullptr, const TagRow &tagrow={})
Inserts item into given parent under given tagrow.
Definition: sessionmodel.h:104

References ModelView::SessionModel::insertItem(), ModelView::VectorItem::P_X, ModelView::VectorItem::P_Y, and ModelView::VectorItem::P_Z.

Here is the call graph for this function: