1 #include "../io/entry.h" 2 #include "../io/field.h" 6 #include <c++utilities/tests/testutils.h> 9 #include <cppunit/TestFixture.h> 10 #include <cppunit/extensions/HelperMacros.h> 23 CPPUNIT_TEST(testNewFieldCorrectlyInitialized);
24 CPPUNIT_TEST(testMutation);
25 CPPUNIT_TEST_SUITE_END();
31 void testNewFieldCorrectlyInitialized();
51 const Field emptyField(&account);
52 CPPUNIT_ASSERT(emptyField.
isEmpty());
54 const Field field(&account,
"foo",
"bar");
55 CPPUNIT_ASSERT(!field.isEmpty());
56 CPPUNIT_ASSERT_EQUAL(&account, field.tiedAccount());
57 CPPUNIT_ASSERT_EQUAL(
"foo"s, field.name());
58 CPPUNIT_ASSERT_EQUAL(
"bar"s, field.value());
59 CPPUNIT_ASSERT_EQUAL(FieldType::Normal, field.type());
65 Field field(&account,
"foo",
"bar");
68 field.
setType(FieldType::Password);
69 CPPUNIT_ASSERT_EQUAL(
"bar"s, field.
name());
70 CPPUNIT_ASSERT_EQUAL(
"foo"s, field.
value());
71 CPPUNIT_ASSERT_EQUAL(FieldType::Password, field.
type());
void setName(const std::string &name)
Sets the name.
void setValue(const std::string &value)
Sets the value.
bool isEmpty() const
Returns an indication whether the entry is empty.
const std::string & value() const
Returns the value.
The FieldTests class tests the Io::Field class.
Contains all IO related classes.
FieldType type() const
Returns the type.
The Field class holds field information which consists of a name and a value and is able to serialize...
The exception that is thrown when a parsing error occurs.
void testNewFieldCorrectlyInitialized()
Tests whether a new field is correctly initialized (default values set).
void setType(FieldType type)
Sets the type.
const std::string & name() const
Returns the name.
CPPUNIT_TEST_SUITE_REGISTRATION(FieldTests)