@@ -10,26 +10,59 @@ void TestCore::serialization()
10
10
datas.append (QByteArray (" Even More..." ));
11
11
datas.append (QByteArray (" lalalaalalalalalalal" ).toBase64 ());
12
12
13
- // Write some data.
13
+ // WRITE some data.
14
14
ADS_NS_SER::InMemoryWriter writer;
15
15
for (int i = 0 ; i < datas.count (); ++i)
16
16
{
17
- QVERIFY (writer.write (i + 1 , datas.at (i)));
17
+ QVERIFY (writer.write (ADS_NS_SER::ET_Custom + i , datas.at (i)));
18
18
}
19
- QVERIFY (writer.offsetsCount () == datas.count ());
19
+
20
+ // Type: SectionIndexData
21
+ ADS_NS_SER::SectionIndexData sid;
22
+ for (int i = 0 ; i < 1 ; ++i)
23
+ {
24
+ ADS_NS_SER::SectionEntity se;
25
+ se.x = i;
26
+ se.y = i;
27
+ se.width = 100 + i;
28
+ se.height = 100 + i;
29
+ se.currentIndex = i;
30
+
31
+ for (int j = 0 ; j < 1 ; ++j)
32
+ {
33
+ ADS_NS_SER::SectionContentEntity sce;
34
+ sce.uniqueName = QString (" uname-%1-%2" ).arg (i).arg (j);
35
+ sce.preferredIndex = 8 ;
36
+ sce.visible = true ;
37
+ se.sectionContents .append (sce);
38
+ se.sectionContentsCount += 1 ;
39
+ }
40
+
41
+ sid.sections .append (se);
42
+ sid.sectionsCount += 1 ;
43
+ }
44
+ QVERIFY (writer.write (sid));
45
+
46
+ QVERIFY (writer.offsetsCount () == datas.count () + 1 );
20
47
const QByteArray writtenData = writer.toByteArray ();
21
48
QVERIFY (writtenData.size () > 0 );
22
49
23
- // Read and validate written data.
50
+ // READ and validate written data.
24
51
ADS_NS_SER::InMemoryReader reader (writtenData);
25
52
QVERIFY (reader.initReadHeader ());
26
- QVERIFY (reader.offsetsCount () == datas.count ());
53
+ QVERIFY (reader.offsetsCount () == datas.count () + 1 );
27
54
for (int i = 0 ; i < datas.count (); ++i)
28
55
{
29
56
QByteArray readData;
30
- QVERIFY (reader.read (i + 1 , readData));
57
+ QVERIFY (reader.read (ADS_NS_SER::ET_Custom + i , readData));
31
58
QVERIFY (readData == datas.at (i));
32
59
}
60
+
61
+ // Type: SectionIndexData
62
+ ADS_NS_SER::SectionIndexData sidRead;
63
+ QVERIFY (reader.read (sidRead));
64
+
65
+ // TODO compare sidRead with sid
33
66
}
34
67
35
68
QTEST_MAIN (TestCore)
0 commit comments