Passwordfile library
5.0.12
C++ library to read/write passwords from/to encrypted files
Loading...
Searching...
No Matches
tests
fieldtests.cpp
Go to the documentation of this file.
1
#include "
../io/entry.h
"
2
#include "
../io/field.h
"
3
4
#include "
./utils.h
"
5
6
#include <cppunit/TestFixture.h>
7
#include <cppunit/extensions/HelperMacros.h>
8
9
using namespace
std;
10
using namespace
Io
;
11
using namespace
CppUtilities::Literals;
12
13
using namespace
CPPUNIT_NS;
14
18
class
FieldTests
:
public
TestFixture {
19
CPPUNIT_TEST_SUITE(
FieldTests
);
20
CPPUNIT_TEST(
testNewFieldCorrectlyInitialized
);
21
CPPUNIT_TEST(
testMutation
);
22
CPPUNIT_TEST_SUITE_END();
23
24
public
:
25
void
setUp
()
override
;
26
void
tearDown
()
override
;
27
28
void
testNewFieldCorrectlyInitialized
();
29
void
testMutation
();
30
};
31
32
CPPUNIT_TEST_SUITE_REGISTRATION
(
FieldTests
);
33
34
void
FieldTests::setUp
()
35
{
36
}
37
38
void
FieldTests::tearDown
()
39
{
40
}
41
45
void
FieldTests::testNewFieldCorrectlyInitialized
()
46
{
47
AccountEntry
account(
"account"
);
48
const
Field
emptyField(&account);
49
CPPUNIT_ASSERT(emptyField.
isEmpty
());
50
51
const
Field
field(&account,
"foo"
,
"bar"
);
52
CPPUNIT_ASSERT(!field.
isEmpty
());
53
CPPUNIT_ASSERT_EQUAL(&account, field.
tiedAccount
());
54
CPPUNIT_ASSERT_EQUAL(
"foo"
s, field.
name
());
55
CPPUNIT_ASSERT_EQUAL(
"bar"
s, field.
value
());
56
CPPUNIT_ASSERT_EQUAL(FieldType::Normal, field.
type
());
57
}
58
59
void
FieldTests::testMutation
()
60
{
61
AccountEntry
account(
"account"
);
62
Field
field(&account,
"foo"
,
"bar"
);
63
field.
setName
(
"bar"
);
64
field.
setValue
(
"foo"
);
65
field.
setType
(FieldType::Password);
66
CPPUNIT_ASSERT_EQUAL(
"bar"
s, field.
name
());
67
CPPUNIT_ASSERT_EQUAL(
"foo"
s, field.
value
());
68
CPPUNIT_ASSERT_EQUAL(FieldType::Password, field.
type
());
69
}
FieldTests
The FieldTests class tests the Io::Field class.
Definition
fieldtests.cpp:18
FieldTests::testMutation
void testMutation()
Definition
fieldtests.cpp:59
FieldTests::testNewFieldCorrectlyInitialized
void testNewFieldCorrectlyInitialized()
Tests whether a new field is correctly initialized (default values set).
Definition
fieldtests.cpp:45
FieldTests::setUp
void setUp() override
Definition
fieldtests.cpp:34
FieldTests::tearDown
void tearDown() override
Definition
fieldtests.cpp:38
Io::AccountEntry
The exception that is thrown when a parsing error occurs.
Definition
entry.h:170
Io::Field
The Field class holds field information which consists of a name and a value and is able to serialize...
Definition
field.h:15
Io::Field::setName
void setName(const std::string &name)
Sets the name.
Definition
field.h:67
Io::Field::setValue
void setValue(const std::string &value)
Sets the value.
Definition
field.h:83
Io::Field::name
const std::string & name() const
Returns the name.
Definition
field.h:59
Io::Field::value
const std::string & value() const
Returns the value.
Definition
field.h:75
Io::Field::setType
void setType(FieldType type)
Sets the type.
Definition
field.h:99
Io::Field::isEmpty
bool isEmpty() const
Returns an indication whether the entry is empty.
Definition
field.h:51
Io::Field::type
FieldType type() const
Returns the type.
Definition
field.h:91
Io::Field::tiedAccount
AccountEntry * tiedAccount() const
Returns the tied account.
Definition
field.h:107
entry.h
field.h
CPPUNIT_TEST_SUITE_REGISTRATION
CPPUNIT_TEST_SUITE_REGISTRATION(FieldTests)
Io
Contains all IO related classes.
Definition
cryptoexception.h:9
utils.h
Generated on Tue Aug 6 2024 22:26:30 for Passwordfile library by
1.11.0