MessageFieldCollectionTest.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2014 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
19 #include <gtest/gtest.h>
20 
22 
23 using namespace variant_topic_tools;
24 
27 
28  c1.appendField("field1");
29  c1.appendField("field2", true);
30  c1["field2"].appendField("field2_1");
31 
32  EXPECT_FALSE(c1.isEmpty());
33  EXPECT_EQ(2, c1.getNumFields());
34 
35  EXPECT_TRUE(c1.hasField("field1"));
36  EXPECT_TRUE(c1.hasField("/field2"));
37  EXPECT_TRUE(c1.hasField("field2/field2_1"));
38  EXPECT_TRUE(c1.hasField("/field2/field2_1"));
39  EXPECT_FALSE(c1.hasField("field3"));
40  EXPECT_FALSE(c1.hasField("field2/field2_2"));
41 
42  EXPECT_NO_THROW(c1.getField("field1"));
43  EXPECT_NO_THROW(c1.getField("/field2"));
44  EXPECT_NO_THROW(c1.getField("field2/field2_1"));
45  EXPECT_NO_THROW(c1.getField("/field2/field2_1"));
46  EXPECT_ANY_THROW(c1.getField("field3"));
47  EXPECT_ANY_THROW(c1.getField("field2/field2_2"));
48 
49  EXPECT_FALSE(c1["field1"].getValue());
50  EXPECT_TRUE(c1["field2"].getValue());
51 
52  c1.clear();
53 
54  EXPECT_TRUE(c1.isEmpty());
55 }
MessageField< T > & getField(int index)
Retrieve a field of the message field collection by index (non-const version)
bool hasField(const std::string &name) const
True, if the message field collection contains the field with the specified name. ...
Header file providing the MessageFieldCollection class interface.
void appendField(const MessageField< T > &field)
Append a field to the message field collection.
TEST(MessageFieldCollection, Namespaces)
size_t getNumFields() const
Retrieve the number of fields of the message field collection.
virtual void clear()
Clear the message field collection.
Forward declaration of the message field collection.
Definition: Forwards.h:64
bool isEmpty() const
True, if the message field collections is empty.


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:49