forked from organicmaps/organicmaps-tmp
Test on transit section header rewriting.
This commit is contained in:
parent
9b69523703
commit
6ead5a1b79
2 changed files with 36 additions and 1 deletions
|
@ -47,6 +47,40 @@ void TestSerialization(Obj const & obj)
|
|||
TestCommonSerialization<Serializer<MemWriter<vector<uint8_t>>>,
|
||||
Deserializer<ReaderSource<MemReader>>>(obj);
|
||||
}
|
||||
|
||||
UNIT_TEST(Transit_HeaderRewriting)
|
||||
{
|
||||
TransitHeader const bigHeader(1 /* version */, 1000 /* gatesOffset */, 200000 /* edgesOffset */,
|
||||
300000 /* transfersOffset */, 400000 /* linesOffset */,
|
||||
5000000 /* shapesOffset */, 6000000 /* networksOffset */,
|
||||
700000000 /* endOffset */);
|
||||
|
||||
TransitHeader header;
|
||||
vector<uint8_t> buffer;
|
||||
MemWriter<vector<uint8_t>> writer(buffer);
|
||||
|
||||
// Writing.
|
||||
auto const startOffset = writer.Pos();
|
||||
FixSizeNumberSerializer<MemWriter<vector<uint8_t>>> serializer(writer);
|
||||
header.Visit(serializer);
|
||||
auto const endOffset = writer.Pos();
|
||||
|
||||
// Rewriting.
|
||||
header = bigHeader;
|
||||
|
||||
writer.Seek(startOffset);
|
||||
header.Visit(serializer);
|
||||
writer.Seek(endOffset);
|
||||
|
||||
// Reading.
|
||||
MemReader reader(buffer.data(), buffer.size());
|
||||
ReaderSource<MemReader> src(reader);
|
||||
TransitHeader deserializedHeader;
|
||||
FixSizeNumberDeserializer<ReaderSource<MemReader>> deserializer(src);
|
||||
deserializedHeader.Visit(deserializer);
|
||||
|
||||
TEST(deserializedHeader.IsEqualForTesting(bigHeader), (deserializedHeader, bigHeader));
|
||||
}
|
||||
} // namespace transit
|
||||
} // namespace routing
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ Weight constexpr kInvalidWeight = -1.0;
|
|||
std::string const & osmIdsToFeatureIdPath, \
|
||||
std::string const & transitDir); \
|
||||
template <class Ser, class Deser, class Obj> \
|
||||
void friend TestCommonSerialization(Obj const & obj); \
|
||||
friend void TestCommonSerialization(Obj const & obj); \
|
||||
friend void UnitTest_Transit_HeaderRewriting(); \
|
||||
|
||||
struct TransitHeader
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue