aboutsummaryrefslogtreecommitdiff
path: root/c/test.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-16 04:37:48 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-16 04:37:48 +0200
commit5095c2e2ba9aadf468514804fb3a872d10fdc17d (patch)
tree6683057496648797923ce686440c101510d9bc87 /c/test.cpp
parentafd245c205e2787e54cb7e2fd34de617eeceed25 (diff)
downloadEpisodeBrowser-5095c2e2ba9aadf468514804fb3a872d10fdc17d.tar.gz
Implement preliminary IO.
It might be a good idea to eschew the structs and access the data directly from the view. Alternatively, the serialization functions might be rewritten to simply memcpy the structs, after either adding __attribute__((packed)) or ensuring consistent padding.
Diffstat (limited to 'c/test.cpp')
-rw-r--r--c/test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/c/test.cpp b/c/test.cpp
index 1fc7e3b..fb5d44d 100644
--- a/c/test.cpp
+++ b/c/test.cpp
@@ -71,6 +71,36 @@ TESTS
if (wcscmp(e1.title, e2.title) != 0)
FAIL("title is different");
}
+
+ TEST(SerializationPlusIO)
+ {
+ ElvData e1;
+ FromProlog(6, e1);
+ {
+ DatView dv{L"tmp.dat", CB_SERIALIZE_ELVDATA};
+ Serialize(e1, static_cast<unsigned char*>(dv.view));
+ }
+ {
+ DatView dv{L"tmp.dat", CB_SERIALIZE_ELVDATA};
+
+ ElvData e2;
+ if (!Unserialize(e2, static_cast<unsigned char*>(dv.view)))
+ FAIL("invalid serialization version");
+ if (e1.rating != e2.rating)
+ FAIL("rating is different");
+ if (e1.bWatched != e2.bWatched)
+ FAIL("bWatched is different");
+ if (e1.bTVOriginal != e2.bTVOriginal)
+ FAIL("bTVOriginal is different");
+ if (wcscmp(e1.sRating, e2.sRating) != 0)
+ FAIL("sRating is different");
+ if (wcscmp(e1.siEp, e2.siEp) != 0)
+ FAIL("siEp is different");
+ if (wcscmp(e1.title, e2.title) != 0)
+ FAIL("title is different");
+ }
+ DeleteFile(L"tmp.dat");
+ }
};
int RunTests()
@@ -80,6 +110,7 @@ int RunTests()
//EpisodeDataFromWeb{},
EpisodeDataFromProlog{},
Serialization{},
+ SerializationPlusIO{},
};
printf("Results (%llu tests):\n", sizeof(tests)/sizeof(*tests));