mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
52
coding/coding_tests/reader_test.hpp
Normal file
52
coding/coding_tests/reader_test.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/reader.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class ReaderT>
|
||||
void ReadToStringFromPos(ReaderT const & reader, std::string & str, uint64_t pos, size_t size)
|
||||
{
|
||||
str.resize(size);
|
||||
reader.Read(pos, &str[0], str.size());
|
||||
}
|
||||
|
||||
template <class SourceT>
|
||||
void ReadToStringFromSource(SourceT & source, std::string & str, size_t size)
|
||||
{
|
||||
str.resize(size);
|
||||
source.Read(&str[0], str.size());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ReaderT>
|
||||
void TestReader(ReaderT const & reader)
|
||||
{
|
||||
ReaderSource<ReaderT> source(reader);
|
||||
std::string d1;
|
||||
ReadToStringFromSource(source, d1, 6);
|
||||
TEST_EQUAL(d1, "Quick ", ());
|
||||
|
||||
ReadToStringFromSource(source, d1, 6);
|
||||
TEST_EQUAL(d1, "brown ", ());
|
||||
|
||||
ReaderT subReader = source.SubReader(10);
|
||||
ReadToStringFromPos(subReader, d1, 1, 3);
|
||||
TEST_EQUAL(d1, "ox ", ());
|
||||
|
||||
ReaderT subSubReader = subReader.SubReader(2, 8);
|
||||
ReadToStringFromPos(subSubReader, d1, 0, 2);
|
||||
TEST_EQUAL(d1, "x ", ());
|
||||
|
||||
ReadToStringFromSource(source, d1, 5);
|
||||
TEST_EQUAL(d1, "over ", ());
|
||||
|
||||
ReaderSource<ReaderT> subReaderSource(subReader);
|
||||
ReadToStringFromSource(subReaderSource, d1, 6);
|
||||
TEST_EQUAL(d1, "fox ju", ());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user