BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
externalproperty.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/externalproperty.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/comparators.h"
18 
19 using namespace ModelView;
20 
21 class ExternalPropertyTest : public ::testing::Test {
22 public:
24 };
25 
27 
29 {
30  ExternalProperty property;
31  EXPECT_FALSE(property.isValid());
32  EXPECT_EQ(property.text(), "");
33  EXPECT_EQ(property.identifier(), "");
34  EXPECT_FALSE(property.color().isValid());
35 }
36 
38 {
39  ExternalProperty property("text", QColor(Qt::red), "123");
40  EXPECT_TRUE(property.isValid());
41  EXPECT_EQ(property.text(), "text");
42  EXPECT_EQ(property.color(), QColor("red"));
43  EXPECT_EQ(property.identifier(), "123");
44 }
45 
46 TEST_F(ExternalPropertyTest, equalityOperators)
47 {
48  ExternalProperty prop1a;
49  ExternalProperty prop1b;
50 
51  EXPECT_TRUE(prop1a == prop1b);
52  EXPECT_FALSE(prop1a < prop1b);
53 
54  ExternalProperty prop2a("text", QColor(Qt::red));
55  ExternalProperty prop2b("text", QColor(Qt::red));
56  EXPECT_TRUE(prop2a == prop2b);
57  EXPECT_FALSE(prop2a < prop2b);
58 
59  EXPECT_FALSE(prop1a == prop2a);
60 }
61 
62 TEST_F(ExternalPropertyTest, variantEquality)
63 {
65  ExternalProperty prop1a;
66  ExternalProperty prop1b;
67  EXPECT_TRUE(QVariant::fromValue(prop1a) == QVariant::fromValue(prop1b));
68 
69  ExternalProperty prop2a("text", QColor(Qt::red));
70  ExternalProperty prop2b("text", QColor(Qt::red));
71  EXPECT_TRUE(QVariant::fromValue(prop2a) == QVariant::fromValue(prop2b));
72 
73  EXPECT_FALSE(QVariant::fromValue(prop1a) == QVariant::fromValue(prop2a));
74  }
75 }
static bool registered()
Definition: comparators.cpp:38
Property to carry text, color and identifier.
std::string identifier() const
Defines class CLASS?
Defines class CLASS?
TEST_F(ExternalPropertyTest, initialState)
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.