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
|
#include "SRModel_test.h"
#include "../../common/printQtTypes.h"
#include "../../../src/dictionary/DicRecord.h"
#include "../../../src/dictionary/Card.h"
#include "../../../src/study/StudySettings.h"
#include "../../mocks/RandomGenerator_mock.h"
SRModelTest::SRModelTest():
recordId(0),
pack(&dict),
randomGenerator(new MockRandomGenerator),
model(&pack, randomGenerator)
{
field1 = new Field("English", "Normal");
field2 = new Field("Russian", "Normal");
pack.addField(field1);
pack.addField(field2);
dict.addCardPack(&pack);
}
void SRModelTest::SetUp()
{
QCoreApplication::setOrganizationName("freshmemory");
QCoreApplication::setApplicationName("freshmemory");
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, "");
StudySettings::inst()->load();
}
void SRModelTest::TearDown()
{
delete field1;
delete field2;
}
TEST_F(SRModelTest, EmptyStats)
{
ASSERT_EQ(0, model.estimatedNewReviewedCardsToday());
ASSERT_EQ(0, model.countTodayRemainingCards());
}
TEST_F(SRModelTest, FirstStudy)
{
QString cardName = createCard();
StudyRecord newStudy = pack.getStudyRecord(cardName);
ASSERT_EQ(StudyRecord::Unknown, newStudy.grade);
ASSERT_DOUBLE_EQ(StudySettings::inst()->initEasiness, newStudy.easiness);
ASSERT_DOUBLE_EQ(0, newStudy.interval);
}
QString SRModelTest::createCard()
{
addRecord();
pack.generateQuestions();
return model.getCurCard()->getQuestion();
}
QString SRModelTest::addRecord()
{
DicRecord* record = new DicRecord;
QString recordName = QString::number(recordId);
record->setField("English", recordName);
record->setField("Russian", "Odin");
recordId++;
dict.addRecord(record);
return recordName;
}
|