I would suggest to test the invidual pieces.
First check that the size is written and read correctly, because there is no point in continuing if it is not.
Then check writing and reading a map with one entry, and so on.
Btw, why such a complicated way of writing the map size? If you just write the map size's value you can also more easily iterate over that range when reading, no?
Cheers,
_
Bookmarks