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>
14 using namespace CppUtilities::Literals;
16 using namespace CPPUNIT_NS;
23 CPPUNIT_TEST(testNewFieldCorrectlyInitialized);
24 CPPUNIT_TEST(testMutation);
25 CPPUNIT_TEST_SUITE_END();
28 void setUp()
override;
29 void tearDown()
override;
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());
The FieldTests class tests the Io::Field class.
void testNewFieldCorrectlyInitialized()
Tests whether a new field is correctly initialized (default values set).
The exception that is thrown when a parsing error occurs.
The Field class holds field information which consists of a name and a value and is able to serialize...
void setName(const std::string &name)
Sets the name.
void setValue(const std::string &value)
Sets the value.
const std::string & name() const
Returns the name.
const std::string & value() const
Returns the value.
void setType(FieldType type)
Sets the type.
bool isEmpty() const
Returns an indication whether the entry is empty.
FieldType type() const
Returns the type.
AccountEntry * tiedAccount() const
Returns the tied account.
CPPUNIT_TEST_SUITE_REGISTRATION(FieldTests)
Contains all IO related classes.