BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
compatibilityutils.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/testmodel/compatibilityutils.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 "google_test.h"
16 #include "mvvm/model/groupitem.h"
17 #include "mvvm/model/mvvm_types.h"
22 
23 using namespace ModelView;
24 
25 //! Test of CompatibilityUtilsTest.
26 
27 class CompatibilityUtilsTest : public ::testing::Test {
28 public:
30 };
31 
33 
34 //! Testing IsCompatibleSingleProperty.
35 
37 {
39  SessionItemContainer container(tag);
40 
41  // to be compatible, container should have PropertyItem in it already
42  EXPECT_FALSE(Compatibility::IsCompatibleSinglePropertyTag(container, tag));
43 
44  EXPECT_TRUE(container.insertItem(new PropertyItem, 0));
45  EXPECT_TRUE(Compatibility::IsCompatibleSinglePropertyTag(container, tag));
46 }
47 
48 //! Testing IsCompatibleSingleProperty.
49 
51 {
52  TagInfo tag = TagInfo::universalTag("layers");
53  SessionItemContainer container(tag);
54 
55  // to be compatible, container should be empty
56  EXPECT_TRUE(Compatibility::IsCompatibleUniversalTag(container, tag));
57 
58  EXPECT_TRUE(container.insertItem(new PropertyItem, 0));
59  EXPECT_FALSE(Compatibility::IsCompatibleUniversalTag(container, tag));
60 }
61 
62 //! Testing IsCompatibleSingleProperty.
63 
65 {
67  SessionItemContainer container(tag);
68 
69  // to be compatible, container should be non-empty
70  EXPECT_FALSE(Compatibility::IsCompatibleGroupTag(container, tag));
71 
72  EXPECT_TRUE(container.insertItem(new PropertyItem, 0));
73  EXPECT_TRUE(Compatibility::IsCompatibleGroupTag(container, tag));
74 }
Test of CompatibilityUtilsTest.
static const std::string T_GROUP_ITEMS
Definition: groupitem.h:28
Item to carry concrete editable entity (e.g.
Definition: propertyitem.h:27
Holds collection of SessionItem objects related to the same tag.
bool insertItem(SessionItem *item, int index)
Inserts item in a vector of children at given index, returns true in the case of success.
Holds info about single tag for SessionItem.
Definition: taginfo.h:28
static TagInfo universalTag(std::string name, std::vector< std::string > modelTypes={})
Constructs universal tag intended for unlimited amount of various items.
Definition: taginfo.cpp:34
static TagInfo propertyTag(std::string name, std::string model_type)
Constructs tag intended for single property.
Definition: taginfo.cpp:40
Defines class CLASS?
TEST_F(CompatibilityUtilsTest, IsCompatibleSinglePropertyTag)
Testing IsCompatibleSingleProperty.
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
bool IsCompatibleUniversalTag(const SessionItemContainer &container, const TagInfo &taginfo)
bool IsCompatibleSinglePropertyTag(const SessionItemContainer &container, const TagInfo &taginfo)
bool IsCompatibleGroupTag(const SessionItemContainer &container, const TagInfo &taginfo)
MVVM_MODEL_EXPORT bool IsCompatibleSinglePropertyTag(const SessionItemContainer &container, const TagInfo &taginfo)
Returns true if given TagInfo is a single property tag which is compatible with given container.
MVVM_MODEL_EXPORT bool IsCompatibleUniversalTag(const SessionItemContainer &container, const TagInfo &taginfo)
Returns true if given TagInfo is compatible with given container.
MVVM_MODEL_EXPORT bool IsCompatibleGroupTag(const SessionItemContainer &container, const TagInfo &taginfo)
Returns true if given TagInfo is a tag from GroupItem which is compatible with given container.
const model_type PropertyType
Definition: mvvm_types.h:59
materialitems.h Collection of materials to populate MaterialModel.
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?