blob: 7c1142e21b2d934f021e368643ab7d93342dbc8f [file] [log] [blame]
Constantin Ziesche02817f12020-08-04 21:40:43 +02001#include <gtest/gtest.h>
2
3#include <BaSyx/submodel/api_v2/parts/IConceptDictionary.h>
4#include <BaSyx/submodel/map_v2/parts/ConceptDictionary.h>
5#include <BaSyx/submodel/simple/parts/ConceptDictionary.h>
6
7#include <BaSyx/util/util.h>
8
9using namespace basyx::submodel;
10
11using ImplTypes = ::testing::Types
12<
13 std::tuple<map::ConceptDictionary, map::ConceptDescription>,
14 std::tuple<simple::ConceptDictionary, simple::ConceptDescription>
15>;
16
17template<class Impl>
18class ConceptDictionaryTest :public ::testing::Test {
19protected:
20 using impl_t = typename std::tuple_element<0, Impl>::type;
21 using impl_desc_t = typename std::tuple_element<1, Impl>::type;
22
23 std::unique_ptr<impl_t> conceptDictionary;
24 std::unique_ptr<impl_desc_t> description;
25 std::unique_ptr<impl_desc_t> description2;
26
27protected:
28 void SetUp() override
29 {
30 simple::Identifier id(IdentifierType::IRDI, "basyx");
31 description = util::make_unique<impl_desc_t>("some description", id);
32
33 simple::Identifier id2(IdentifierType::URI, "basyx");;
34 description2 = util::make_unique<impl_desc_t>("some other description", id2);
35
36 conceptDictionary = util::make_unique<impl_t>("test id");
37 }
38
39 void TearDown() override
40 { }
41};
42
43TYPED_TEST_CASE(ConceptDictionaryTest, ImplTypes);
44
45TYPED_TEST(ConceptDictionaryTest, TestConstructor)
46{
47 auto & descriptions = this->conceptDictionary->getConceptDescriptions();
48
49 ASSERT_EQ(descriptions.size(), 0);
50}
51
52TYPED_TEST(ConceptDictionaryTest, TestAddDescription)
53{
54 this->conceptDictionary->addConceptDescription(std::move(this->description));
55 this->conceptDictionary->addConceptDescription(std::move(this->description2));
56
57 auto & descriptions = this->conceptDictionary->getConceptDescriptions();
58
59 ASSERT_EQ(descriptions.size(), 2);
60 ASSERT_NE(descriptions.getElement("some description"), nullptr);
61 ASSERT_NE(descriptions.getElement("some other description"), nullptr);
62}