1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#include "CardPack_test.h"
#include "../../common/printQtTypes.h"
#include "../../../src/dictionary/IDictionary.h"
#include "../../../src/dictionary/Field.h"
#include "../../../src/dictionary/DicRecord.h"
ostream& operator<<(ostream& os, const Field* field)
{
return os << field->name().toStdString();
}
CardPackTest::CardPackTest():
pack(&dict),
qstField("Question", "Normal"),
ansField1("Answer1", "Normal"),
ansField2("Answer2", "Normal")
{}
TEST_F(CardPackTest, empty_QuestionAnswers)
{
ASSERT_EQ(NULL, pack.getQuestionField());
ASSERT_EQ(QList<const Field*>(), pack.getAnswerFields());
}
TEST_F(CardPackTest, empty_Id)
{
ASSERT_EQ("(empty pack)", pack.id());
}
TEST_F(CardPackTest, empty_cardQuestions)
{
ASSERT_EQ(QStringList(), pack.getCardQuestions());
}
TEST_F(CardPackTest, setQstField)
{
pack.setQstField(&qstField);
ASSERT_EQ(&qstField, pack.getQuestionField());
}
TEST_F(CardPackTest, setAnsField_1)
{
ansFields << &ansField1;
pack.setAnsFields(ansFields);
ASSERT_EQ(ansFields, pack.getAnswerFields());
}
TEST_F(CardPackTest, setAnsFields_2)
{
ansFields << &ansField1 << &ansField2;
pack.setAnsFields(ansFields);
ASSERT_EQ(ansFields, pack.getAnswerFields());
}
TEST_F(CardPackTest, addFields)
{
QList<const Field*> allFields;
allFields << &qstField << &ansField1 << &ansField2;
ansFields << &ansField1 << &ansField2;
pack.addField(&qstField);
pack.addField(&ansField1);
pack.addField(&ansField2);
ASSERT_EQ(allFields, pack.getFields());
ASSERT_EQ(&qstField, pack.getQuestionField());
ASSERT_EQ(ansFields, pack.getAnswerFields());
}
TEST_F(CardPackTest, id)
{
ansFields << &ansField1 << &ansField2;
pack.setQstField(&qstField);
pack.setAnsFields(ansFields);
ASSERT_EQ("Question - Answer1, Answer2", pack.id());
}
|