mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -2,14 +2,13 @@
|
||||
|
||||
#include "coding/base64.hpp"
|
||||
|
||||
|
||||
using namespace base64;
|
||||
|
||||
UNIT_TEST(Base64_Smoke)
|
||||
{
|
||||
char const * bytes[] = {"H", "He", "Hel", "Hell", "Hello", "Hello,", "Hello, ", "Hello, World!"};
|
||||
char const * encoded[] = {"SA==", "SGU=", "SGVs", "SGVsbA==", "SGVsbG8=", "SGVsbG8s",
|
||||
"SGVsbG8sIA==", "SGVsbG8sIFdvcmxkIQ=="};
|
||||
char const * encoded[] = {
|
||||
"SA==", "SGU=", "SGVs", "SGVsbA==", "SGVsbG8=", "SGVsbG8s", "SGVsbG8sIA==", "SGVsbG8sIFdvcmxkIQ=="};
|
||||
|
||||
TEST_EQUAL(ARRAY_SIZE(bytes), ARRAY_SIZE(encoded), ());
|
||||
|
||||
@@ -22,7 +21,8 @@ UNIT_TEST(Base64_Smoke)
|
||||
}
|
||||
|
||||
char const * str = "MapsWithMe is the offline maps application for any device in the world.";
|
||||
char const * encStr = "TWFwc1dpdGhNZSBpcyB0aGUgb2ZmbGluZSBtYXBzIGFwcGxpY2F0aW9uIGZvciBhbnkgZGV2aWNlIGluIHRoZSB3b3JsZC4=";
|
||||
char const * encStr =
|
||||
"TWFwc1dpdGhNZSBpcyB0aGUgb2ZmbGluZSBtYXBzIGFwcGxpY2F0aW9uIGZvciBhbnkgZGV2aWNlIGluIHRoZSB3b3JsZC4=";
|
||||
TEST_EQUAL(Encode(str), encStr, ());
|
||||
TEST_EQUAL(Decode(encStr), str, ());
|
||||
}
|
||||
|
||||
@@ -84,12 +84,10 @@ UNIT_TEST(BitStreams_Large)
|
||||
BitWriter<TWriter> bits(w);
|
||||
|
||||
for (int i = 0; i <= 64; ++i)
|
||||
{
|
||||
if (i <= 32)
|
||||
bits.WriteAtMost32Bits(static_cast<uint32_t>(kMask), i);
|
||||
else
|
||||
bits.WriteAtMost64Bits(kMask, i);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -18,24 +18,21 @@ void Intersect(vector<uint64_t> & setBits1, vector<uint64_t> & setBits2, vector<
|
||||
{
|
||||
sort(setBits1.begin(), setBits1.end());
|
||||
sort(setBits2.begin(), setBits2.end());
|
||||
set_intersection(setBits1.begin(), setBits1.end(), setBits2.begin(), setBits2.end(),
|
||||
back_inserter(result));
|
||||
set_intersection(setBits1.begin(), setBits1.end(), setBits2.begin(), setBits2.end(), back_inserter(result));
|
||||
}
|
||||
|
||||
void Subtract(vector<uint64_t> & setBits1, vector<uint64_t> & setBits2, vector<uint64_t> & result)
|
||||
{
|
||||
sort(setBits1.begin(), setBits1.end());
|
||||
sort(setBits2.begin(), setBits2.end());
|
||||
set_difference(setBits1.begin(), setBits1.end(), setBits2.begin(), setBits2.end(),
|
||||
back_inserter(result));
|
||||
set_difference(setBits1.begin(), setBits1.end(), setBits2.begin(), setBits2.end(), back_inserter(result));
|
||||
}
|
||||
|
||||
void Union(vector<uint64_t> & setBits1, vector<uint64_t> & setBits2, vector<uint64_t> & result)
|
||||
{
|
||||
sort(setBits1.begin(), setBits1.end());
|
||||
sort(setBits2.begin(), setBits2.end());
|
||||
set_union(setBits1.begin(), setBits1.end(), setBits2.begin(), setBits2.end(),
|
||||
back_inserter(result));
|
||||
set_union(setBits1.begin(), setBits1.end(), setBits2.begin(), setBits2.end(), back_inserter(result));
|
||||
}
|
||||
|
||||
template <typename TBinaryOp>
|
||||
@@ -56,14 +53,12 @@ void CheckIntersection(vector<uint64_t> & setBits1, vector<uint64_t> & setBits2,
|
||||
CheckBinaryOp(&Intersect, setBits1, setBits2, cbv);
|
||||
}
|
||||
|
||||
void CheckSubtraction(vector<uint64_t> & setBits1, vector<uint64_t> & setBits2,
|
||||
coding::CompressedBitVector const & cbv)
|
||||
void CheckSubtraction(vector<uint64_t> & setBits1, vector<uint64_t> & setBits2, coding::CompressedBitVector const & cbv)
|
||||
{
|
||||
CheckBinaryOp(&Subtract, setBits1, setBits2, cbv);
|
||||
}
|
||||
|
||||
void CheckUnion(vector<uint64_t> & setBits1, vector<uint64_t> & setBits2,
|
||||
coding::CompressedBitVector const & cbv)
|
||||
void CheckUnion(vector<uint64_t> & setBits1, vector<uint64_t> & setBits2, coding::CompressedBitVector const & cbv)
|
||||
{
|
||||
CheckBinaryOp(&Union, setBits1, setBits2, cbv);
|
||||
}
|
||||
@@ -249,8 +244,8 @@ UNIT_TEST(CompressedBitVector_Union_Smoke)
|
||||
vector<uint64_t> setBits1 = {};
|
||||
vector<uint64_t> setBits2 = {};
|
||||
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Sparse /* strategy1 */,
|
||||
setBits2, coding::CompressedBitVector::StorageStrategy::Sparse /* strategy2 */,
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Sparse /* strategy1 */, setBits2,
|
||||
coding::CompressedBitVector::StorageStrategy::Sparse /* strategy2 */,
|
||||
coding::CompressedBitVector::StorageStrategy::Sparse /* resultStrategy */);
|
||||
}
|
||||
|
||||
@@ -259,8 +254,8 @@ UNIT_TEST(CompressedBitVector_Union1)
|
||||
vector<uint64_t> setBits1 = {};
|
||||
vector<uint64_t> setBits2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Sparse /* strategy1 */,
|
||||
setBits2, coding::CompressedBitVector::StorageStrategy::Dense /* strategy2 */,
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Sparse /* strategy1 */, setBits2,
|
||||
coding::CompressedBitVector::StorageStrategy::Dense /* strategy2 */,
|
||||
coding::CompressedBitVector::StorageStrategy::Dense /* resultStrategy */);
|
||||
}
|
||||
|
||||
@@ -269,8 +264,8 @@ UNIT_TEST(CompressedBitVector_Union2)
|
||||
vector<uint64_t> setBits1 = {256, 1024};
|
||||
vector<uint64_t> setBits2 = {0, 32, 64};
|
||||
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Sparse /* strategy1 */,
|
||||
setBits2, coding::CompressedBitVector::StorageStrategy::Sparse /* strategy2 */,
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Sparse /* strategy1 */, setBits2,
|
||||
coding::CompressedBitVector::StorageStrategy::Sparse /* strategy2 */,
|
||||
coding::CompressedBitVector::StorageStrategy::Sparse /* resultStrategy */);
|
||||
}
|
||||
|
||||
@@ -282,8 +277,8 @@ UNIT_TEST(CompressedBitVector_Union3)
|
||||
for (int i = 0; i < 256; ++i)
|
||||
setBits2.push_back(i);
|
||||
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Dense /* strategy1 */,
|
||||
setBits2, coding::CompressedBitVector::StorageStrategy::Dense /* strategy2 */,
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Dense /* strategy1 */, setBits2,
|
||||
coding::CompressedBitVector::StorageStrategy::Dense /* strategy2 */,
|
||||
coding::CompressedBitVector::StorageStrategy::Dense /* resultStrategy */);
|
||||
}
|
||||
|
||||
@@ -295,8 +290,8 @@ UNIT_TEST(CompressedBitVector_Union4)
|
||||
|
||||
vector<uint64_t> setBits2 = {1000000000};
|
||||
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Dense /* strategy1 */,
|
||||
setBits2, coding::CompressedBitVector::StorageStrategy::Sparse /* strategy2 */,
|
||||
CheckUnion(setBits1, coding::CompressedBitVector::StorageStrategy::Dense /* strategy1 */, setBits2,
|
||||
coding::CompressedBitVector::StorageStrategy::Sparse /* strategy2 */,
|
||||
coding::CompressedBitVector::StorageStrategy::Sparse /* resultStrategy */);
|
||||
}
|
||||
|
||||
@@ -328,10 +323,8 @@ UNIT_TEST(CompressedBitVector_SerializationSparse)
|
||||
int const kNumBits = 100;
|
||||
vector<uint64_t> setBits;
|
||||
for (size_t i = 0; i < kNumBits; ++i)
|
||||
{
|
||||
if (i % 10 == 0)
|
||||
setBits.push_back(i);
|
||||
}
|
||||
vector<uint8_t> buf;
|
||||
{
|
||||
MemWriter<vector<uint8_t>> writer(buf);
|
||||
@@ -361,25 +354,20 @@ UNIT_TEST(CompressedBitVector_ForEach)
|
||||
}
|
||||
auto denseCBV = coding::CompressedBitVectorBuilder::FromBitPositions(denseBits);
|
||||
auto sparseCBV = coding::CompressedBitVectorBuilder::FromBitPositions(sparseBits);
|
||||
TEST_EQUAL(coding::CompressedBitVector::StorageStrategy::Dense, denseCBV->GetStorageStrategy(),
|
||||
());
|
||||
TEST_EQUAL(coding::CompressedBitVector::StorageStrategy::Sparse, sparseCBV->GetStorageStrategy(),
|
||||
());
|
||||
TEST_EQUAL(coding::CompressedBitVector::StorageStrategy::Dense, denseCBV->GetStorageStrategy(), ());
|
||||
TEST_EQUAL(coding::CompressedBitVector::StorageStrategy::Sparse, sparseCBV->GetStorageStrategy(), ());
|
||||
|
||||
set<uint64_t> denseSet;
|
||||
uint64_t maxPos = 0;
|
||||
coding::CompressedBitVectorEnumerator::ForEach(*denseCBV, [&](uint64_t pos)
|
||||
{
|
||||
denseSet.insert(pos);
|
||||
maxPos = max(maxPos, pos);
|
||||
});
|
||||
{
|
||||
denseSet.insert(pos);
|
||||
maxPos = max(maxPos, pos);
|
||||
});
|
||||
TEST_EQUAL(denseSet.size(), kNumBits, ());
|
||||
TEST_EQUAL(maxPos, kNumBits - 1, ());
|
||||
|
||||
coding::CompressedBitVectorEnumerator::ForEach(*sparseCBV, [](uint64_t pos)
|
||||
{
|
||||
TEST_EQUAL(pos % 15, 0, ());
|
||||
});
|
||||
coding::CompressedBitVectorEnumerator::ForEach(*sparseCBV, [](uint64_t pos) { TEST_EQUAL(pos % 15, 0, ()); });
|
||||
}
|
||||
|
||||
UNIT_TEST(CompressedBitVector_DenseOneBit)
|
||||
@@ -387,10 +375,7 @@ UNIT_TEST(CompressedBitVector_DenseOneBit)
|
||||
vector<uint64_t> setBits = {0};
|
||||
unique_ptr<coding::DenseCBV> cbv(new coding::DenseCBV(setBits));
|
||||
TEST_EQUAL(cbv->PopCount(), 1, ());
|
||||
coding::CompressedBitVectorEnumerator::ForEach(*cbv, [&](uint64_t pos)
|
||||
{
|
||||
TEST_EQUAL(pos, 0, ());
|
||||
});
|
||||
coding::CompressedBitVectorEnumerator::ForEach(*cbv, [&](uint64_t pos) { TEST_EQUAL(pos, 0, ()); });
|
||||
}
|
||||
|
||||
UNIT_TEST(CompressedBitVector_LeaveFirstNBitsSmoke)
|
||||
@@ -450,22 +435,18 @@ UNIT_TEST(CompressedBitVector_SparseLeaveFirstNBits)
|
||||
cbv = cbv->LeaveFirstSetNBits(100);
|
||||
TEST_EQUAL(cbv->PopCount(), 10, ());
|
||||
for (uint64_t bit = 0; bit < (1 << 10); ++bit)
|
||||
{
|
||||
if (bit != 0 && (bit & (bit - 1)) == 0)
|
||||
TEST(cbv->GetBit(bit), (bit));
|
||||
else
|
||||
TEST(!cbv->GetBit(bit), (bit));
|
||||
}
|
||||
|
||||
cbv = cbv->LeaveFirstSetNBits(8);
|
||||
TEST_EQUAL(cbv->PopCount(), 8, ());
|
||||
for (uint64_t bit = 0; bit < (1 << 10); ++bit)
|
||||
{
|
||||
if (bit != 0 && (bit & (bit - 1)) == 0 && bit < (1 << 8))
|
||||
TEST(cbv->GetBit(bit), (bit));
|
||||
else
|
||||
TEST(!cbv->GetBit(bit), (bit));
|
||||
}
|
||||
|
||||
cbv = cbv->LeaveFirstSetNBits(0);
|
||||
TEST_EQUAL(cbv->PopCount(), 0, ());
|
||||
|
||||
@@ -144,7 +144,8 @@ UNIT_TEST(CSVReaderForEachRow)
|
||||
FileReader fileReader(sf.GetFullPath());
|
||||
auto reader = coding::CSVReader(fileReader);
|
||||
size_t index = 0;
|
||||
reader.ForEachRow([&](auto const & row) {
|
||||
reader.ForEachRow([&](auto const & row)
|
||||
{
|
||||
TEST_EQUAL(row, answer[index], ());
|
||||
++index;
|
||||
});
|
||||
@@ -202,10 +203,12 @@ UNIT_TEST(CSVReaderEmptyColumns)
|
||||
|
||||
UNIT_TEST(CSVReaderQuotes)
|
||||
{
|
||||
auto const kContentWithQuotes = R"(noquotes, "" , "with space","with, comma","""double"" quotes","""double,"", commas", """""",)";
|
||||
auto const kContentWithQuotes =
|
||||
R"(noquotes, "" , "with space","with, comma","""double"" quotes","""double,"", commas", """""",)";
|
||||
auto const fileName = "test.csv";
|
||||
ScopedFile sf(fileName, kContentWithQuotes);
|
||||
Rows const answer = {{"noquotes", "", "with space", "with, comma", "\"double\" quotes", "\"double,\", commas","\"\"", ""}};
|
||||
Rows const answer = {
|
||||
{"noquotes", "", "with space", "with, comma", "\"double\" quotes", "\"double,\", commas", "\"\"", ""}};
|
||||
coding::CSVReader reader(sf.GetFullPath());
|
||||
size_t index = 0;
|
||||
while (auto const optionalRow = reader.ReadRow())
|
||||
|
||||
@@ -18,10 +18,10 @@ using namespace std;
|
||||
UNIT_TEST(MyersSimpleDiff)
|
||||
{
|
||||
vector<char> tmp;
|
||||
PushBackByteSink<vector<char> > sink(tmp);
|
||||
PushBackByteSink<vector<char>> sink(tmp);
|
||||
TEST_EQUAL(4, diff::DiffMyersSimple(string("axxxb"), string("cxxxd"), 5, sink), ());
|
||||
TEST_EQUAL(5, diff::DiffMyersSimple(string("abcabba"), string("cbabac"), 10, sink), ());
|
||||
TEST_EQUAL(5, diff::DiffMyersSimple(string("abcabba"), string("cbabac"), 5, sink), ());
|
||||
TEST_EQUAL(5, diff::DiffMyersSimple(string("abcabba"), string("cbabac"), 10, sink), ());
|
||||
TEST_EQUAL(5, diff::DiffMyersSimple(string("abcabba"), string("cbabac"), 5, sink), ());
|
||||
TEST_EQUAL(-1, diff::DiffMyersSimple(string("abcabba"), string("cbabac"), 4, sink), ());
|
||||
TEST_EQUAL(-1, diff::DiffMyersSimple(string("abcabba"), string("cbabac"), 2, sink), ());
|
||||
TEST_EQUAL(-1, diff::DiffMyersSimple(string("abcabba"), string("cbabac"), 1, sink), ());
|
||||
@@ -30,21 +30,16 @@ UNIT_TEST(MyersSimpleDiff)
|
||||
class TestPatchWriter
|
||||
{
|
||||
public:
|
||||
template <typename IterT> void WriteData(IterT it, uint64_t n)
|
||||
template <typename IterT>
|
||||
void WriteData(IterT it, uint64_t n)
|
||||
{
|
||||
for (uint64_t i = 0; i < n; ++i, ++it)
|
||||
m_Stream << *it;
|
||||
}
|
||||
|
||||
void WriteOperation(uint64_t op)
|
||||
{
|
||||
m_Stream << op << ".";
|
||||
}
|
||||
void WriteOperation(uint64_t op) { m_Stream << op << "."; }
|
||||
|
||||
string Str()
|
||||
{
|
||||
return m_Stream.str();
|
||||
}
|
||||
string Str() { return m_Stream.str(); }
|
||||
|
||||
private:
|
||||
ostringstream m_Stream;
|
||||
@@ -113,7 +108,8 @@ public:
|
||||
m_Stream << "-" << n << ".";
|
||||
}
|
||||
|
||||
template <typename IterT> void Insert(IterT it, size_t n)
|
||||
template <typename IterT>
|
||||
void Insert(IterT it, size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
return;
|
||||
@@ -124,6 +120,7 @@ public:
|
||||
}
|
||||
void Finalize() {}
|
||||
string Str() { return m_Stream.str(); }
|
||||
|
||||
private:
|
||||
ostringstream m_Stream;
|
||||
};
|
||||
@@ -134,8 +131,8 @@ UNIT_TEST(DiffSimpleReplace)
|
||||
char const dst[] = "abcyydef";
|
||||
MemReader srcReader(src, ARRAY_SIZE(src) - 1);
|
||||
MemReader dstReader(dst, ARRAY_SIZE(dst) - 1);
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
|
||||
diff::SimpleReplaceDiffer differ;
|
||||
|
||||
@@ -156,8 +153,8 @@ UNIT_TEST(DiffSimpleReplaceEmptyBegin)
|
||||
char const dst[] = "yydef";
|
||||
MemReader srcReader(src, ARRAY_SIZE(src) - 1);
|
||||
MemReader dstReader(dst, ARRAY_SIZE(dst) - 1);
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
|
||||
diff::SimpleReplaceDiffer differ;
|
||||
|
||||
@@ -178,8 +175,8 @@ UNIT_TEST(DiffSimpleReplaceEmptyEnd)
|
||||
char const dst[] = "abcyy";
|
||||
MemReader srcReader(src, ARRAY_SIZE(src) - 1);
|
||||
MemReader dstReader(dst, ARRAY_SIZE(dst) - 1);
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
|
||||
diff::SimpleReplaceDiffer differ;
|
||||
|
||||
@@ -200,8 +197,8 @@ UNIT_TEST(DiffSimpleReplaceAllEqual)
|
||||
char const dst[] = "abcdef";
|
||||
MemReader srcReader(src, ARRAY_SIZE(src) - 1);
|
||||
MemReader dstReader(dst, ARRAY_SIZE(dst) - 1);
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
|
||||
diff::SimpleReplaceDiffer differ;
|
||||
|
||||
@@ -222,8 +219,8 @@ UNIT_TEST(DiffWithRollingHashEqualStrings)
|
||||
char const dst[] = "abcdefklmno";
|
||||
MemReader srcReader(src, ARRAY_SIZE(src) - 1);
|
||||
MemReader dstReader(dst, ARRAY_SIZE(dst) - 1);
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
|
||||
diff::RollingHashDiffer<diff::SimpleReplaceDiffer, RollingHasher64> differ(3);
|
||||
|
||||
@@ -238,8 +235,8 @@ UNIT_TEST(DiffWithRollingHashCompletelyDifferentStrings)
|
||||
char const dst[] = "abcdefgh";
|
||||
MemReader srcReader(src, ARRAY_SIZE(src) - 1);
|
||||
MemReader dstReader(dst, ARRAY_SIZE(dst) - 1);
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
|
||||
diff::RollingHashDiffer<diff::SimpleReplaceDiffer, RollingHasher64> differ(3);
|
||||
|
||||
@@ -254,8 +251,8 @@ UNIT_TEST(DiffWithRollingHash1)
|
||||
char const dst[] = "abcdfeghikkklmnop";
|
||||
MemReader srcReader(src, ARRAY_SIZE(src) - 1);
|
||||
MemReader dstReader(dst, ARRAY_SIZE(dst) - 1);
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
|
||||
diff::RollingHashDiffer<diff::SimpleReplaceDiffer, RollingHasher64> differ(3);
|
||||
|
||||
@@ -270,8 +267,8 @@ UNIT_TEST(DiffWithRollingHash2)
|
||||
char const dst[] = "abxdeflmnop";
|
||||
MemReader srcReader(src, ARRAY_SIZE(src) - 1);
|
||||
MemReader dstReader(dst, ARRAY_SIZE(dst) - 1);
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> srcV(srcReader); // since sizeof(char) == 1
|
||||
DDVector<char, MemReader> dstV(dstReader); // since sizeof(char) == 1
|
||||
|
||||
diff::RollingHashDiffer<diff::SimpleReplaceDiffer, RollingHasher64> differ(3);
|
||||
|
||||
|
||||
@@ -51,6 +51,12 @@ void TestCoder(std::string const & name)
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(EliasCoder_Gamma) { TestCoder<coding::GammaCoder>("Gamma"); }
|
||||
UNIT_TEST(EliasCoder_Delta) { TestCoder<coding::DeltaCoder>("Delta"); }
|
||||
UNIT_TEST(EliasCoder_Gamma)
|
||||
{
|
||||
TestCoder<coding::GammaCoder>("Gamma");
|
||||
}
|
||||
UNIT_TEST(EliasCoder_Delta)
|
||||
{
|
||||
TestCoder<coding::DeltaCoder>("Delta");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -2,40 +2,39 @@
|
||||
|
||||
#include "coding/endianness.hpp"
|
||||
|
||||
|
||||
UNIT_TEST(Endianness1Byte)
|
||||
{
|
||||
TEST_EQUAL(uint8_t(0), ReverseByteOrder<uint8_t>(0), ());
|
||||
TEST_EQUAL(uint8_t(17), ReverseByteOrder<uint8_t>(17), ());
|
||||
TEST_EQUAL(uint8_t(0), ReverseByteOrder<uint8_t>(0), ());
|
||||
TEST_EQUAL(uint8_t(17), ReverseByteOrder<uint8_t>(17), ());
|
||||
TEST_EQUAL(uint8_t(255), ReverseByteOrder<uint8_t>(255), ());
|
||||
|
||||
TEST_EQUAL(uint8_t(0), ReverseByteOrder<uint8_t>(0), ());
|
||||
TEST_EQUAL(uint8_t(17), ReverseByteOrder<uint8_t>(17), ());
|
||||
TEST_EQUAL(uint8_t(0), ReverseByteOrder<uint8_t>(0), ());
|
||||
TEST_EQUAL(uint8_t(17), ReverseByteOrder<uint8_t>(17), ());
|
||||
TEST_EQUAL(uint8_t(255), ReverseByteOrder<uint8_t>(255), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(Endianness12Bytes)
|
||||
{
|
||||
TEST_EQUAL(uint16_t(0), ReverseByteOrder<uint16_t>(0), ());
|
||||
TEST_EQUAL(uint16_t(256), ReverseByteOrder<uint16_t>(1), ());
|
||||
TEST_EQUAL(uint16_t(0), ReverseByteOrder<uint16_t>(0), ());
|
||||
TEST_EQUAL(uint16_t(256), ReverseByteOrder<uint16_t>(1), ());
|
||||
TEST_EQUAL(uint16_t(0xE8FD), ReverseByteOrder<uint16_t>(0xFDE8), ());
|
||||
TEST_EQUAL(uint16_t(0xFFFF), ReverseByteOrder<uint16_t>(0xFFFF), ());
|
||||
|
||||
TEST_EQUAL(uint16_t(0), ReverseByteOrder<uint16_t>(0), ());
|
||||
TEST_EQUAL(uint16_t(256), ReverseByteOrder<uint16_t>(1), ());
|
||||
TEST_EQUAL(uint16_t(0), ReverseByteOrder<uint16_t>(0), ());
|
||||
TEST_EQUAL(uint16_t(256), ReverseByteOrder<uint16_t>(1), ());
|
||||
TEST_EQUAL(uint16_t(0xE8FD), ReverseByteOrder<uint16_t>(0xFDE8), ());
|
||||
TEST_EQUAL(uint16_t(0xFFFF), ReverseByteOrder<uint16_t>(0xFFFF), ());
|
||||
}
|
||||
|
||||
UNIT_TEST(Endianness18Bytes)
|
||||
{
|
||||
TEST_EQUAL(0ULL, ReverseByteOrder(0ULL), ());
|
||||
TEST_EQUAL(1ULL, ReverseByteOrder(1ULL << 56), ());
|
||||
TEST_EQUAL(0xE2E4D7D5B1C3B8C6ULL, ReverseByteOrder(0xC6B8C3B1D5D7E4E2ULL), ());
|
||||
TEST_EQUAL(0xFFFFFFFFFFFFFFFFULL, ReverseByteOrder(0xFFFFFFFFFFFFFFFFULL), ());
|
||||
TEST_EQUAL(0ULL, ReverseByteOrder(0ULL), ());
|
||||
TEST_EQUAL(1ULL, ReverseByteOrder(1ULL << 56), ());
|
||||
TEST_EQUAL(0xE2E4D7D5B1C3B8C6ULL, ReverseByteOrder(0xC6B8C3B1D5D7E4E2ULL), ());
|
||||
TEST_EQUAL(0xFFFFFFFFFFFFFFFFULL, ReverseByteOrder(0xFFFFFFFFFFFFFFFFULL), ());
|
||||
|
||||
TEST_EQUAL(0ULL, ReverseByteOrder(0ULL), ());
|
||||
TEST_EQUAL(1ULL, ReverseByteOrder(1ULL << 56), ());
|
||||
TEST_EQUAL(0xE2E4D7D5B1C3B8C6ULL, ReverseByteOrder(0xC6B8C3B1D5D7E4E2ULL), ());
|
||||
TEST_EQUAL(0xFFFFFFFFFFFFFFFFULL, ReverseByteOrder(0xFFFFFFFFFFFFFFFFULL), ());
|
||||
TEST_EQUAL(0ULL, ReverseByteOrder(0ULL), ());
|
||||
TEST_EQUAL(1ULL, ReverseByteOrder(1ULL << 56), ());
|
||||
TEST_EQUAL(0xE2E4D7D5B1C3B8C6ULL, ReverseByteOrder(0xC6B8C3B1D5D7E4E2ULL), ());
|
||||
TEST_EQUAL(0xFFFFFFFFFFFFFFFFULL, ReverseByteOrder(0xFFFFFFFFFFFFFFFFULL), ());
|
||||
}
|
||||
|
||||
@@ -6,36 +6,35 @@
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace file_data_test
|
||||
{
|
||||
std::string const name1 = "test1.file";
|
||||
std::string const name2 = "test2.file";
|
||||
std::string const name1 = "test1.file";
|
||||
std::string const name2 = "test2.file";
|
||||
|
||||
void MakeFile(std::string const & name)
|
||||
{
|
||||
base::FileData f(name, base::FileData::Op::WRITE_TRUNCATE);
|
||||
f.Write(name.c_str(), name.size());
|
||||
}
|
||||
void MakeFile(std::string const & name)
|
||||
{
|
||||
base::FileData f(name, base::FileData::Op::WRITE_TRUNCATE);
|
||||
f.Write(name.c_str(), name.size());
|
||||
}
|
||||
|
||||
void MakeFile(std::string const & name, size_t const size, const char c)
|
||||
{
|
||||
base::FileData f(name, base::FileData::Op::WRITE_TRUNCATE);
|
||||
f.Write(std::string(size, c).c_str(), size);
|
||||
}
|
||||
void MakeFile(std::string const & name, size_t const size, char const c)
|
||||
{
|
||||
base::FileData f(name, base::FileData::Op::WRITE_TRUNCATE);
|
||||
f.Write(std::string(size, c).c_str(), size);
|
||||
}
|
||||
|
||||
#ifdef OMIM_OS_WINDOWS
|
||||
void CheckFileOK(std::string const & name)
|
||||
{
|
||||
base::FileData f(name, base::FileData::Op::READ);
|
||||
void CheckFileOK(std::string const & name)
|
||||
{
|
||||
base::FileData f(name, base::FileData::Op::READ);
|
||||
|
||||
uint64_t const size = f.Size();
|
||||
TEST_EQUAL ( size, name.size(), () );
|
||||
uint64_t const size = f.Size();
|
||||
TEST_EQUAL(size, name.size(), ());
|
||||
|
||||
std::vector<char> buffer(size);
|
||||
f.Read(0, &buffer[0], size);
|
||||
TEST ( equal(name.begin(), name.end(), buffer.begin()), () );
|
||||
}
|
||||
std::vector<char> buffer(size);
|
||||
f.Read(0, &buffer[0], size);
|
||||
TEST(equal(name.begin(), name.end(), buffer.begin()), ());
|
||||
}
|
||||
#endif
|
||||
|
||||
UNIT_TEST(FileData_ApiSmoke)
|
||||
@@ -202,7 +201,7 @@ UNIT_TEST(EmptyFile)
|
||||
|
||||
// Do copy.
|
||||
TEST(CopyFileX(name, copy), ());
|
||||
//TEST(!RenameFileX(name, copy), ());
|
||||
// TEST(!RenameFileX(name, copy), ());
|
||||
|
||||
// Delete copy file and rename name -> copy.
|
||||
TEST(DeleteFileX(copy), ());
|
||||
@@ -252,7 +251,7 @@ UNIT_TEST(File_StdGetLine)
|
||||
{
|
||||
std::string const fName = "test.txt";
|
||||
|
||||
for (char const * buffer : { "x\nxy\nxyz\nxyzk", "x\nxy\nxyz\nxyzk\n" })
|
||||
for (char const * buffer : {"x\nxy\nxyz\nxyzk", "x\nxy\nxyz\nxyzk\n"})
|
||||
{
|
||||
{
|
||||
base::FileData f(fName, base::FileData::Op::WRITE_TRUNCATE);
|
||||
@@ -276,4 +275,4 @@ UNIT_TEST(File_StdGetLine)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace file_data_test
|
||||
} // namespace file_data_test
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/file_sort.hpp"
|
||||
#include "coding/write_to_sink.hpp"
|
||||
#include "coding/reader.hpp"
|
||||
#include "coding/write_to_sink.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
@@ -14,27 +14,27 @@ using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
void TestFileSorter(vector<uint32_t> & data, char const * tmpFileName, size_t bufferSize)
|
||||
{
|
||||
vector<char> serial;
|
||||
typedef MemWriter<vector<char> > MemWriterType;
|
||||
MemWriterType writer(serial);
|
||||
typedef WriterFunctor<MemWriterType> OutT;
|
||||
OutT out(writer);
|
||||
FileSorter<uint32_t, OutT> sorter(bufferSize, tmpFileName, out);
|
||||
for (size_t i = 0; i < data.size(); ++i)
|
||||
sorter.Add(data[i]);
|
||||
sorter.SortAndFinish();
|
||||
void TestFileSorter(vector<uint32_t> & data, char const * tmpFileName, size_t bufferSize)
|
||||
{
|
||||
vector<char> serial;
|
||||
typedef MemWriter<vector<char>> MemWriterType;
|
||||
MemWriterType writer(serial);
|
||||
typedef WriterFunctor<MemWriterType> OutT;
|
||||
OutT out(writer);
|
||||
FileSorter<uint32_t, OutT> sorter(bufferSize, tmpFileName, out);
|
||||
for (size_t i = 0; i < data.size(); ++i)
|
||||
sorter.Add(data[i]);
|
||||
sorter.SortAndFinish();
|
||||
|
||||
TEST_EQUAL(serial.size(), data.size() * sizeof(data[0]), ());
|
||||
sort(data.begin(), data.end());
|
||||
MemReader reader(&serial[0], serial.size());
|
||||
TEST_EQUAL(reader.Size(), data.size() * sizeof(data[0]), ());
|
||||
vector<uint32_t> result(data.size());
|
||||
reader.Read(0, &result[0], reader.Size());
|
||||
TEST_EQUAL(result, data, ());
|
||||
}
|
||||
TEST_EQUAL(serial.size(), data.size() * sizeof(data[0]), ());
|
||||
sort(data.begin(), data.end());
|
||||
MemReader reader(&serial[0], serial.size());
|
||||
TEST_EQUAL(reader.Size(), data.size() * sizeof(data[0]), ());
|
||||
vector<uint32_t> result(data.size());
|
||||
reader.Read(0, &result[0], reader.Size());
|
||||
TEST_EQUAL(result, data, ());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(FileSorter_Smoke)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "coding/varint.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
#include "base/scope_guard.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
#include "std/target_os.hpp"
|
||||
|
||||
@@ -56,7 +56,7 @@ UNIT_TEST(FilesContainer_Smoke)
|
||||
}
|
||||
|
||||
// append to container
|
||||
uint32_t const arrAppend[] = { 888, 777, 666 };
|
||||
uint32_t const arrAppend[] = {888, 777, 666};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(arrAppend); ++i)
|
||||
{
|
||||
{
|
||||
@@ -82,12 +82,12 @@ UNIT_TEST(FilesContainer_Smoke)
|
||||
|
||||
namespace
|
||||
{
|
||||
void CheckInvariant(FilesContainerR & reader, string const & tag, int64_t test)
|
||||
{
|
||||
FilesContainerR::TReader r = reader.GetReader(tag);
|
||||
TEST_EQUAL(test, ReadPrimitiveFromPos<int64_t>(r, 0), ());
|
||||
}
|
||||
void CheckInvariant(FilesContainerR & reader, string const & tag, int64_t test)
|
||||
{
|
||||
FilesContainerR::TReader r = reader.GetReader(tag);
|
||||
TEST_EQUAL(test, ReadPrimitiveFromPos<int64_t>(r, 0), ());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(FilesContainer_Shared)
|
||||
{
|
||||
@@ -147,43 +147,41 @@ UNIT_TEST(FilesContainer_Shared)
|
||||
|
||||
namespace
|
||||
{
|
||||
void ReplaceInContainer(string const & fName,
|
||||
char const * key, char const * value)
|
||||
void ReplaceInContainer(string const & fName, char const * key, char const * value)
|
||||
{
|
||||
FilesContainerW writer(fName, FileWriter::OP_WRITE_EXISTING);
|
||||
auto w = writer.GetWriter(key);
|
||||
w->Write(value, strlen(value));
|
||||
}
|
||||
|
||||
void CheckContainer(string const & fName, char const * key[], char const * value[], size_t count)
|
||||
{
|
||||
FilesContainerR reader(fName);
|
||||
LOG(LINFO, ("Size=", reader.GetFileSize()));
|
||||
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
FilesContainerW writer(fName, FileWriter::OP_WRITE_EXISTING);
|
||||
auto w = writer.GetWriter(key);
|
||||
w->Write(value, strlen(value));
|
||||
}
|
||||
FilesContainerR::TReader r = reader.GetReader(key[i]);
|
||||
|
||||
void CheckContainer(string const & fName,
|
||||
char const * key[], char const * value[], size_t count)
|
||||
{
|
||||
FilesContainerR reader(fName);
|
||||
LOG(LINFO, ("Size=", reader.GetFileSize()));
|
||||
size_t const szBuffer = 100;
|
||||
size_t const szS = strlen(value[i]);
|
||||
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
FilesContainerR::TReader r = reader.GetReader(key[i]);
|
||||
char s[szBuffer] = {0};
|
||||
ASSERT_LESS(szS, szBuffer, ());
|
||||
r.Read(0, s, szS);
|
||||
|
||||
size_t const szBuffer = 100;
|
||||
size_t const szS = strlen(value[i]);
|
||||
|
||||
char s[szBuffer] = { 0 };
|
||||
ASSERT_LESS ( szS, szBuffer, () );
|
||||
r.Read(0, s, szS);
|
||||
|
||||
TEST(strcmp(value[i], s) == 0, (s));
|
||||
}
|
||||
TEST(strcmp(value[i], s) == 0, (s));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(FilesContainer_RewriteExisting)
|
||||
{
|
||||
string const fName = "files_container.tmp";
|
||||
FileWriter::DeleteFileX(fName);
|
||||
|
||||
char const * key[] = { "3", "2", "1" };
|
||||
char const * value[] = { "prolog", "data", "epilog" };
|
||||
char const * key[] = {"3", "2", "1"};
|
||||
char const * value[] = {"prolog", "data", "epilog"};
|
||||
|
||||
// fill container
|
||||
{
|
||||
@@ -199,19 +197,19 @@ UNIT_TEST(FilesContainer_RewriteExisting)
|
||||
// re-write middle file in container
|
||||
char const * buffer1 = "xxxxxxx";
|
||||
ReplaceInContainer(fName, key[1], buffer1);
|
||||
char const * value1[] = { value[0], buffer1, value[2] };
|
||||
char const * value1[] = {value[0], buffer1, value[2]};
|
||||
CheckContainer(fName, key, value1, 3);
|
||||
|
||||
// re-write end file in container
|
||||
char const * buffer2 = "yyyyyyyyyyyyyy";
|
||||
ReplaceInContainer(fName, key[2], buffer2);
|
||||
char const * value2[] = { value[0], buffer1, buffer2 };
|
||||
char const * value2[] = {value[0], buffer1, buffer2};
|
||||
CheckContainer(fName, key, value2, 3);
|
||||
|
||||
// re-write end file in container once again
|
||||
char const * buffer3 = "zzz";
|
||||
ReplaceInContainer(fName, key[2], buffer3);
|
||||
char const * value3[] = { value[0], buffer1, buffer3 };
|
||||
char const * value3[] = {value[0], buffer1, buffer3};
|
||||
CheckContainer(fName, key, value3, 3);
|
||||
|
||||
FileWriter::DeleteFileX(fName);
|
||||
@@ -334,7 +332,7 @@ UNIT_TEST(FilesMappingContainer_MoveHandle)
|
||||
UNIT_TEST(FilesMappingContainer_Smoke)
|
||||
{
|
||||
string const fName = "files_container.tmp";
|
||||
char const * key[] = { "3", "2", "1" };
|
||||
char const * key[] = {"3", "2", "1"};
|
||||
uint32_t const count = 1000000;
|
||||
|
||||
// fill container
|
||||
@@ -385,9 +383,9 @@ UNIT_TEST(FilesMappingContainer_PageSize)
|
||||
#endif
|
||||
LOG(LINFO, ("Page size:", pageSize));
|
||||
|
||||
char const * key[] = { "3", "2", "1" };
|
||||
char const byte[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g' };
|
||||
size_t count[] = { pageSize-1, pageSize, pageSize+1 };
|
||||
char const * key[] = {"3", "2", "1"};
|
||||
char const byte[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g'};
|
||||
size_t count[] = {pageSize - 1, pageSize, pageSize + 1};
|
||||
size_t const sz = ARRAY_SIZE(key);
|
||||
|
||||
{
|
||||
|
||||
@@ -12,7 +12,8 @@ using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
template <size_t Bits> void TestWithData(vector<uint32_t> const & lst)
|
||||
template <size_t Bits>
|
||||
void TestWithData(vector<uint32_t> const & lst)
|
||||
{
|
||||
using TVector = FixedBitsDDVector<Bits, MemReader>;
|
||||
using TBuffer = vector<uint8_t>;
|
||||
@@ -50,7 +51,7 @@ template <size_t Bits> void TestWithData(vector<uint32_t> const & lst)
|
||||
++i;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(FixedBitsDDVector_Smoke)
|
||||
{
|
||||
|
||||
@@ -26,12 +26,17 @@ using PD = m2::PointD;
|
||||
|
||||
namespace
|
||||
{
|
||||
m2::PointU D2U(m2::PointD const & p) { return PointDToPointU(p, kPointCoordBits); }
|
||||
m2::PointU D2U(m2::PointD const & p)
|
||||
{
|
||||
return PointDToPointU(p, kPointCoordBits);
|
||||
}
|
||||
|
||||
m2::PointU GetMaxPoint() { return D2U(m2::PointD(mercator::Bounds::kMaxX, mercator::Bounds::kMaxY)); }
|
||||
m2::PointU GetMaxPoint()
|
||||
{
|
||||
return D2U(m2::PointD(mercator::Bounds::kMaxX, mercator::Bounds::kMaxY));
|
||||
}
|
||||
|
||||
void TestPolylineEncode(string testName, vector<m2::PointU> const & points,
|
||||
m2::PointU const & maxPoint,
|
||||
void TestPolylineEncode(string testName, vector<m2::PointU> const & points, m2::PointU const & maxPoint,
|
||||
void (*fnEncode)(InPointsT const & points, m2::PointU const & basePoint,
|
||||
m2::PointU const & maxPoint, OutDeltasT & deltas),
|
||||
void (*fnDecode)(InDeltasT const & deltas, m2::PointU const & basePoint,
|
||||
@@ -161,9 +166,8 @@ UNIT_TEST(EncodePolyline)
|
||||
vector<m2::PointU> points;
|
||||
points.reserve(polygonSize);
|
||||
for (size_t i = 0; i < polygonSize; ++i)
|
||||
points.push_back(
|
||||
m2::PointU(static_cast<uint32_t>(LargePolygon::kLargePolygon[i].x * 10000),
|
||||
static_cast<uint32_t>((LargePolygon::kLargePolygon[i].y + 200) * 10000)));
|
||||
points.push_back(m2::PointU(static_cast<uint32_t>(LargePolygon::kLargePolygon[i].x * 10000),
|
||||
static_cast<uint32_t>((LargePolygon::kLargePolygon[i].y + 200) * 10000)));
|
||||
|
||||
TestEncodePolyline("Unsimp", maxPoint, points);
|
||||
TestEncodePolyline("1simp", maxPoint, SimplifyPoints(points, 1));
|
||||
|
||||
@@ -29,8 +29,8 @@ bool IsEqual(m2::PointD const & p1, m2::PointD const & p2)
|
||||
|
||||
bool IsEqual(m2::RectD const & r1, m2::RectD const & r2)
|
||||
{
|
||||
return (IsEqual(r1.minX(), r2.minX()) && IsEqual(r1.minY(), r2.minY()) &&
|
||||
IsEqual(r1.maxX(), r2.maxX()) && IsEqual(r1.maxY(), r2.maxY()));
|
||||
return (IsEqual(r1.minX(), r2.minX()) && IsEqual(r1.minY(), r2.minY()) && IsEqual(r1.maxX(), r2.maxX()) &&
|
||||
IsEqual(r1.maxY(), r2.maxY()));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ UNIT_TEST(RandomRecode)
|
||||
|
||||
UNIT_TEST(EncodeNumber)
|
||||
{
|
||||
TEST_EQUAL(NumToHex(uint64_t(0x0123456789ABCDEFULL)),
|
||||
"0123456789ABCDEF", ());
|
||||
TEST_EQUAL(NumToHex(uint64_t(0x0123456789ABCDEFULL)), "0123456789ABCDEF", ());
|
||||
}
|
||||
|
||||
UNIT_TEST(DecodeLowerCaseHex)
|
||||
|
||||
@@ -85,8 +85,7 @@ UNIT_TEST(Huffman_Init)
|
||||
UNIT_TEST(Huffman_Serialization_Encoding)
|
||||
{
|
||||
HuffmanCoder hW;
|
||||
hW.Init(MakeUniStringVector(
|
||||
vector<string>{"aaaaaaaaaa", "bbbbbbbbbb", "ccccc", "ddddd"})); // 10, 10, 5, 5
|
||||
hW.Init(MakeUniStringVector(vector<string>{"aaaaaaaaaa", "bbbbbbbbbb", "ccccc", "ddddd"})); // 10, 10, 5, 5
|
||||
vector<uint8_t> buf;
|
||||
MemWriter<vector<uint8_t>> writer(buf);
|
||||
hW.WriteEncoding(writer);
|
||||
@@ -112,8 +111,7 @@ UNIT_TEST(Huffman_Serialization_Encoding)
|
||||
UNIT_TEST(Huffman_Serialization_Data)
|
||||
{
|
||||
HuffmanCoder hW;
|
||||
hW.Init(MakeUniStringVector(
|
||||
vector<string>{"aaaaaaaaaa", "bbbbbbbbbb", "ccccc", "ddddd"})); // 10, 10, 5, 5
|
||||
hW.Init(MakeUniStringVector(vector<string>{"aaaaaaaaaa", "bbbbbbbbbb", "ccccc", "ddddd"})); // 10, 10, 5, 5
|
||||
vector<uint8_t> buf;
|
||||
|
||||
string const data = "abacabaddddaaabbcabacabadbabd";
|
||||
|
||||
@@ -86,8 +86,8 @@ UNIT_TEST(MapUint32Val_Smoke)
|
||||
|
||||
{
|
||||
MemReader reader(buffer.data(), buffer.size());
|
||||
auto table = MapUint32ToValue<uint32_t>::Load(reader, [](NonOwningReaderSource & source, uint32_t blockSize,
|
||||
ValuesT & values)
|
||||
auto table = MapUint32ToValue<uint32_t>::Load(
|
||||
reader, [](NonOwningReaderSource & source, uint32_t blockSize, ValuesT & values)
|
||||
{
|
||||
values.reserve(blockSize);
|
||||
while (source.Size() > 0)
|
||||
@@ -105,4 +105,4 @@ UNIT_TEST(MapUint32Val_Smoke)
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace map_uint32_tests
|
||||
} // namespace map_uint32_tests
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/reader.hpp"
|
||||
#include "base/macros.hpp"
|
||||
#include "coding/reader.hpp"
|
||||
|
||||
UNIT_TEST(MemReaderSimple)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/writer.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/writer.hpp"
|
||||
|
||||
#include "base/macros.hpp"
|
||||
|
||||
@@ -25,6 +25,6 @@ UNIT_TEST(MemWriterSimple)
|
||||
writer.Write("world!", 6);
|
||||
|
||||
char const expected[] = "Hello,world!";
|
||||
TEST_EQUAL(data.size(), ARRAY_SIZE(expected)-1, ());
|
||||
TEST_EQUAL(data.size(), ARRAY_SIZE(expected) - 1, ());
|
||||
TEST(equal(data.begin(), data.end(), &expected[0]), (data));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void loadFile(vector<unsigned char> & buffer, string const & filename) //designed for loading files from hard disk in an std::vector
|
||||
void loadFile(vector<unsigned char> & buffer,
|
||||
string const & filename) // designed for loading files from hard disk in an std::vector
|
||||
{
|
||||
ifstream file(filename.c_str(), ios::in | ios::binary | ios::ate);
|
||||
|
||||
@@ -21,7 +22,7 @@ void loadFile(vector<unsigned char> & buffer, string const & filename) //designe
|
||||
if (size > 0)
|
||||
{
|
||||
buffer.resize((size_t)size);
|
||||
file.read((char*)(&buffer[0]), size);
|
||||
file.read((char *)(&buffer[0]), size);
|
||||
}
|
||||
else
|
||||
buffer.clear();
|
||||
@@ -29,16 +30,16 @@ void loadFile(vector<unsigned char> & buffer, string const & filename) //designe
|
||||
|
||||
UNIT_TEST(PngDecode)
|
||||
{
|
||||
// // load and decode
|
||||
// vector<unsigned char> buffer, image;
|
||||
// loadFile(buffer, "../../data/font_0.png");
|
||||
// unsigned long w, h;
|
||||
// int error = DecodePNG(image, w, h, buffer.empty() ? 0 : &buffer[0], (unsigned long)buffer.size());
|
||||
//
|
||||
// // if there's an error, display it
|
||||
// TEST_EQUAL(error, 0, ());
|
||||
// // the pixels are now in the vector "image", use it as texture, draw it, ...
|
||||
// TEST_GREATER(image.size(), 4, ("Image is empty???"));
|
||||
// TEST_EQUAL(w, 1024, ());
|
||||
// TEST_EQUAL(h, 1024, ());
|
||||
// // load and decode
|
||||
// vector<unsigned char> buffer, image;
|
||||
// loadFile(buffer, "../../data/font_0.png");
|
||||
// unsigned long w, h;
|
||||
// int error = DecodePNG(image, w, h, buffer.empty() ? 0 : &buffer[0], (unsigned long)buffer.size());
|
||||
//
|
||||
// // if there's an error, display it
|
||||
// TEST_EQUAL(error, 0, ());
|
||||
// // the pixels are now in the vector "image", use it as texture, draw it, ...
|
||||
// TEST_GREATER(image.size(), 4, ("Image is empty???"));
|
||||
// TEST_EQUAL(w, 1024, ());
|
||||
// TEST_EQUAL(h, 1024, ());
|
||||
}
|
||||
|
||||
@@ -51,9 +51,7 @@ UNIT_TEST(PointDToPointU_Epsilons)
|
||||
for (; i < count; ++i)
|
||||
{
|
||||
m2::PointU p0 = PointDToPointU(arrPt[i].x, arrPt[i].y, kCoordBits);
|
||||
m2::PointU p1 = PointDToPointU(arrPt[i].x + arrD[i].x * eps,
|
||||
arrPt[i].y + arrD[i].y * eps,
|
||||
kCoordBits);
|
||||
m2::PointU p1 = PointDToPointU(arrPt[i].x + arrD[i].x * eps, arrPt[i].y + arrD[i].y * eps, kCoordBits);
|
||||
|
||||
if (p0 != p1)
|
||||
break;
|
||||
@@ -114,8 +112,7 @@ UNIT_TEST(PointToInt64Obsolete_Smoke)
|
||||
m2::PointD const arr[] = {{1.25, 1.3}, {180, 90}, {-180, -90}, {0, 0}};
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
|
||||
CheckEqualPoints(arr[i],
|
||||
Int64ToPointObsolete(PointToInt64Obsolete(arr[i], kCoordBits), kCoordBits));
|
||||
CheckEqualPoints(arr[i], Int64ToPointObsolete(PointToInt64Obsolete(arr[i], kCoordBits), kCoordBits));
|
||||
}
|
||||
|
||||
UNIT_TEST(PointToInt64Obsolete_Grid)
|
||||
@@ -151,11 +148,9 @@ UNIT_TEST(PointToInt64Obsolete_Bounds)
|
||||
for (size_t iY = 0; iY < ARRAY_SIZE(arrEps); ++iY)
|
||||
{
|
||||
m2::PointD const pt(arrPt[iP].x + arrEps[iX], arrPt[iP].y + arrEps[iY]);
|
||||
m2::PointD const pt1 =
|
||||
Int64ToPointObsolete(PointToInt64Obsolete(pt, kCoordBits), kCoordBits);
|
||||
m2::PointD const pt1 = Int64ToPointObsolete(PointToInt64Obsolete(pt, kCoordBits), kCoordBits);
|
||||
|
||||
TEST(fabs(pt.x - pt1.x) <= (fabs(arrEps[iX]) + kEps) &&
|
||||
fabs(pt.y - pt1.y) <= (fabs(arrEps[iY]) + kEps),
|
||||
TEST(fabs(pt.x - pt1.x) <= (fabs(arrEps[iX]) + kEps) && fabs(pt.y - pt1.y) <= (fabs(arrEps[iY]) + kEps),
|
||||
(pt, pt1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/reader_cache.hpp"
|
||||
#include "coding/reader.hpp"
|
||||
#include "coding/reader_cache.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
@@ -12,21 +12,22 @@ using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class ReaderT> class CacheReader
|
||||
{
|
||||
public:
|
||||
CacheReader(ReaderT const & reader, uint32_t logPageSize, uint32_t logPageCount)
|
||||
: m_Reader(reader), m_Cache(logPageSize, logPageCount) {}
|
||||
template <class ReaderT>
|
||||
class CacheReader
|
||||
{
|
||||
public:
|
||||
CacheReader(ReaderT const & reader, uint32_t logPageSize, uint32_t logPageCount)
|
||||
: m_Reader(reader)
|
||||
, m_Cache(logPageSize, logPageCount)
|
||||
{}
|
||||
|
||||
void Read(uint64_t pos, void * p, size_t size) const
|
||||
{
|
||||
m_Cache.Read(m_Reader, pos, p, size);
|
||||
}
|
||||
private:
|
||||
ReaderT m_Reader;
|
||||
ReaderCache<ReaderT const> mutable m_Cache;
|
||||
};
|
||||
}
|
||||
void Read(uint64_t pos, void * p, size_t size) const { m_Cache.Read(m_Reader, pos, p, size); }
|
||||
|
||||
private:
|
||||
ReaderT m_Reader;
|
||||
ReaderCache<ReaderT const> mutable m_Cache;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(CacheReaderRandomTest)
|
||||
{
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include "coding/coding_tests/reader_test.hpp"
|
||||
|
||||
#include "coding/buffer_reader.hpp"
|
||||
#include "coding/file_reader.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/buffer_reader.hpp"
|
||||
#include "coding/reader_streambuf.hpp"
|
||||
|
||||
#include <cstring>
|
||||
@@ -16,7 +16,7 @@ using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
string const kData("Quick brown fox jumps over a lazy dog...");
|
||||
string const kData("Quick brown fox jumps over a lazy dog...");
|
||||
}
|
||||
|
||||
UNIT_TEST(MemReaderSmokeTest)
|
||||
@@ -70,8 +70,7 @@ UNIT_TEST(FileReaderNonExistentFileTest)
|
||||
TEST(false, ("Exception should be thrown!"));
|
||||
}
|
||||
catch (FileReader::OpenException &)
|
||||
{
|
||||
}
|
||||
{}
|
||||
}
|
||||
|
||||
UNIT_TEST(FileReaderReadAsText)
|
||||
|
||||
@@ -8,21 +8,21 @@
|
||||
|
||||
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 <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());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
template <typename ReaderT>
|
||||
void TestReader(ReaderT const & reader)
|
||||
{
|
||||
@@ -49,4 +49,3 @@ void TestReader(ReaderT const & reader)
|
||||
ReadToStringFromSource(subReaderSource, d1, 6);
|
||||
TEST_EQUAL(d1, "fox ju", ());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/reader_writer_ops.hpp"
|
||||
#include "coding/byte_stream.hpp"
|
||||
#include "coding/file_reader.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/read_write_utils.hpp"
|
||||
#include "coding/byte_stream.hpp"
|
||||
#include "coding/reader_writer_ops.hpp"
|
||||
|
||||
#include "base/random.hpp"
|
||||
|
||||
@@ -17,43 +17,43 @@ using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
void GetReverseForReaderAndTmpFile(Reader const & src, vector<char> & buffer)
|
||||
void GetReverseForReaderAndTmpFile(Reader const & src, vector<char> & buffer)
|
||||
{
|
||||
char const * tmpFile = "reversed_file.tmp";
|
||||
|
||||
{
|
||||
char const * tmpFile = "reversed_file.tmp";
|
||||
|
||||
{
|
||||
FileWriter writer(tmpFile);
|
||||
rw_ops::Reverse(src, writer);
|
||||
}
|
||||
|
||||
{
|
||||
FileReader reader(tmpFile);
|
||||
buffer.clear();
|
||||
MemWriter<vector<char> > writer(buffer);
|
||||
rw_ops::Reverse(reader, writer);
|
||||
}
|
||||
|
||||
FileWriter::DeleteFileX(tmpFile);
|
||||
FileWriter writer(tmpFile);
|
||||
rw_ops::Reverse(src, writer);
|
||||
}
|
||||
|
||||
void FillRandFile(string const & fName, size_t count)
|
||||
{
|
||||
FileWriter writer(fName);
|
||||
FileReader reader(tmpFile);
|
||||
buffer.clear();
|
||||
MemWriter<vector<char>> writer(buffer);
|
||||
rw_ops::Reverse(reader, writer);
|
||||
}
|
||||
|
||||
base::UniformRandom<int8_t> rand;
|
||||
FileWriter::DeleteFileX(tmpFile);
|
||||
}
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
int8_t const c = rand();
|
||||
writer.Write(&c, 1);
|
||||
}
|
||||
void FillRandFile(string const & fName, size_t count)
|
||||
{
|
||||
FileWriter writer(fName);
|
||||
|
||||
base::UniformRandom<int8_t> rand;
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
int8_t const c = rand();
|
||||
writer.Write(&c, 1);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(Reverse_Smoke)
|
||||
{
|
||||
{
|
||||
char arr[] = { 0xA, 0xB, 0xC, 0xD, 0xF };
|
||||
char arr[] = {0xA, 0xB, 0xC, 0xD, 0xF};
|
||||
size_t const sz = ARRAY_SIZE(arr);
|
||||
|
||||
MemReader reader(&arr[0], sz);
|
||||
@@ -86,17 +86,17 @@ UNIT_TEST(Reverse_Smoke)
|
||||
|
||||
namespace
|
||||
{
|
||||
struct ThePOD
|
||||
{
|
||||
uint32_t m_i;
|
||||
double m_d;
|
||||
};
|
||||
struct ThePOD
|
||||
{
|
||||
uint32_t m_i;
|
||||
double m_d;
|
||||
};
|
||||
|
||||
bool operator==(ThePOD const & r1, ThePOD const & r2)
|
||||
{
|
||||
return (r1.m_i == r2.m_i && r1.m_d == r2.m_d);
|
||||
}
|
||||
bool operator==(ThePOD const & r1, ThePOD const & r2)
|
||||
{
|
||||
return (r1.m_i == r2.m_i && r1.m_d == r2.m_d);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(ReadWrite_POD)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ UNIT_TEST(ReadWrite_POD)
|
||||
}
|
||||
|
||||
vector<char> buffer;
|
||||
PushBackByteSink<vector<char> > sink(buffer);
|
||||
PushBackByteSink<vector<char>> sink(buffer);
|
||||
rw::WriteVectorOfPOD(sink, src);
|
||||
|
||||
buffer_vector<ThePOD, 128> dest;
|
||||
@@ -123,12 +123,11 @@ UNIT_TEST(ReadWrite_POD)
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class T> void TestIntegral()
|
||||
template <class T>
|
||||
void TestIntegral()
|
||||
{
|
||||
std::vector<T> ethalon{ static_cast<T>(-1), 0, 1,
|
||||
static_cast<T>(-2), 2,
|
||||
std::numeric_limits<T>::min(), std::numeric_limits<T>::max()
|
||||
};
|
||||
std::vector<T> ethalon{static_cast<T>(-1), 0, 1, static_cast<T>(-2), 2, std::numeric_limits<T>::min(),
|
||||
std::numeric_limits<T>::max()};
|
||||
|
||||
std::string buffer;
|
||||
MemWriter writer(buffer);
|
||||
@@ -141,7 +140,7 @@ template <class T> void TestIntegral()
|
||||
|
||||
TEST_EQUAL(ethalon, expected, ());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(ReadWrite_Integral)
|
||||
{
|
||||
@@ -151,4 +150,4 @@ UNIT_TEST(ReadWrite_Integral)
|
||||
TestIntegral<int64_t>();
|
||||
}
|
||||
|
||||
} // namespace rw_ops_tests
|
||||
} // namespace rw_ops_tests
|
||||
|
||||
@@ -44,8 +44,7 @@ bool TestSerDes(T const & value)
|
||||
}
|
||||
catch (base::Json::Exception const & exception)
|
||||
{
|
||||
LOG(LWARNING, ("Exception while parsing json string, reason:", exception.what(),
|
||||
"json:", jsonStr));
|
||||
LOG(LWARNING, ("Exception while parsing json string, reason:", exception.what(), "json:", jsonStr));
|
||||
return false;
|
||||
}
|
||||
return deserializedValue == value;
|
||||
@@ -61,16 +60,11 @@ enum class TestEnum
|
||||
|
||||
struct ValueTypes
|
||||
{
|
||||
DECLARE_VISITOR(visitor(m_boolValue, "boolValue"),
|
||||
visitor(m_uint8Value, "uint8Value"),
|
||||
visitor(m_uint32Value, "uint32Value"),
|
||||
visitor(m_uint64Value, "uint64Value"),
|
||||
visitor(m_int8Value, "int8Value"),
|
||||
visitor(m_int32Value, "int32Value"),
|
||||
visitor(m_int64Value, "int64Value"),
|
||||
visitor(m_doubleValue, "doubleValue"),
|
||||
visitor(m_stringValue, "stringValue"),
|
||||
visitor(m_enumValue, "enumValue"),
|
||||
DECLARE_VISITOR(visitor(m_boolValue, "boolValue"), visitor(m_uint8Value, "uint8Value"),
|
||||
visitor(m_uint32Value, "uint32Value"), visitor(m_uint64Value, "uint64Value"),
|
||||
visitor(m_int8Value, "int8Value"), visitor(m_int32Value, "int32Value"),
|
||||
visitor(m_int64Value, "int64Value"), visitor(m_doubleValue, "doubleValue"),
|
||||
visitor(m_stringValue, "stringValue"), visitor(m_enumValue, "enumValue"),
|
||||
visitor(m_timePointValue, "timePointValue"))
|
||||
|
||||
ValueTypes() = default;
|
||||
@@ -90,12 +84,11 @@ struct ValueTypes
|
||||
|
||||
bool operator==(ValueTypes const & rhs) const
|
||||
{
|
||||
return m_boolValue == rhs.m_boolValue && m_uint8Value == rhs.m_uint8Value &&
|
||||
m_uint32Value == rhs.m_uint32Value && m_uint64Value == rhs.m_uint64Value &&
|
||||
m_int8Value == rhs.m_int8Value && m_int32Value == rhs.m_int32Value &&
|
||||
m_int64Value == rhs.m_int64Value && m_doubleValue == rhs.m_doubleValue &&
|
||||
m_stringValue == rhs.m_stringValue && m_enumValue == rhs.m_enumValue &&
|
||||
m_timePointValue == rhs.m_timePointValue;
|
||||
return m_boolValue == rhs.m_boolValue && m_uint8Value == rhs.m_uint8Value && m_uint32Value == rhs.m_uint32Value &&
|
||||
m_uint64Value == rhs.m_uint64Value && m_int8Value == rhs.m_int8Value && m_int32Value == rhs.m_int32Value &&
|
||||
m_int64Value == rhs.m_int64Value && m_doubleValue == rhs.m_doubleValue &&
|
||||
m_stringValue == rhs.m_stringValue && m_enumValue == rhs.m_enumValue &&
|
||||
m_timePointValue == rhs.m_timePointValue;
|
||||
}
|
||||
|
||||
bool m_boolValue;
|
||||
@@ -113,8 +106,7 @@ struct ValueTypes
|
||||
|
||||
struct ObjectTypes
|
||||
{
|
||||
DECLARE_VISITOR(visitor(m_pointValue, "pointValue"),
|
||||
visitor(m_latLonValue, "latLonValue"),
|
||||
DECLARE_VISITOR(visitor(m_pointValue, "pointValue"), visitor(m_latLonValue, "latLonValue"),
|
||||
visitor(m_pairValue, "pairValue"))
|
||||
|
||||
ObjectTypes() = default;
|
||||
@@ -126,8 +118,7 @@ struct ObjectTypes
|
||||
|
||||
bool operator==(ObjectTypes const & rhs) const
|
||||
{
|
||||
return m_pointValue == rhs.m_pointValue && m_latLonValue == rhs.m_latLonValue &&
|
||||
m_pairValue == rhs.m_pairValue;
|
||||
return m_pointValue == rhs.m_pointValue && m_latLonValue == rhs.m_latLonValue && m_pairValue == rhs.m_pairValue;
|
||||
}
|
||||
|
||||
m2::PointD m_pointValue;
|
||||
@@ -137,8 +128,7 @@ struct ObjectTypes
|
||||
|
||||
struct PointerTypes
|
||||
{
|
||||
DECLARE_VISITOR(visitor(m_uniquePtrValue, "uniquePtrValue"),
|
||||
visitor(m_sharedPtrValue, "sharedPtrValue"))
|
||||
DECLARE_VISITOR(visitor(m_uniquePtrValue, "uniquePtrValue"), visitor(m_sharedPtrValue, "sharedPtrValue"))
|
||||
|
||||
PointerTypes() = default;
|
||||
PointerTypes(uint32_t testCounter)
|
||||
@@ -149,8 +139,7 @@ struct PointerTypes
|
||||
|
||||
bool operator==(PointerTypes const & rhs) const
|
||||
{
|
||||
return SamePtrValue(m_uniquePtrValue, rhs.m_uniquePtrValue) &&
|
||||
SamePtrValue(m_sharedPtrValue, rhs.m_sharedPtrValue);
|
||||
return SamePtrValue(m_uniquePtrValue, rhs.m_uniquePtrValue) && SamePtrValue(m_sharedPtrValue, rhs.m_sharedPtrValue);
|
||||
}
|
||||
|
||||
unique_ptr<ValueTypes> m_uniquePtrValue;
|
||||
@@ -159,10 +148,8 @@ struct PointerTypes
|
||||
|
||||
struct ArrayTypes
|
||||
{
|
||||
DECLARE_VISITOR(visitor(m_arrayValue, "arrayValue"),
|
||||
visitor(m_dequeValue, "dequeValue"),
|
||||
visitor(m_vectorValue, "vectorValue"),
|
||||
visitor(m_mapValue, "mapValue"),
|
||||
DECLARE_VISITOR(visitor(m_arrayValue, "arrayValue"), visitor(m_dequeValue, "dequeValue"),
|
||||
visitor(m_vectorValue, "vectorValue"), visitor(m_mapValue, "mapValue"),
|
||||
visitor(m_unorderedSetValue, "unorderedSetValue"))
|
||||
|
||||
ArrayTypes() = default;
|
||||
@@ -176,9 +163,8 @@ struct ArrayTypes
|
||||
|
||||
bool operator==(ArrayTypes const & rhs) const
|
||||
{
|
||||
return m_arrayValue == rhs.m_arrayValue && m_dequeValue == rhs.m_dequeValue &&
|
||||
m_vectorValue == rhs.m_vectorValue && m_mapValue == rhs.m_mapValue &&
|
||||
m_unorderedSetValue == rhs.m_unorderedSetValue;
|
||||
return m_arrayValue == rhs.m_arrayValue && m_dequeValue == rhs.m_dequeValue && m_vectorValue == rhs.m_vectorValue &&
|
||||
m_mapValue == rhs.m_mapValue && m_unorderedSetValue == rhs.m_unorderedSetValue;
|
||||
}
|
||||
|
||||
array<uint32_t, 3> m_arrayValue;
|
||||
@@ -233,16 +219,12 @@ UNIT_TEST(SerdesJsonTest)
|
||||
{
|
||||
struct Hasher
|
||||
{
|
||||
size_t operator()(pair<string, string> const & item) const
|
||||
{
|
||||
return m_hasher(item.first + item.second);
|
||||
}
|
||||
size_t operator()(pair<string, string> const & item) const { return m_hasher(item.first + item.second); }
|
||||
|
||||
hash<string> m_hasher;
|
||||
};
|
||||
|
||||
unordered_set<pair<string, string>, Hasher> testValue = {{"ab", "ab"}, {"ef", "ef"},
|
||||
{"cd", "cd"}};
|
||||
unordered_set<pair<string, string>, Hasher> testValue = {{"ab", "ab"}, {"ef", "ef"}, {"cd", "cd"}};
|
||||
TEST(TestSerDes(testValue), ());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,37 +2,43 @@
|
||||
|
||||
#include "coding/sha1.hpp"
|
||||
|
||||
|
||||
namespace sha1_test
|
||||
{
|
||||
using namespace coding;
|
||||
|
||||
UNIT_TEST(SHA1_Smoke)
|
||||
{
|
||||
char const * bytes[] =
|
||||
{
|
||||
"H",
|
||||
"He",
|
||||
"Hel",
|
||||
"Hell",
|
||||
"Hello",
|
||||
"Hello,",
|
||||
"Hello, ",
|
||||
"Hello, World!",
|
||||
"Organic Maps is the ultimate companion app for travellers, tourists, hikers, and cyclists!",
|
||||
char const * bytes[] = {
|
||||
"H",
|
||||
"He",
|
||||
"Hel",
|
||||
"Hell",
|
||||
"Hello",
|
||||
"Hello,",
|
||||
"Hello, ",
|
||||
"Hello, World!",
|
||||
"Organic Maps is the ultimate companion app for travellers, tourists, hikers, and cyclists!",
|
||||
};
|
||||
|
||||
SHA1::Hash encoded[] =
|
||||
{
|
||||
{0x7C, 0xF1, 0x84, 0xF4, 0xC6, 0x7A, 0xD5, 0x82, 0x83, 0xEC, 0xB1, 0x93, 0x49, 0x72, 0x0B, 0x0C, 0xAE, 0x75, 0x68, 0x29},
|
||||
{0x53, 0xA4, 0x17, 0x79, 0x6C, 0x77, 0x78, 0x51, 0x00, 0x3B, 0x3F, 0x24, 0x31, 0xE8, 0xEE, 0xF5, 0x62, 0x5E, 0xC1, 0x5B},
|
||||
{0xDB, 0xC2, 0xD1, 0xFE, 0xD0, 0xDC, 0x37, 0xA7, 0x0A, 0xEA, 0x0F, 0x37, 0x69, 0x58, 0xC8, 0x02, 0xED, 0xDC, 0x05, 0x59},
|
||||
{0xED, 0x10, 0xFE, 0x11, 0x3D, 0xE1, 0xC0, 0xBD, 0xAA, 0xAA, 0xF0, 0x9B, 0x88, 0xCD, 0x34, 0x1E, 0xA0, 0xF4, 0x44, 0x28},
|
||||
{0xF7, 0xFF, 0x9E, 0x8B, 0x7B, 0xB2, 0xE0, 0x9B, 0x70, 0x93, 0x5A, 0x5D, 0x78, 0x5E, 0x0C, 0xC5, 0xD9, 0xD0, 0xAB, 0xF0},
|
||||
{0x65, 0x61, 0x1E, 0x95, 0x20, 0xE7, 0x68, 0x14, 0x5D, 0xAD, 0xAA, 0x1D, 0x10, 0x7F, 0xDD, 0x52, 0x07, 0xE6, 0x30, 0x57},
|
||||
{0xF5, 0x2A, 0xB5, 0x7F, 0xA5, 0x1D, 0xFA, 0x71, 0x45, 0x05, 0x29, 0x44, 0x44, 0x46, 0x3A, 0xE5, 0xA0, 0x09, 0xAE, 0x34},
|
||||
{0x0A, 0x0A, 0x9F, 0x2A, 0x67, 0x72, 0x94, 0x25, 0x57, 0xAB, 0x53, 0x55, 0xD7, 0x6A, 0xF4, 0x42, 0xF8, 0xF6, 0x5E, 0x01},
|
||||
{0x48, 0xF5, 0x4D, 0x3D, 0x08, 0xD5, 0xC0, 0x57, 0x6B, 0x3A, 0xC5, 0x3E, 0xEF, 0x22, 0x4A, 0xB8, 0x46, 0x7B, 0xA2, 0xFC},
|
||||
SHA1::Hash encoded[] = {
|
||||
{0x7C, 0xF1, 0x84, 0xF4, 0xC6, 0x7A, 0xD5, 0x82, 0x83, 0xEC,
|
||||
0xB1, 0x93, 0x49, 0x72, 0x0B, 0x0C, 0xAE, 0x75, 0x68, 0x29},
|
||||
{0x53, 0xA4, 0x17, 0x79, 0x6C, 0x77, 0x78, 0x51, 0x00, 0x3B,
|
||||
0x3F, 0x24, 0x31, 0xE8, 0xEE, 0xF5, 0x62, 0x5E, 0xC1, 0x5B},
|
||||
{0xDB, 0xC2, 0xD1, 0xFE, 0xD0, 0xDC, 0x37, 0xA7, 0x0A, 0xEA,
|
||||
0x0F, 0x37, 0x69, 0x58, 0xC8, 0x02, 0xED, 0xDC, 0x05, 0x59},
|
||||
{0xED, 0x10, 0xFE, 0x11, 0x3D, 0xE1, 0xC0, 0xBD, 0xAA, 0xAA,
|
||||
0xF0, 0x9B, 0x88, 0xCD, 0x34, 0x1E, 0xA0, 0xF4, 0x44, 0x28},
|
||||
{0xF7, 0xFF, 0x9E, 0x8B, 0x7B, 0xB2, 0xE0, 0x9B, 0x70, 0x93,
|
||||
0x5A, 0x5D, 0x78, 0x5E, 0x0C, 0xC5, 0xD9, 0xD0, 0xAB, 0xF0},
|
||||
{0x65, 0x61, 0x1E, 0x95, 0x20, 0xE7, 0x68, 0x14, 0x5D, 0xAD,
|
||||
0xAA, 0x1D, 0x10, 0x7F, 0xDD, 0x52, 0x07, 0xE6, 0x30, 0x57},
|
||||
{0xF5, 0x2A, 0xB5, 0x7F, 0xA5, 0x1D, 0xFA, 0x71, 0x45, 0x05,
|
||||
0x29, 0x44, 0x44, 0x46, 0x3A, 0xE5, 0xA0, 0x09, 0xAE, 0x34},
|
||||
{0x0A, 0x0A, 0x9F, 0x2A, 0x67, 0x72, 0x94, 0x25, 0x57, 0xAB,
|
||||
0x53, 0x55, 0xD7, 0x6A, 0xF4, 0x42, 0xF8, 0xF6, 0x5E, 0x01},
|
||||
{0x48, 0xF5, 0x4D, 0x3D, 0x08, 0xD5, 0xC0, 0x57, 0x6B, 0x3A,
|
||||
0xC5, 0x3E, 0xEF, 0x22, 0x4A, 0xB8, 0x46, 0x7B, 0xA2, 0xFC},
|
||||
};
|
||||
|
||||
static_assert(std::size(bytes) == std::size(encoded));
|
||||
@@ -40,4 +46,4 @@ UNIT_TEST(SHA1_Smoke)
|
||||
for (size_t i = 0; i < std::size(bytes); ++i)
|
||||
TEST_EQUAL(SHA1::CalculateForString(bytes[i]), encoded[i], ());
|
||||
}
|
||||
}
|
||||
} // namespace sha1_test
|
||||
|
||||
@@ -86,4 +86,4 @@ UNIT_TEST(SimpleDenseCoding_Ratio)
|
||||
TEST_GREATER(ratio, 1.8, ());
|
||||
}
|
||||
}
|
||||
} // namespace simple_dense_coding_test
|
||||
} // namespace simple_dense_coding_test
|
||||
|
||||
@@ -4,17 +4,15 @@
|
||||
|
||||
UNIT_TEST(SparseVector_Smoke)
|
||||
{
|
||||
uint32_t const arr[] = { 0, 0, 5, 0, 7, 1000, 0, 0, 1, 0 };
|
||||
uint32_t const arr[] = {0, 0, 5, 0, 7, 1000, 0, 0, 1, 0};
|
||||
uint64_t const count = std::size(arr);
|
||||
|
||||
coding::SparseVectorBuilder<uint32_t> builder(count);
|
||||
for (uint32_t v : arr)
|
||||
{
|
||||
if (v == 0)
|
||||
builder.PushEmpty();
|
||||
else
|
||||
builder.PushValue(v);
|
||||
}
|
||||
|
||||
auto vec = builder.Build();
|
||||
|
||||
|
||||
@@ -123,14 +123,12 @@ UNIT_TEST(MultilangString_Unique)
|
||||
UNIT_TEST(MultilangString_LangNames)
|
||||
{
|
||||
// It is important to compare the contents of the strings, and not just pointers
|
||||
TEST_EQUAL(string("Беларуская"),
|
||||
StringUtf8Multilang::GetLangNameByCode(StringUtf8Multilang::GetLangIndex("be")), ());
|
||||
TEST_EQUAL(string("Беларуская"), StringUtf8Multilang::GetLangNameByCode(StringUtf8Multilang::GetLangIndex("be")), ());
|
||||
|
||||
auto const & langs = StringUtf8Multilang::GetSupportedLanguages();
|
||||
// Using size_t workaround, because our logging/testing macroses do not support passing POD types
|
||||
// by value, only by reference. And our constant is a constexpr.
|
||||
TEST_LESS_OR_EQUAL(langs.size(), static_cast<size_t>(StringUtf8Multilang::kMaxSupportedLanguages),
|
||||
());
|
||||
TEST_LESS_OR_EQUAL(langs.size(), static_cast<size_t>(StringUtf8Multilang::kMaxSupportedLanguages), ());
|
||||
auto const international = StringUtf8Multilang::GetLangIndex("int_name");
|
||||
TEST_EQUAL(langs[international].m_code, string("int_name"), ());
|
||||
}
|
||||
@@ -201,8 +199,8 @@ UNIT_TEST(MultilangString_ForEachLanguage)
|
||||
|
||||
UNIT_TEST(MultilangString_RemoveString)
|
||||
{
|
||||
auto testRemove = [](vector<pair<uint8_t, string>> const & strings,
|
||||
set<uint8_t> const & codesToRemove) {
|
||||
auto testRemove = [](vector<pair<uint8_t, string>> const & strings, set<uint8_t> const & codesToRemove)
|
||||
{
|
||||
StringUtf8Multilang str;
|
||||
for (auto const & s : strings)
|
||||
str.AddString(s.first, s.second);
|
||||
@@ -233,21 +231,15 @@ UNIT_TEST(MultilangString_RemoveString)
|
||||
}
|
||||
|
||||
// No extra languages or other data damage.
|
||||
str.ForEach([&](uint8_t lang, auto const &) {
|
||||
TEST(base::FindIf(strings, [&lang](auto const & s) { return s.first == lang; }) !=
|
||||
strings.end(),
|
||||
());
|
||||
str.ForEach([&](uint8_t lang, auto const &)
|
||||
{
|
||||
TEST(base::FindIf(strings, [&lang](auto const & s) { return s.first == lang; }) != strings.end(), ());
|
||||
TEST(codesToRemove.find(lang) == codesToRemove.end(), ());
|
||||
});
|
||||
};
|
||||
|
||||
vector<pair<uint8_t, string>> strings = {{0, "aaa"},
|
||||
{1, "bbb"},
|
||||
{2, "ccc"},
|
||||
{9, "ddd"},
|
||||
{17, "eee"},
|
||||
{27, "fff"},
|
||||
{37, "ggg"}};
|
||||
vector<pair<uint8_t, string>> strings = {{0, "aaa"}, {1, "bbb"}, {2, "ccc"}, {9, "ddd"},
|
||||
{17, "eee"}, {27, "fff"}, {37, "ggg"}};
|
||||
|
||||
testRemove(strings, {0});
|
||||
testRemove(strings, {1});
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace succinct_ef_test
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
template <class T> vector<T> GetUniformValues(size_t count)
|
||||
template <class T>
|
||||
vector<T> GetUniformValues(size_t count)
|
||||
{
|
||||
// Use max - 1 because succinct makes val + 1 encoding internals.
|
||||
uniform_int_distribution<T> randDist(0, numeric_limits<T>::max() - 1);
|
||||
@@ -25,7 +26,8 @@ template <class T> vector<T> GetUniformValues(size_t count)
|
||||
return data;
|
||||
}
|
||||
|
||||
template <class T> vector<T> GetNormalValues(size_t count, T mean)
|
||||
template <class T>
|
||||
vector<T> GetNormalValues(size_t count, T mean)
|
||||
{
|
||||
normal_distribution<> randDist(mean, 2);
|
||||
random_device randDevice;
|
||||
@@ -46,7 +48,8 @@ template <class T> vector<T> GetNormalValues(size_t count, T mean)
|
||||
return data;
|
||||
}
|
||||
|
||||
template <class T> double GetCompressionRatio(vector<T> const & data)
|
||||
template <class T>
|
||||
double GetCompressionRatio(vector<T> const & data)
|
||||
{
|
||||
succinct::elias_fano_compressed_list efList(data);
|
||||
|
||||
@@ -84,4 +87,4 @@ UNIT_TEST(SuccinctEFList_Ratio)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace succinct_ef_test
|
||||
} // namespace succinct_ef_test
|
||||
|
||||
@@ -2,380 +2,192 @@
|
||||
|
||||
namespace geometry_coding_tests
|
||||
{
|
||||
P arr1[376] = {P(25.624035299999999182, 72.26346513007850092),
|
||||
P(25.624273200000001083, 72.263461698303601111),
|
||||
P(25.624488899999999347, 72.26341365347376211),
|
||||
P(25.624979400000000851, 72.263304218156179104),
|
||||
P(25.626030799999998777, 72.263025101705878228),
|
||||
P(25.629390999999998257, 72.261676817778678128),
|
||||
P(25.630162399999999678, 72.26138836631159279),
|
||||
P(25.631299500000000791, 72.260963603282490908),
|
||||
P(25.63236829999999955, 72.26051310574631259),
|
||||
P(25.63325580000000059, 72.260190152533994024),
|
||||
P(25.633720499999999021, 72.260019906865807116),
|
||||
P(25.634314799999998513, 72.259865485075735592),
|
||||
P(25.634578999999998672, 72.259830215951140531),
|
||||
P(25.635424199999999217, 72.259772832171691448),
|
||||
P(25.635776400000001018, 72.259834791404088605),
|
||||
P(25.638406499999998545, 72.260604806439260983),
|
||||
P(25.639231599999998679, 72.260931765228107793),
|
||||
P(25.639867699999999928, 72.261237563690428942),
|
||||
P(25.640699399999999031, 72.261850499331046649),
|
||||
P(25.643624299999999039, 72.264447578158552687),
|
||||
P(25.644772700000000754, 72.265904403664706024),
|
||||
P(25.645413800000000037, 72.267106341816230497),
|
||||
P(25.646751600000001758, 72.270404536824941033),
|
||||
P(25.64890219999999843, 72.275985791150915816),
|
||||
P(25.649064599999999103, 72.276404165523842948),
|
||||
P(25.650549500000000336, 72.279974564589863917),
|
||||
P(25.651433600000000723, 72.281545386607334081),
|
||||
P(25.652029899999998719, 72.282193025251160634),
|
||||
P(25.652814700000000414, 72.282915237415323872),
|
||||
P(25.654197199999998702, 72.283799562153532747),
|
||||
P(25.656540400000000801, 72.285055792411071707),
|
||||
P(25.658162999999998277, 72.286263412818769325),
|
||||
P(25.661959599999999426, 72.289916920742129491),
|
||||
P(25.663380199999998865, 72.291039561736027963),
|
||||
P(25.665810499999999195, 72.292780588759853799),
|
||||
P(25.6700361000000008, 72.29585629709197292),
|
||||
P(25.670962599999999298, 72.296655718166547899),
|
||||
P(25.672222699999998952, 72.297961211704517837),
|
||||
P(25.673103499999999855, 72.29896171301187735),
|
||||
P(25.674837499999998869, 72.300952077677095531),
|
||||
P(25.676358000000000459, 72.302732468128681376),
|
||||
P(25.678018200000000348, 72.304444228347662715),
|
||||
P(25.680309600000001069, 72.306619426588397914),
|
||||
P(25.682252600000001763, 72.308208994982337003),
|
||||
P(25.685880300000000886, 72.310749482551628375),
|
||||
P(25.6871223999999998, 72.311619291531712861),
|
||||
P(25.689502399999998516, 72.313337574126506979),
|
||||
P(25.689994200000001001, 72.313685586072296019),
|
||||
P(25.691337099999998372, 72.314639003020189989),
|
||||
P(25.694014100000000411, 72.316465930359882464),
|
||||
P(25.696650399999999337, 72.318133963117716689),
|
||||
P(25.697924300000000386, 72.31863598381848135),
|
||||
P(25.699229800000001234, 72.31891418618496914),
|
||||
P(25.700213699999999051, 72.319045273707061483),
|
||||
P(25.703616300000000194, 72.319271576784373678),
|
||||
P(25.707311499999999427, 72.319273484907995453),
|
||||
P(25.715181600000001083, 72.318046763400587906),
|
||||
P(25.72608460000000008, 72.315978426880036523),
|
||||
P(25.728649600000000675, 72.31539857900408208),
|
||||
P(25.730824299999998317, 72.315156452495600092),
|
||||
P(25.732753200000001215, 72.314945427265811873),
|
||||
P(25.736661200000000349, 72.315042353781024076),
|
||||
P(25.74480259999999987, 72.315568583243575063),
|
||||
P(25.747831600000001373, 72.315649864883624787),
|
||||
P(25.749809599999998966, 72.315866807206518274),
|
||||
P(25.752535200000000515, 72.316023647210727177),
|
||||
P(25.755610000000000781, 72.315910501039496694),
|
||||
P(25.760463999999998919, 72.315272459413776573),
|
||||
P(25.762314700000001011, 72.315021747344800929),
|
||||
P(25.763456399999999036, 72.314812630534717641),
|
||||
P(25.763716200000001066, 72.31478954377344337),
|
||||
P(25.771413500000001306, 72.314102668549878672),
|
||||
P(25.779617200000000565, 72.313375160856324442),
|
||||
P(25.784148800000000534, 72.313357035273327256),
|
||||
P(25.790238899999998523, 72.313577786126856495),
|
||||
P(25.793676300000001334, 72.313716876708198811),
|
||||
P(25.796280599999999339, 72.314048100429985766),
|
||||
P(25.798680499999999682, 72.31463614103191162),
|
||||
P(25.800190700000001698, 72.315239260045032665),
|
||||
P(25.803071100000000371, 72.316310615756250968),
|
||||
P(25.806439499999999754, 72.316835901112042961),
|
||||
P(25.809219599999998707, 72.316657116642062419),
|
||||
P(25.813906700000000427, 72.315918133153061831),
|
||||
P(25.817769800000000657, 72.31543750249576874),
|
||||
P(25.819804099999998925, 72.315482531661231747),
|
||||
P(25.823219200000000484, 72.315995217547779816),
|
||||
P(25.824360999999999677, 72.316092908788874638),
|
||||
P(25.825752500000000111, 72.316000750836963107),
|
||||
P(25.833053499999998337, 72.315183355397863352),
|
||||
P(25.835087900000001326, 72.314863574077250519),
|
||||
P(25.836477299999998536, 72.314986830897922232),
|
||||
P(25.838510800000001666, 72.315843910886087542),
|
||||
P(25.84021669999999915, 72.316586137240363996),
|
||||
P(25.845591399999999993, 72.318366369042564656),
|
||||
P(25.847287900000001315, 72.318912278071522337),
|
||||
P(25.852937300000000675, 72.321233538069833457),
|
||||
P(25.857534099999998745, 72.324114950429262194),
|
||||
P(25.858493899999999144, 72.324638770105451613),
|
||||
P(25.859516599999999187, 72.325101910243901671),
|
||||
P(25.860960299999998568, 72.325309341574609334),
|
||||
P(25.864481800000000078, 72.325170990340012622),
|
||||
P(25.866295099999998541, 72.325066225249685203),
|
||||
P(25.871619400000000155, 72.324758609934391984),
|
||||
P(25.873917800000000966, 72.324524655307570242),
|
||||
P(25.875719000000000136, 72.324229064532204347),
|
||||
P(25.882352300000000866, 72.322516991669758113),
|
||||
P(25.886094899999999797, 72.321551632301222412),
|
||||
P(25.891463999999999146, 72.320154280548763381),
|
||||
P(25.892594599999998906, 72.32000410941930113),
|
||||
P(25.893775399999999109, 72.320041127430243932),
|
||||
P(25.895055100000000436, 72.320205228136387632),
|
||||
P(25.901716900000000265, 72.321479884460799781),
|
||||
P(25.905201399999999268, 72.322148897878847151),
|
||||
P(25.906758400000001075, 72.322300409542663147),
|
||||
P(25.908453200000000294, 72.322276366107203671),
|
||||
P(25.910453700000001476, 72.322039939449879853),
|
||||
P(25.912611200000000622, 72.321379323121732341),
|
||||
P(25.914446699999999169, 72.320507670602822259),
|
||||
P(25.915890699999998503, 72.319578403757603269),
|
||||
P(25.916971199999998987, 72.318721085380474278),
|
||||
P(25.923277999999999821, 72.312682767056259081),
|
||||
P(25.924315100000001166, 72.311643903530907096),
|
||||
P(25.925479700000000349, 72.310661910829537646),
|
||||
P(25.926380200000000542, 72.31012846985993292),
|
||||
P(25.927288000000000778, 72.309673827336439444),
|
||||
P(25.929170299999999116, 72.308742039167825055),
|
||||
P(25.931695000000001272, 72.307558244187632113),
|
||||
P(25.935542200000000435, 72.305689970006980616),
|
||||
P(25.936291600000000557, 72.305420216334297834),
|
||||
P(25.937011699999999337, 72.3052109385934898),
|
||||
P(25.937444899999999137, 72.305171830245583919),
|
||||
P(25.938065999999999178, 72.305126426436075349),
|
||||
P(25.939194700000001603, 72.305346959512363014),
|
||||
P(25.941637199999998842, 72.306187700803491225),
|
||||
P(25.951531899999999098, 72.309363611414866568),
|
||||
P(25.958591599999998323, 72.311600021678131611),
|
||||
P(25.961859900000000323, 72.312588133461261464),
|
||||
P(25.9623209000000017, 72.312845323461488078),
|
||||
P(25.962808800000001241, 72.313126745396871797),
|
||||
P(25.963783500000001681, 72.313929806056449934),
|
||||
P(25.964454100000001091, 72.315054565005411291),
|
||||
P(25.966293799999998981, 72.319575350745964215),
|
||||
P(25.966609900000001687, 72.320173934482440359),
|
||||
P(25.966938999999999993, 72.320628647970096381),
|
||||
P(25.968776200000000642, 72.322731857094510133),
|
||||
P(25.969766299999999859, 72.323772036806516894),
|
||||
P(25.97039970000000153, 72.324406914991570261),
|
||||
P(25.971057800000000526, 72.324904784282267656),
|
||||
P(25.972805199999999815, 72.325716763759459127),
|
||||
P(25.973508700000000005, 72.326106631888762877),
|
||||
P(25.974174900000001287, 72.326699167072590058),
|
||||
P(25.974623600000001034, 72.327462886785923502),
|
||||
P(25.97499170000000035, 72.32822527930542833),
|
||||
P(25.975826399999998984, 72.329784823533856297),
|
||||
P(25.976481499999998448, 72.330935420885211329),
|
||||
P(25.977230399999999833, 72.332212952428704966),
|
||||
P(25.978115400000000079, 72.333512265445278899),
|
||||
P(25.9789551000000003, 72.33474671239962106),
|
||||
P(25.980276700000001, 72.336402410819303554),
|
||||
P(25.98169719999999927, 72.337880836033434662),
|
||||
P(25.983172299999999666, 72.33911288186702393),
|
||||
P(25.984414600000000917, 72.340068567971513858),
|
||||
P(25.985398499999998734, 72.340636603533639004),
|
||||
P(25.986058100000001048, 72.340908025445514795),
|
||||
P(25.987230000000000274, 72.341316496490946975),
|
||||
P(25.988157300000001015, 72.341676869267246275),
|
||||
P(25.991148400000000152, 72.342299318530393748),
|
||||
P(25.997876999999999015, 72.343701138883602653),
|
||||
P(25.999752600000000768, 72.344154484369809666),
|
||||
P(26.001479700000000861, 72.344723890629211382),
|
||||
P(26.003023999999999916, 72.345420432028205937),
|
||||
P(26.005314899999998346, 72.346859159309715892),
|
||||
P(26.007066099999999409, 72.348322733682408625),
|
||||
P(26.008686999999998335, 72.35014618535842601),
|
||||
P(26.012360000000001037, 72.354910262506038521),
|
||||
P(26.013286199999999582, 72.355943685106993257),
|
||||
P(26.013858500000001328, 72.35652369166834319),
|
||||
P(26.014633599999999802, 72.357135968669368253),
|
||||
P(26.015746700000001113, 72.357673410043958029),
|
||||
P(26.017126499999999822, 72.358212001250265644),
|
||||
P(26.020520199999999988, 72.359278695677289761),
|
||||
P(26.021437599999998724, 72.359644892510004865),
|
||||
P(26.022532699999999295, 72.360275718006846546),
|
||||
P(26.028545999999998628, 72.365263533617877556),
|
||||
P(26.029226600000001213, 72.365797602942478761),
|
||||
P(26.030111600000001459, 72.366317546512846093),
|
||||
P(26.032004199999999372, 72.367306080501194288),
|
||||
P(26.033209299999999331, 72.367834246590078351),
|
||||
P(26.034265699999998844, 72.368067397148493569),
|
||||
P(26.035592099999998794, 72.368224167962054594),
|
||||
P(26.03677019999999942, 72.368129074294643033),
|
||||
P(26.043432299999999202, 72.366408627750374194),
|
||||
P(26.045431499999999403, 72.365842856777021552),
|
||||
P(26.048415399999999664, 72.36504242213915461),
|
||||
P(26.052753299999999115, 72.363920454888528866),
|
||||
P(26.05556269999999941, 72.363008918012667436),
|
||||
P(26.060303699999998628, 72.360393712052541559),
|
||||
P(26.065962500000001256, 72.35698705139280662),
|
||||
P(26.067612400000001571, 72.356026924714299753),
|
||||
P(26.069255399999999412, 72.355021374242639354),
|
||||
P(26.070335599999999943, 72.354163985856629893),
|
||||
P(26.071483900000000489, 72.353231772141796796),
|
||||
P(26.073087300000000965, 72.351530224288538307),
|
||||
P(26.07495580000000146, 72.349052146600300262),
|
||||
P(26.077375199999998756, 72.345412414793742073),
|
||||
P(26.079008800000000434, 72.34322240936705839),
|
||||
P(26.080636800000000619, 72.341554327036718064),
|
||||
P(26.081818800000000635, 72.340620379333103074),
|
||||
P(26.083176200000000478, 72.339615440891947173),
|
||||
P(26.085581000000001239, 72.338285853103528211),
|
||||
P(26.092078799999999461, 72.335142167729841844),
|
||||
P(26.099516500000000008, 72.332061609286498083),
|
||||
P(26.102282500000001164, 72.330882175026999903),
|
||||
P(26.105014700000001682, 72.329521843521945357),
|
||||
P(26.108211900000000583, 72.327720133658942814),
|
||||
P(26.116759299999998234, 72.322424061632020198),
|
||||
P(26.118289900000000614, 72.321345929920937579),
|
||||
P(26.124188000000000187, 72.316306990481081129),
|
||||
P(26.126093300000000852, 72.314456217615472156),
|
||||
P(26.13131840000000139, 72.308768748722727082),
|
||||
P(26.133807300000000851, 72.305896196846916268),
|
||||
P(26.135103199999999646, 72.304208818196542552),
|
||||
P(26.13615610000000089, 72.3027141546473473),
|
||||
P(26.136958199999998698, 72.301545345164157652),
|
||||
P(26.137658200000000619, 72.300474224549915903),
|
||||
P(26.140487000000000251, 72.29551524417688313),
|
||||
P(26.146685800000000199, 72.285760107870132174),
|
||||
P(26.151274499999999534, 72.277504651282583836),
|
||||
P(26.151979099999998368, 72.276113553331668982),
|
||||
P(26.152562700000000717, 72.274582520714972134),
|
||||
P(26.152978600000000853, 72.272986691312326002),
|
||||
P(26.154697899999998612, 72.264608683472175699),
|
||||
P(26.155105599999998844, 72.263003939235275652),
|
||||
P(26.155811400000001044, 72.261258344309723611),
|
||||
P(26.156706599999999696, 72.259655777039213831),
|
||||
P(26.158511799999999425, 72.257073180827120495),
|
||||
P(26.163497199999998344, 72.251147710512896083),
|
||||
P(26.164152500000000146, 72.250452144382251163),
|
||||
P(26.165397099999999853, 72.249370018656591697),
|
||||
P(26.171159400000000517, 72.245101348184562084),
|
||||
P(26.171824600000000771, 72.244502288299599968),
|
||||
P(26.172791700000001214, 72.243464858038208831),
|
||||
P(26.173422299999998586, 72.24251111483852128),
|
||||
P(26.174280599999999453, 72.240982180618559028),
|
||||
P(26.174924399999998315, 72.239409446329290176),
|
||||
P(26.175138900000000319, 72.238550480576279256),
|
||||
P(26.177894599999998348, 72.222417606854094174),
|
||||
P(26.178249600000000896, 72.220799387733251251),
|
||||
P(26.178700899999999052, 72.219414415122045625),
|
||||
P(26.179689899999999625, 72.217234222262234766),
|
||||
P(26.182073200000001378, 72.213506738076645775),
|
||||
P(26.18310470000000123, 72.211533626956168064),
|
||||
P(26.183614800000000855, 72.210338776927230242),
|
||||
P(26.18428000000000111, 72.208417574177602205),
|
||||
P(26.185804499999999706, 72.203266316303412964),
|
||||
P(26.186153000000000901, 72.202346286216979365),
|
||||
P(26.186549599999999316, 72.201465316811109574),
|
||||
P(26.187059699999998941, 72.200685882789031211),
|
||||
P(26.187643699999998859, 72.200064170625580573),
|
||||
P(26.188815999999999207, 72.199110470754774838),
|
||||
P(26.189986799999999789, 72.198491439723213148),
|
||||
P(26.190943999999998226, 72.198205925482497491),
|
||||
P(26.192045499999998981, 72.198064597333782899),
|
||||
P(26.201502200000000187, 72.19749033573828001),
|
||||
P(26.204289599999999183, 72.197194731015855496),
|
||||
P(26.212046699999998367, 72.196023752898682346),
|
||||
P(26.217400099999998986, 72.195033541852339454),
|
||||
P(26.220660899999998605, 72.194099530393685882),
|
||||
P(26.223864100000000121, 72.193042117073559893),
|
||||
P(26.227025699999998665, 72.192404096537160285),
|
||||
P(26.229406099999998503, 72.192154413131575552),
|
||||
P(26.23379059999999896, 72.191934250652863625),
|
||||
P(26.241092200000000645, 72.191652763688111349),
|
||||
P(26.247795599999999894, 72.191305763109099303),
|
||||
P(26.259740499999999486, 72.190710990755292187),
|
||||
P(26.262441899999998896, 72.190662426481935654),
|
||||
P(26.26396259999999927, 72.190803739092231694),
|
||||
P(26.265582200000000768, 72.19108065172507338),
|
||||
P(26.271514700000000886, 72.192273445913514252),
|
||||
P(26.275603900000000124, 72.192994312937273094),
|
||||
P(26.278289999999998372, 72.193506828374651718),
|
||||
P(26.280647800000000558, 72.193799369593079973),
|
||||
P(26.284991699999999071, 72.194193426147350579),
|
||||
P(26.295021899999998283, 72.194996021158502231),
|
||||
P(26.296629599999999272, 72.195353135208762296),
|
||||
P(26.298219400000000689, 72.195936520796209379),
|
||||
P(26.299353599999999886, 72.196573622487093758),
|
||||
P(26.300700500000001369, 72.19746290844136638),
|
||||
P(26.301440499999998224, 72.198127833072547332),
|
||||
P(26.302059899999999715, 72.198747051231549676),
|
||||
P(26.302597999999999701, 72.199118470577644757),
|
||||
P(26.30326700000000173, 72.200164931796578571),
|
||||
P(26.304018299999999186, 72.201524555689601925),
|
||||
P(26.305375600000001413, 72.20513574950004454),
|
||||
P(26.306215500000000418, 72.206942181028665573),
|
||||
P(26.307179600000001329, 72.208595118825385839),
|
||||
P(26.307805599999998236, 72.209443034325843769),
|
||||
P(26.308593200000000678, 72.210334966852684602),
|
||||
P(26.309511400000001657, 72.211171854914510959),
|
||||
P(26.310345000000001647, 72.211829485157878139),
|
||||
P(26.313103999999999161, 72.213550746524816759),
|
||||
P(26.313808999999999116, 72.214105903186023738),
|
||||
P(26.315858999999999668, 72.21616368063173752),
|
||||
P(26.316473599999998356, 72.216713905276705532),
|
||||
P(26.317261800000000704, 72.217105619191144683),
|
||||
P(26.318279199999999207, 72.217451609641841515),
|
||||
P(26.31951039999999864, 72.217778930438797147),
|
||||
P(26.319995200000001034, 72.217883719155963718),
|
||||
P(26.322028199999998321, 72.21814340535271981),
|
||||
P(26.323134799999998279, 72.218219615725388394),
|
||||
P(26.324022500000001656, 72.218280774611798734),
|
||||
P(26.32581220000000144, 72.218525220186265301),
|
||||
P(26.327261700000001099, 72.218861882068196678),
|
||||
P(26.330273800000000506, 72.219715642811124212),
|
||||
P(26.337171999999998917, 72.221928497785057743),
|
||||
P(26.339137900000000769, 72.222394361231621929),
|
||||
P(26.341438799999998821, 72.222689314479467271),
|
||||
P(26.343669200000000785, 72.222811640430336411),
|
||||
P(26.346788899999999956, 72.222677310542948703),
|
||||
P(26.356923500000000615, 72.222042438730937874),
|
||||
P(26.359536099999999692, 72.2221015051835451),
|
||||
P(26.36183730000000125, 72.222299854521224916),
|
||||
P(26.366428899999998947, 72.222842507761527031),
|
||||
P(26.374883000000000521, 72.223912965077033732),
|
||||
P(26.380090800000001394, 72.224542709845593436),
|
||||
P(26.39073850000000121, 72.225869670908153353),
|
||||
P(26.393878699999998361, 72.226187124115313054),
|
||||
P(26.400813700000000495, 72.226887965488728582),
|
||||
P(26.405969100000000083, 72.227408932782296347),
|
||||
P(26.434136200000001082, 72.23031015029567925),
|
||||
P(26.437651200000001239, 72.230672215773722655),
|
||||
P(26.439650799999999009, 72.230860300030158783),
|
||||
P(26.442400500000001529, 72.230918230849241013),
|
||||
P(26.444426599999999894, 72.230815518016711962),
|
||||
P(26.454957100000001446, 72.229639190945519545),
|
||||
P(26.455386699999998257, 72.229609273288744475),
|
||||
P(26.470600499999999755, 72.227804710557407475),
|
||||
P(26.485397899999998828, 72.226080035891357056),
|
||||
P(26.487313600000000235, 72.226084418502168205),
|
||||
P(26.488673999999999609, 72.226209799401686951),
|
||||
P(26.489974300000000085, 72.226456941463752059),
|
||||
P(26.493316499999998825, 72.227405883949458598),
|
||||
P(26.497907399999999001, 72.228727947008763977),
|
||||
P(26.507186099999998419, 72.231355762593423719),
|
||||
P(26.521764000000001005, 72.235531322949142918),
|
||||
P(26.522283200000000392, 72.235663963313356817),
|
||||
P(26.52274799999999999, 72.235808991367022713),
|
||||
P(26.523495799999999178, 72.236006428221017472),
|
||||
P(26.537509100000001183, 72.239985971537208798),
|
||||
P(26.540924100000001573, 72.240959309764491536),
|
||||
P(26.544420699999999869, 72.241674408812258434),
|
||||
P(26.546888100000000321, 72.242183101965366632),
|
||||
P(26.5518616999999999, 72.242874580127462991),
|
||||
P(26.562219100000000083, 72.244128903051048951),
|
||||
P(26.564274399999998622, 72.244315309516480283),
|
||||
P(26.576127799999998302, 72.245028538203385438),
|
||||
P(26.58263820000000166, 72.244424904560787581),
|
||||
P(26.591367999999999228, 72.243389190867901561),
|
||||
P(26.598972199999998622, 72.242452221067154028),
|
||||
P(26.600826200000000199, 72.242522931717928714),
|
||||
P(26.603627199999998254, 72.242683603364909573),
|
||||
P(26.606756300000000692, 72.243241096929352807),
|
||||
P(26.612569100000001754, 72.244800578667096147),
|
||||
P(26.615042299999998932, 72.246052459623328446),
|
||||
P(26.621848599999999863, 72.249011664844303482),
|
||||
P(26.627471299999999843, 72.250195383365820589),
|
||||
P(26.641823800000000944, 72.252710806698729584),
|
||||
P(26.648778100000001245, 72.254338371527666141),
|
||||
P(26.655288500000001051, 72.25700169234383452),
|
||||
P(26.660515000000000185, 72.259171735257126556),
|
||||
P(26.662390800000000723, 72.25996099777080417),
|
||||
P(26.670629300000001649, 72.263625851730935779),
|
||||
P(26.671595899999999801, 72.264267979553508781),
|
||||
P(26.676856199999999575, 72.267335711577246116),
|
||||
P(26.677412499999999085, 72.267929636079472289),
|
||||
P(26.676856199999999575, 72.267335711577246116)};
|
||||
P arr1[376] = {P(25.624035299999999182, 72.26346513007850092), P(25.624273200000001083, 72.263461698303601111),
|
||||
P(25.624488899999999347, 72.26341365347376211), P(25.624979400000000851, 72.263304218156179104),
|
||||
P(25.626030799999998777, 72.263025101705878228), P(25.629390999999998257, 72.261676817778678128),
|
||||
P(25.630162399999999678, 72.26138836631159279), P(25.631299500000000791, 72.260963603282490908),
|
||||
P(25.63236829999999955, 72.26051310574631259), P(25.63325580000000059, 72.260190152533994024),
|
||||
P(25.633720499999999021, 72.260019906865807116), P(25.634314799999998513, 72.259865485075735592),
|
||||
P(25.634578999999998672, 72.259830215951140531), P(25.635424199999999217, 72.259772832171691448),
|
||||
P(25.635776400000001018, 72.259834791404088605), P(25.638406499999998545, 72.260604806439260983),
|
||||
P(25.639231599999998679, 72.260931765228107793), P(25.639867699999999928, 72.261237563690428942),
|
||||
P(25.640699399999999031, 72.261850499331046649), P(25.643624299999999039, 72.264447578158552687),
|
||||
P(25.644772700000000754, 72.265904403664706024), P(25.645413800000000037, 72.267106341816230497),
|
||||
P(25.646751600000001758, 72.270404536824941033), P(25.64890219999999843, 72.275985791150915816),
|
||||
P(25.649064599999999103, 72.276404165523842948), P(25.650549500000000336, 72.279974564589863917),
|
||||
P(25.651433600000000723, 72.281545386607334081), P(25.652029899999998719, 72.282193025251160634),
|
||||
P(25.652814700000000414, 72.282915237415323872), P(25.654197199999998702, 72.283799562153532747),
|
||||
P(25.656540400000000801, 72.285055792411071707), P(25.658162999999998277, 72.286263412818769325),
|
||||
P(25.661959599999999426, 72.289916920742129491), P(25.663380199999998865, 72.291039561736027963),
|
||||
P(25.665810499999999195, 72.292780588759853799), P(25.6700361000000008, 72.29585629709197292),
|
||||
P(25.670962599999999298, 72.296655718166547899), P(25.672222699999998952, 72.297961211704517837),
|
||||
P(25.673103499999999855, 72.29896171301187735), P(25.674837499999998869, 72.300952077677095531),
|
||||
P(25.676358000000000459, 72.302732468128681376), P(25.678018200000000348, 72.304444228347662715),
|
||||
P(25.680309600000001069, 72.306619426588397914), P(25.682252600000001763, 72.308208994982337003),
|
||||
P(25.685880300000000886, 72.310749482551628375), P(25.6871223999999998, 72.311619291531712861),
|
||||
P(25.689502399999998516, 72.313337574126506979), P(25.689994200000001001, 72.313685586072296019),
|
||||
P(25.691337099999998372, 72.314639003020189989), P(25.694014100000000411, 72.316465930359882464),
|
||||
P(25.696650399999999337, 72.318133963117716689), P(25.697924300000000386, 72.31863598381848135),
|
||||
P(25.699229800000001234, 72.31891418618496914), P(25.700213699999999051, 72.319045273707061483),
|
||||
P(25.703616300000000194, 72.319271576784373678), P(25.707311499999999427, 72.319273484907995453),
|
||||
P(25.715181600000001083, 72.318046763400587906), P(25.72608460000000008, 72.315978426880036523),
|
||||
P(25.728649600000000675, 72.31539857900408208), P(25.730824299999998317, 72.315156452495600092),
|
||||
P(25.732753200000001215, 72.314945427265811873), P(25.736661200000000349, 72.315042353781024076),
|
||||
P(25.74480259999999987, 72.315568583243575063), P(25.747831600000001373, 72.315649864883624787),
|
||||
P(25.749809599999998966, 72.315866807206518274), P(25.752535200000000515, 72.316023647210727177),
|
||||
P(25.755610000000000781, 72.315910501039496694), P(25.760463999999998919, 72.315272459413776573),
|
||||
P(25.762314700000001011, 72.315021747344800929), P(25.763456399999999036, 72.314812630534717641),
|
||||
P(25.763716200000001066, 72.31478954377344337), P(25.771413500000001306, 72.314102668549878672),
|
||||
P(25.779617200000000565, 72.313375160856324442), P(25.784148800000000534, 72.313357035273327256),
|
||||
P(25.790238899999998523, 72.313577786126856495), P(25.793676300000001334, 72.313716876708198811),
|
||||
P(25.796280599999999339, 72.314048100429985766), P(25.798680499999999682, 72.31463614103191162),
|
||||
P(25.800190700000001698, 72.315239260045032665), P(25.803071100000000371, 72.316310615756250968),
|
||||
P(25.806439499999999754, 72.316835901112042961), P(25.809219599999998707, 72.316657116642062419),
|
||||
P(25.813906700000000427, 72.315918133153061831), P(25.817769800000000657, 72.31543750249576874),
|
||||
P(25.819804099999998925, 72.315482531661231747), P(25.823219200000000484, 72.315995217547779816),
|
||||
P(25.824360999999999677, 72.316092908788874638), P(25.825752500000000111, 72.316000750836963107),
|
||||
P(25.833053499999998337, 72.315183355397863352), P(25.835087900000001326, 72.314863574077250519),
|
||||
P(25.836477299999998536, 72.314986830897922232), P(25.838510800000001666, 72.315843910886087542),
|
||||
P(25.84021669999999915, 72.316586137240363996), P(25.845591399999999993, 72.318366369042564656),
|
||||
P(25.847287900000001315, 72.318912278071522337), P(25.852937300000000675, 72.321233538069833457),
|
||||
P(25.857534099999998745, 72.324114950429262194), P(25.858493899999999144, 72.324638770105451613),
|
||||
P(25.859516599999999187, 72.325101910243901671), P(25.860960299999998568, 72.325309341574609334),
|
||||
P(25.864481800000000078, 72.325170990340012622), P(25.866295099999998541, 72.325066225249685203),
|
||||
P(25.871619400000000155, 72.324758609934391984), P(25.873917800000000966, 72.324524655307570242),
|
||||
P(25.875719000000000136, 72.324229064532204347), P(25.882352300000000866, 72.322516991669758113),
|
||||
P(25.886094899999999797, 72.321551632301222412), P(25.891463999999999146, 72.320154280548763381),
|
||||
P(25.892594599999998906, 72.32000410941930113), P(25.893775399999999109, 72.320041127430243932),
|
||||
P(25.895055100000000436, 72.320205228136387632), P(25.901716900000000265, 72.321479884460799781),
|
||||
P(25.905201399999999268, 72.322148897878847151), P(25.906758400000001075, 72.322300409542663147),
|
||||
P(25.908453200000000294, 72.322276366107203671), P(25.910453700000001476, 72.322039939449879853),
|
||||
P(25.912611200000000622, 72.321379323121732341), P(25.914446699999999169, 72.320507670602822259),
|
||||
P(25.915890699999998503, 72.319578403757603269), P(25.916971199999998987, 72.318721085380474278),
|
||||
P(25.923277999999999821, 72.312682767056259081), P(25.924315100000001166, 72.311643903530907096),
|
||||
P(25.925479700000000349, 72.310661910829537646), P(25.926380200000000542, 72.31012846985993292),
|
||||
P(25.927288000000000778, 72.309673827336439444), P(25.929170299999999116, 72.308742039167825055),
|
||||
P(25.931695000000001272, 72.307558244187632113), P(25.935542200000000435, 72.305689970006980616),
|
||||
P(25.936291600000000557, 72.305420216334297834), P(25.937011699999999337, 72.3052109385934898),
|
||||
P(25.937444899999999137, 72.305171830245583919), P(25.938065999999999178, 72.305126426436075349),
|
||||
P(25.939194700000001603, 72.305346959512363014), P(25.941637199999998842, 72.306187700803491225),
|
||||
P(25.951531899999999098, 72.309363611414866568), P(25.958591599999998323, 72.311600021678131611),
|
||||
P(25.961859900000000323, 72.312588133461261464), P(25.9623209000000017, 72.312845323461488078),
|
||||
P(25.962808800000001241, 72.313126745396871797), P(25.963783500000001681, 72.313929806056449934),
|
||||
P(25.964454100000001091, 72.315054565005411291), P(25.966293799999998981, 72.319575350745964215),
|
||||
P(25.966609900000001687, 72.320173934482440359), P(25.966938999999999993, 72.320628647970096381),
|
||||
P(25.968776200000000642, 72.322731857094510133), P(25.969766299999999859, 72.323772036806516894),
|
||||
P(25.97039970000000153, 72.324406914991570261), P(25.971057800000000526, 72.324904784282267656),
|
||||
P(25.972805199999999815, 72.325716763759459127), P(25.973508700000000005, 72.326106631888762877),
|
||||
P(25.974174900000001287, 72.326699167072590058), P(25.974623600000001034, 72.327462886785923502),
|
||||
P(25.97499170000000035, 72.32822527930542833), P(25.975826399999998984, 72.329784823533856297),
|
||||
P(25.976481499999998448, 72.330935420885211329), P(25.977230399999999833, 72.332212952428704966),
|
||||
P(25.978115400000000079, 72.333512265445278899), P(25.9789551000000003, 72.33474671239962106),
|
||||
P(25.980276700000001, 72.336402410819303554), P(25.98169719999999927, 72.337880836033434662),
|
||||
P(25.983172299999999666, 72.33911288186702393), P(25.984414600000000917, 72.340068567971513858),
|
||||
P(25.985398499999998734, 72.340636603533639004), P(25.986058100000001048, 72.340908025445514795),
|
||||
P(25.987230000000000274, 72.341316496490946975), P(25.988157300000001015, 72.341676869267246275),
|
||||
P(25.991148400000000152, 72.342299318530393748), P(25.997876999999999015, 72.343701138883602653),
|
||||
P(25.999752600000000768, 72.344154484369809666), P(26.001479700000000861, 72.344723890629211382),
|
||||
P(26.003023999999999916, 72.345420432028205937), P(26.005314899999998346, 72.346859159309715892),
|
||||
P(26.007066099999999409, 72.348322733682408625), P(26.008686999999998335, 72.35014618535842601),
|
||||
P(26.012360000000001037, 72.354910262506038521), P(26.013286199999999582, 72.355943685106993257),
|
||||
P(26.013858500000001328, 72.35652369166834319), P(26.014633599999999802, 72.357135968669368253),
|
||||
P(26.015746700000001113, 72.357673410043958029), P(26.017126499999999822, 72.358212001250265644),
|
||||
P(26.020520199999999988, 72.359278695677289761), P(26.021437599999998724, 72.359644892510004865),
|
||||
P(26.022532699999999295, 72.360275718006846546), P(26.028545999999998628, 72.365263533617877556),
|
||||
P(26.029226600000001213, 72.365797602942478761), P(26.030111600000001459, 72.366317546512846093),
|
||||
P(26.032004199999999372, 72.367306080501194288), P(26.033209299999999331, 72.367834246590078351),
|
||||
P(26.034265699999998844, 72.368067397148493569), P(26.035592099999998794, 72.368224167962054594),
|
||||
P(26.03677019999999942, 72.368129074294643033), P(26.043432299999999202, 72.366408627750374194),
|
||||
P(26.045431499999999403, 72.365842856777021552), P(26.048415399999999664, 72.36504242213915461),
|
||||
P(26.052753299999999115, 72.363920454888528866), P(26.05556269999999941, 72.363008918012667436),
|
||||
P(26.060303699999998628, 72.360393712052541559), P(26.065962500000001256, 72.35698705139280662),
|
||||
P(26.067612400000001571, 72.356026924714299753), P(26.069255399999999412, 72.355021374242639354),
|
||||
P(26.070335599999999943, 72.354163985856629893), P(26.071483900000000489, 72.353231772141796796),
|
||||
P(26.073087300000000965, 72.351530224288538307), P(26.07495580000000146, 72.349052146600300262),
|
||||
P(26.077375199999998756, 72.345412414793742073), P(26.079008800000000434, 72.34322240936705839),
|
||||
P(26.080636800000000619, 72.341554327036718064), P(26.081818800000000635, 72.340620379333103074),
|
||||
P(26.083176200000000478, 72.339615440891947173), P(26.085581000000001239, 72.338285853103528211),
|
||||
P(26.092078799999999461, 72.335142167729841844), P(26.099516500000000008, 72.332061609286498083),
|
||||
P(26.102282500000001164, 72.330882175026999903), P(26.105014700000001682, 72.329521843521945357),
|
||||
P(26.108211900000000583, 72.327720133658942814), P(26.116759299999998234, 72.322424061632020198),
|
||||
P(26.118289900000000614, 72.321345929920937579), P(26.124188000000000187, 72.316306990481081129),
|
||||
P(26.126093300000000852, 72.314456217615472156), P(26.13131840000000139, 72.308768748722727082),
|
||||
P(26.133807300000000851, 72.305896196846916268), P(26.135103199999999646, 72.304208818196542552),
|
||||
P(26.13615610000000089, 72.3027141546473473), P(26.136958199999998698, 72.301545345164157652),
|
||||
P(26.137658200000000619, 72.300474224549915903), P(26.140487000000000251, 72.29551524417688313),
|
||||
P(26.146685800000000199, 72.285760107870132174), P(26.151274499999999534, 72.277504651282583836),
|
||||
P(26.151979099999998368, 72.276113553331668982), P(26.152562700000000717, 72.274582520714972134),
|
||||
P(26.152978600000000853, 72.272986691312326002), P(26.154697899999998612, 72.264608683472175699),
|
||||
P(26.155105599999998844, 72.263003939235275652), P(26.155811400000001044, 72.261258344309723611),
|
||||
P(26.156706599999999696, 72.259655777039213831), P(26.158511799999999425, 72.257073180827120495),
|
||||
P(26.163497199999998344, 72.251147710512896083), P(26.164152500000000146, 72.250452144382251163),
|
||||
P(26.165397099999999853, 72.249370018656591697), P(26.171159400000000517, 72.245101348184562084),
|
||||
P(26.171824600000000771, 72.244502288299599968), P(26.172791700000001214, 72.243464858038208831),
|
||||
P(26.173422299999998586, 72.24251111483852128), P(26.174280599999999453, 72.240982180618559028),
|
||||
P(26.174924399999998315, 72.239409446329290176), P(26.175138900000000319, 72.238550480576279256),
|
||||
P(26.177894599999998348, 72.222417606854094174), P(26.178249600000000896, 72.220799387733251251),
|
||||
P(26.178700899999999052, 72.219414415122045625), P(26.179689899999999625, 72.217234222262234766),
|
||||
P(26.182073200000001378, 72.213506738076645775), P(26.18310470000000123, 72.211533626956168064),
|
||||
P(26.183614800000000855, 72.210338776927230242), P(26.18428000000000111, 72.208417574177602205),
|
||||
P(26.185804499999999706, 72.203266316303412964), P(26.186153000000000901, 72.202346286216979365),
|
||||
P(26.186549599999999316, 72.201465316811109574), P(26.187059699999998941, 72.200685882789031211),
|
||||
P(26.187643699999998859, 72.200064170625580573), P(26.188815999999999207, 72.199110470754774838),
|
||||
P(26.189986799999999789, 72.198491439723213148), P(26.190943999999998226, 72.198205925482497491),
|
||||
P(26.192045499999998981, 72.198064597333782899), P(26.201502200000000187, 72.19749033573828001),
|
||||
P(26.204289599999999183, 72.197194731015855496), P(26.212046699999998367, 72.196023752898682346),
|
||||
P(26.217400099999998986, 72.195033541852339454), P(26.220660899999998605, 72.194099530393685882),
|
||||
P(26.223864100000000121, 72.193042117073559893), P(26.227025699999998665, 72.192404096537160285),
|
||||
P(26.229406099999998503, 72.192154413131575552), P(26.23379059999999896, 72.191934250652863625),
|
||||
P(26.241092200000000645, 72.191652763688111349), P(26.247795599999999894, 72.191305763109099303),
|
||||
P(26.259740499999999486, 72.190710990755292187), P(26.262441899999998896, 72.190662426481935654),
|
||||
P(26.26396259999999927, 72.190803739092231694), P(26.265582200000000768, 72.19108065172507338),
|
||||
P(26.271514700000000886, 72.192273445913514252), P(26.275603900000000124, 72.192994312937273094),
|
||||
P(26.278289999999998372, 72.193506828374651718), P(26.280647800000000558, 72.193799369593079973),
|
||||
P(26.284991699999999071, 72.194193426147350579), P(26.295021899999998283, 72.194996021158502231),
|
||||
P(26.296629599999999272, 72.195353135208762296), P(26.298219400000000689, 72.195936520796209379),
|
||||
P(26.299353599999999886, 72.196573622487093758), P(26.300700500000001369, 72.19746290844136638),
|
||||
P(26.301440499999998224, 72.198127833072547332), P(26.302059899999999715, 72.198747051231549676),
|
||||
P(26.302597999999999701, 72.199118470577644757), P(26.30326700000000173, 72.200164931796578571),
|
||||
P(26.304018299999999186, 72.201524555689601925), P(26.305375600000001413, 72.20513574950004454),
|
||||
P(26.306215500000000418, 72.206942181028665573), P(26.307179600000001329, 72.208595118825385839),
|
||||
P(26.307805599999998236, 72.209443034325843769), P(26.308593200000000678, 72.210334966852684602),
|
||||
P(26.309511400000001657, 72.211171854914510959), P(26.310345000000001647, 72.211829485157878139),
|
||||
P(26.313103999999999161, 72.213550746524816759), P(26.313808999999999116, 72.214105903186023738),
|
||||
P(26.315858999999999668, 72.21616368063173752), P(26.316473599999998356, 72.216713905276705532),
|
||||
P(26.317261800000000704, 72.217105619191144683), P(26.318279199999999207, 72.217451609641841515),
|
||||
P(26.31951039999999864, 72.217778930438797147), P(26.319995200000001034, 72.217883719155963718),
|
||||
P(26.322028199999998321, 72.21814340535271981), P(26.323134799999998279, 72.218219615725388394),
|
||||
P(26.324022500000001656, 72.218280774611798734), P(26.32581220000000144, 72.218525220186265301),
|
||||
P(26.327261700000001099, 72.218861882068196678), P(26.330273800000000506, 72.219715642811124212),
|
||||
P(26.337171999999998917, 72.221928497785057743), P(26.339137900000000769, 72.222394361231621929),
|
||||
P(26.341438799999998821, 72.222689314479467271), P(26.343669200000000785, 72.222811640430336411),
|
||||
P(26.346788899999999956, 72.222677310542948703), P(26.356923500000000615, 72.222042438730937874),
|
||||
P(26.359536099999999692, 72.2221015051835451), P(26.36183730000000125, 72.222299854521224916),
|
||||
P(26.366428899999998947, 72.222842507761527031), P(26.374883000000000521, 72.223912965077033732),
|
||||
P(26.380090800000001394, 72.224542709845593436), P(26.39073850000000121, 72.225869670908153353),
|
||||
P(26.393878699999998361, 72.226187124115313054), P(26.400813700000000495, 72.226887965488728582),
|
||||
P(26.405969100000000083, 72.227408932782296347), P(26.434136200000001082, 72.23031015029567925),
|
||||
P(26.437651200000001239, 72.230672215773722655), P(26.439650799999999009, 72.230860300030158783),
|
||||
P(26.442400500000001529, 72.230918230849241013), P(26.444426599999999894, 72.230815518016711962),
|
||||
P(26.454957100000001446, 72.229639190945519545), P(26.455386699999998257, 72.229609273288744475),
|
||||
P(26.470600499999999755, 72.227804710557407475), P(26.485397899999998828, 72.226080035891357056),
|
||||
P(26.487313600000000235, 72.226084418502168205), P(26.488673999999999609, 72.226209799401686951),
|
||||
P(26.489974300000000085, 72.226456941463752059), P(26.493316499999998825, 72.227405883949458598),
|
||||
P(26.497907399999999001, 72.228727947008763977), P(26.507186099999998419, 72.231355762593423719),
|
||||
P(26.521764000000001005, 72.235531322949142918), P(26.522283200000000392, 72.235663963313356817),
|
||||
P(26.52274799999999999, 72.235808991367022713), P(26.523495799999999178, 72.236006428221017472),
|
||||
P(26.537509100000001183, 72.239985971537208798), P(26.540924100000001573, 72.240959309764491536),
|
||||
P(26.544420699999999869, 72.241674408812258434), P(26.546888100000000321, 72.242183101965366632),
|
||||
P(26.5518616999999999, 72.242874580127462991), P(26.562219100000000083, 72.244128903051048951),
|
||||
P(26.564274399999998622, 72.244315309516480283), P(26.576127799999998302, 72.245028538203385438),
|
||||
P(26.58263820000000166, 72.244424904560787581), P(26.591367999999999228, 72.243389190867901561),
|
||||
P(26.598972199999998622, 72.242452221067154028), P(26.600826200000000199, 72.242522931717928714),
|
||||
P(26.603627199999998254, 72.242683603364909573), P(26.606756300000000692, 72.243241096929352807),
|
||||
P(26.612569100000001754, 72.244800578667096147), P(26.615042299999998932, 72.246052459623328446),
|
||||
P(26.621848599999999863, 72.249011664844303482), P(26.627471299999999843, 72.250195383365820589),
|
||||
P(26.641823800000000944, 72.252710806698729584), P(26.648778100000001245, 72.254338371527666141),
|
||||
P(26.655288500000001051, 72.25700169234383452), P(26.660515000000000185, 72.259171735257126556),
|
||||
P(26.662390800000000723, 72.25996099777080417), P(26.670629300000001649, 72.263625851730935779),
|
||||
P(26.671595899999999801, 72.264267979553508781), P(26.676856199999999575, 72.267335711577246116),
|
||||
P(26.677412499999999085, 72.267929636079472289), P(26.676856199999999575, 72.267335711577246116)};
|
||||
} // namespace geometry_coding_tests
|
||||
|
||||
@@ -47,8 +47,7 @@ void Test(vector<TrafficGPSEncoder::DataPoint> & points)
|
||||
TEST_EQUAL(points.size(), result.size(), ());
|
||||
for (size_t i = 0; i < points.size(); ++i)
|
||||
{
|
||||
TEST_EQUAL(points[i].m_timestamp, result[i].m_timestamp,
|
||||
(points[i].m_timestamp, result[i].m_timestamp));
|
||||
TEST_EQUAL(points[i].m_timestamp, result[i].m_timestamp, (points[i].m_timestamp, result[i].m_timestamp));
|
||||
TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat, kEps),
|
||||
(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat));
|
||||
TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon, kEps),
|
||||
@@ -57,8 +56,8 @@ void Test(vector<TrafficGPSEncoder::DataPoint> & points)
|
||||
|
||||
if (version == TrafficGPSEncoder::kLatestVersion)
|
||||
{
|
||||
LOG(LINFO, ("path length =", CalculateLength(points), "num points =", points.size(),
|
||||
"compressed size =", buf.size()));
|
||||
LOG(LINFO,
|
||||
("path length =", CalculateLength(points), "num points =", points.size(), "compressed size =", buf.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +65,8 @@ void Test(vector<TrafficGPSEncoder::DataPoint> & points)
|
||||
UNIT_TEST(Traffic_Serialization_Smoke)
|
||||
{
|
||||
vector<TrafficGPSEncoder::DataPoint> data = {
|
||||
{0, ms::LatLon(0.0, 1.0), 1}, {0, ms::LatLon(0.0, 2.0), 2},
|
||||
{0, ms::LatLon(0.0, 1.0), 1},
|
||||
{0, ms::LatLon(0.0, 2.0), 2},
|
||||
};
|
||||
Test(data);
|
||||
}
|
||||
@@ -80,7 +80,8 @@ UNIT_TEST(Traffic_Serialization_EmptyPath)
|
||||
UNIT_TEST(Traffic_Serialization_StraightLine100m)
|
||||
{
|
||||
vector<TrafficGPSEncoder::DataPoint> path = {
|
||||
{0, ms::LatLon(0.0, 0.0), 1}, {0, ms::LatLon(0.0, 1e-3), 2},
|
||||
{0, ms::LatLon(0.0, 0.0), 1},
|
||||
{0, ms::LatLon(0.0, 1e-3), 2},
|
||||
};
|
||||
Test(path);
|
||||
}
|
||||
@@ -88,7 +89,8 @@ UNIT_TEST(Traffic_Serialization_StraightLine100m)
|
||||
UNIT_TEST(Traffic_Serialization_StraightLine50Km)
|
||||
{
|
||||
vector<TrafficGPSEncoder::DataPoint> path = {
|
||||
{0, ms::LatLon(0.0, 0.0), 1}, {0, ms::LatLon(0.0, 0.5), 2},
|
||||
{0, ms::LatLon(0.0, 0.0), 1},
|
||||
{0, ms::LatLon(0.0, 0.5), 2},
|
||||
};
|
||||
Test(path);
|
||||
}
|
||||
@@ -147,7 +149,8 @@ UNIT_TEST(Traffic_Serialization_Circle20KmRadius)
|
||||
UNIT_TEST(Traffic_Serialization_ExtremeLatLon)
|
||||
{
|
||||
vector<TrafficGPSEncoder::DataPoint> path = {
|
||||
{0, ms::LatLon(-90, -180), 0}, {0, ms::LatLon(90, 180), 0},
|
||||
{0, ms::LatLon(-90, -180), 0},
|
||||
{0, ms::LatLon(90, 180), 0},
|
||||
};
|
||||
Test(path);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,21 @@ class TestUrl
|
||||
public:
|
||||
explicit TestUrl(string && url) : m_url(std::move(url)) {}
|
||||
|
||||
TestUrl & Scheme(string && scheme) { m_scheme = std::move(scheme); return *this; }
|
||||
TestUrl & Host(string && host) { m_host = std::move(host); return *this; }
|
||||
TestUrl & Path(string && path) { m_path = std::move(path); return *this; }
|
||||
TestUrl & Scheme(string && scheme)
|
||||
{
|
||||
m_scheme = std::move(scheme);
|
||||
return *this;
|
||||
}
|
||||
TestUrl & Host(string && host)
|
||||
{
|
||||
m_host = std::move(host);
|
||||
return *this;
|
||||
}
|
||||
TestUrl & Path(string && path)
|
||||
{
|
||||
m_path = std::move(path);
|
||||
return *this;
|
||||
}
|
||||
TestUrl & KV(string && key, string && value)
|
||||
{
|
||||
m_keyValuePairs.emplace(std::move(key), std::move(value));
|
||||
@@ -115,17 +127,9 @@ UNIT_TEST(Url_Valid)
|
||||
.KV("ll", "10.3,12.3223")
|
||||
.KV("n", "Hello World");
|
||||
|
||||
TestUrl("cm:M&M//path?q=q&w=w")
|
||||
.Scheme("cm")
|
||||
.Host("M&M")
|
||||
.Path("path")
|
||||
.KV("q", "q")
|
||||
.KV("w", "w");
|
||||
TestUrl("cm:M&M//path?q=q&w=w").Scheme("cm").Host("M&M").Path("path").KV("q", "q").KV("w", "w");
|
||||
|
||||
TestUrl("http://www.sandwichparlour.com.au/")
|
||||
.Scheme("http")
|
||||
.Host("www.sandwichparlour.com.au")
|
||||
.Path("");
|
||||
TestUrl("http://www.sandwichparlour.com.au/").Scheme("http").Host("www.sandwichparlour.com.au").Path("");
|
||||
|
||||
TestUrl("cm:/&test").Scheme("cm").Host("&test").Path("");
|
||||
}
|
||||
@@ -160,21 +164,40 @@ UNIT_TEST(UrlScheme_Comprehensive)
|
||||
TestUrl("http://host/path/to/something").Scheme("http").Host("host").Path("path/to/something");
|
||||
TestUrl("http://host?").Scheme("http").Host("host").Path("");
|
||||
TestUrl("maps://host?&&key=&").Scheme("maps").Host("host").KV("key", "");
|
||||
TestUrl("mapswithme://map?ll=1.2,3.4&z=15").Scheme("mapswithme").Host("map").Path("")
|
||||
.KV("ll", "1.2,3.4").KV("z", "15");
|
||||
TestUrl("nopathnovalues://?key1&key2=val2").Scheme("nopathnovalues").Host("").Path("")
|
||||
.KV("key1", "").KV("key2", "val2");
|
||||
TestUrl("mapswithme://map?ll=1.2,3.4&z=15")
|
||||
.Scheme("mapswithme")
|
||||
.Host("map")
|
||||
.Path("")
|
||||
.KV("ll", "1.2,3.4")
|
||||
.KV("z", "15");
|
||||
TestUrl("nopathnovalues://?key1&key2=val2")
|
||||
.Scheme("nopathnovalues")
|
||||
.Host("")
|
||||
.Path("")
|
||||
.KV("key1", "")
|
||||
.KV("key2", "val2");
|
||||
TestUrl("s://?key1&key2").Scheme("s").Host("").Path("").KV("key1", "").KV("key2", "");
|
||||
TestUrl("g://h/p?key1=val1&key2=").Scheme("g").Host("h").Path("p").KV("key1", "val1").KV("key2", "");
|
||||
TestUrl("g://h?=val1&key2=").Scheme("g").Host("h").Path("").KV("", "val1").KV("key2", "");
|
||||
TestUrl("g://?k&key2").Scheme("g").Host("").Path("").KV("k", "").KV("key2", "");
|
||||
TestUrl("m:?%26Amp%26%3D%26Amp%26&name=%31%20%30").Scheme("m").Host("").Path("")
|
||||
.KV("&Amp&=&Amp&", "").KV("name", "1 0");
|
||||
TestUrl("m:?%26Amp%26%3D%26Amp%26&name=%31%20%30")
|
||||
.Scheme("m")
|
||||
.Host("")
|
||||
.Path("")
|
||||
.KV("&Amp&=&Amp&", "")
|
||||
.KV("name", "1 0");
|
||||
TestUrl("s://?key1=value1&key1=value2&key1=value3&key2&key2&key3=value1&key3&key3=value2")
|
||||
.Scheme("s").Host("").Path("")
|
||||
.KV("key1", "value1").KV("key1", "value2").KV("key1", "value3")
|
||||
.KV("key2", "").KV("key2", "")
|
||||
.KV("key3", "value1").KV("key3", "").KV("key3", "value2");
|
||||
.Scheme("s")
|
||||
.Host("")
|
||||
.Path("")
|
||||
.KV("key1", "value1")
|
||||
.KV("key1", "value2")
|
||||
.KV("key1", "value3")
|
||||
.KV("key2", "")
|
||||
.KV("key2", "")
|
||||
.KV("key3", "value1")
|
||||
.KV("key3", "")
|
||||
.KV("key3", "value2");
|
||||
}
|
||||
|
||||
UNIT_TEST(UrlApi_Smoke)
|
||||
|
||||
@@ -22,7 +22,7 @@ void TestStringCodingT(T const * arr, size_t count, size_t maxSize)
|
||||
s.Set(ethalon);
|
||||
|
||||
std::vector<char> buffer;
|
||||
MemWriter<std::vector<char> > w(buffer);
|
||||
MemWriter<std::vector<char>> w(buffer);
|
||||
|
||||
s.Write(w);
|
||||
|
||||
@@ -38,7 +38,7 @@ void TestStringCodingT(T const * arr, size_t count, size_t maxSize)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(StringNumericOptimal_Zero)
|
||||
{
|
||||
@@ -51,19 +51,19 @@ UNIT_TEST(StringNumericOptimal_Zero)
|
||||
|
||||
UNIT_TEST(StringNumericOptimal_IntCoding1)
|
||||
{
|
||||
int arr[] = { 0, 1, 2, 666, 0x0FFFFFFF, 0x7FFFFFFF-1, 0x7FFFFFFF };
|
||||
int arr[] = {0, 1, 2, 666, 0x0FFFFFFF, 0x7FFFFFFF - 1, 0x7FFFFFFF};
|
||||
TestStringCodingT(arr, ARRAY_SIZE(arr), 5); // should be coded as VarUint
|
||||
}
|
||||
|
||||
UNIT_TEST(StringNumericOptimal_IntCoding2)
|
||||
{
|
||||
int arr[] = { -1, -2, -666666, static_cast<int>(0xFFFFFFFE), static_cast<int>(0xFFFFFFFF) };
|
||||
int arr[] = {-1, -2, -666666, static_cast<int>(0xFFFFFFFE), static_cast<int>(0xFFFFFFFF)};
|
||||
TestStringCodingT(arr, ARRAY_SIZE(arr), 12); // should be coded as String
|
||||
}
|
||||
|
||||
UNIT_TEST(StringNumericOptimal_StringCoding)
|
||||
{
|
||||
char const * arr[] = { "xxx", "yyy", "a", "0xFFFFFF", "123456UL" };
|
||||
char const * arr[] = {"xxx", "yyy", "a", "0xFFFFFF", "123456UL"};
|
||||
TestStringCodingT(arr, ARRAY_SIZE(arr), 12); // should be coded as String
|
||||
}
|
||||
|
||||
|
||||
@@ -17,36 +17,37 @@ using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
struct SaveForEachParams
|
||||
struct SaveForEachParams
|
||||
{
|
||||
explicit SaveForEachParams(vector<pair<uint64_t, string>> & data) : m_data(data) {}
|
||||
|
||||
void operator()(uint64_t pos, vector<uint8_t> && data) const
|
||||
{
|
||||
explicit SaveForEachParams(vector<pair<uint64_t, string>> & data) : m_data(data) {}
|
||||
m_data.emplace_back(pos, string(data.begin(), data.end()));
|
||||
}
|
||||
|
||||
void operator()(uint64_t pos, vector<uint8_t> && data) const
|
||||
{
|
||||
m_data.emplace_back(pos, string(data.begin(), data.end()));
|
||||
}
|
||||
vector<pair<uint64_t, string>> & m_data;
|
||||
};
|
||||
|
||||
vector<pair<uint64_t, string>> & m_data;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(VarRecordReader_Simple)
|
||||
{
|
||||
vector<uint8_t> data;
|
||||
char const longString[] = "0123456789012345678901234567890123456789012345678901234567890123456789"
|
||||
"012345678901234567890123456789012345678901234567890123456789012345";
|
||||
char const longString[] =
|
||||
"0123456789012345678901234567890123456789012345678901234567890123456789"
|
||||
"012345678901234567890123456789012345678901234567890123456789012345";
|
||||
size_t const longStringSize = sizeof(longString) - 1;
|
||||
TEST_GREATER(longStringSize, 128, ());
|
||||
{
|
||||
MemWriter<vector<uint8_t>> writer(data);
|
||||
WriteVarUint(writer, 3U); // 0
|
||||
writer.Write("abc", 3); // 1
|
||||
WriteVarUint(writer, longStringSize); // 4
|
||||
writer.Write(longString, longStringSize); // 6
|
||||
WriteVarUint(writer, 4U); // 6 + longStringSize
|
||||
writer.Write("defg", 4); // 7 + longStringSize
|
||||
// 11 + longStringSize
|
||||
WriteVarUint(writer, 3U); // 0
|
||||
writer.Write("abc", 3); // 1
|
||||
WriteVarUint(writer, longStringSize); // 4
|
||||
writer.Write(longString, longStringSize); // 6
|
||||
WriteVarUint(writer, 4U); // 6 + longStringSize
|
||||
writer.Write("defg", 4); // 7 + longStringSize
|
||||
// 11 + longStringSize
|
||||
}
|
||||
|
||||
MemReader reader(&data[0], data.size());
|
||||
@@ -63,8 +64,6 @@ UNIT_TEST(VarRecordReader_Simple)
|
||||
|
||||
vector<pair<uint64_t, string>> forEachCalls;
|
||||
recordReader.ForEachRecord(SaveForEachParams(forEachCalls));
|
||||
vector<pair<uint64_t, string>> expectedForEachCalls = {{0, "abc"},
|
||||
{4, longString},
|
||||
{6 + longStringSize, "defg"}};
|
||||
vector<pair<uint64_t, string>> expectedForEachCalls = {{0, "abc"}, {4, longString}, {6 + longStringSize, "defg"}};
|
||||
TEST_EQUAL(forEachCalls, expectedForEachCalls, ());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,12 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
char const kHexSerial[] = "03000000" "01000000" "04000000" "06000000" "616263646566";
|
||||
char const kHexSerial[] =
|
||||
"03000000"
|
||||
"01000000"
|
||||
"04000000"
|
||||
"06000000"
|
||||
"616263646566";
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -45,7 +50,7 @@ void WriteVarSerialVector(ItT begin, ItT end, TDstStream & dst)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(WriteSerial)
|
||||
{
|
||||
@@ -65,7 +70,7 @@ UNIT_TEST(WriteSerialWithWriter)
|
||||
{
|
||||
string output;
|
||||
MemWriter<string> writer(output);
|
||||
VarSerialVectorWriter<MemWriter<string> > recordWriter(writer, 3);
|
||||
VarSerialVectorWriter<MemWriter<string>> recordWriter(writer, 3);
|
||||
writer.Write("a", 1);
|
||||
recordWriter.FinishRecord();
|
||||
writer.Write("bcd", 3);
|
||||
|
||||
@@ -12,33 +12,35 @@ using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T> void TestVarUint(T const x)
|
||||
{
|
||||
vector<unsigned char> data;
|
||||
PushBackByteSink<vector<uint8_t>> dst(data);
|
||||
WriteVarUint(dst, x);
|
||||
template <typename T>
|
||||
void TestVarUint(T const x)
|
||||
{
|
||||
vector<unsigned char> data;
|
||||
PushBackByteSink<vector<uint8_t>> dst(data);
|
||||
WriteVarUint(dst, x);
|
||||
|
||||
ArrayByteSource src(&data[0]);
|
||||
TEST_EQUAL(ReadVarUint<T>(src), x, ());
|
||||
ArrayByteSource src(&data[0]);
|
||||
TEST_EQUAL(ReadVarUint<T>(src), x, ());
|
||||
|
||||
size_t const bytesRead = src.PtrUint8() - data.data();
|
||||
TEST_EQUAL(bytesRead, data.size(), (x));
|
||||
}
|
||||
|
||||
template <typename T> void TestVarInt(T const x)
|
||||
{
|
||||
vector<uint8_t> data;
|
||||
PushBackByteSink<vector<uint8_t>> dst(data);
|
||||
WriteVarInt(dst, x);
|
||||
|
||||
ArrayByteSource src(&data[0]);
|
||||
TEST_EQUAL(ReadVarInt<T>(src), x, ());
|
||||
|
||||
size_t const bytesRead = src.PtrUint8() - data.data();
|
||||
TEST_EQUAL(bytesRead, data.size(), (x));
|
||||
}
|
||||
size_t const bytesRead = src.PtrUint8() - data.data();
|
||||
TEST_EQUAL(bytesRead, data.size(), (x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TestVarInt(T const x)
|
||||
{
|
||||
vector<uint8_t> data;
|
||||
PushBackByteSink<vector<uint8_t>> dst(data);
|
||||
WriteVarInt(dst, x);
|
||||
|
||||
ArrayByteSource src(&data[0]);
|
||||
TEST_EQUAL(ReadVarInt<T>(src), x, ());
|
||||
|
||||
size_t const bytesRead = src.PtrUint8() - data.data();
|
||||
TEST_EQUAL(bytesRead, data.size(), (x));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(VarUint0)
|
||||
{
|
||||
// TestVarUint(static_cast<uint8_t>(0));
|
||||
@@ -125,11 +127,16 @@ UNIT_TEST(ReadVarInt64Array)
|
||||
|
||||
// Fill in values.
|
||||
{
|
||||
int64_t const baseValues [] =
|
||||
{
|
||||
0, 127, 128, (2 << 28) - 1, (2 << 28), (2LL << 31), (2LL << 31) - 1,
|
||||
0xFFFFFFFF - 1, 0xFFFFFFFF, 0xFFFFFFFFFFULL
|
||||
};
|
||||
int64_t const baseValues[] = {0,
|
||||
127,
|
||||
128,
|
||||
(2 << 28) - 1,
|
||||
(2 << 28),
|
||||
(2LL << 31),
|
||||
(2LL << 31) - 1,
|
||||
0xFFFFFFFF - 1,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFFFFULL};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(baseValues); ++i)
|
||||
{
|
||||
values.push_back(baseValues[i]);
|
||||
@@ -164,20 +171,17 @@ UNIT_TEST(ReadVarInt64Array)
|
||||
void const * pDataEnd = &data[0] + data.size();
|
||||
|
||||
vector<int64_t> result;
|
||||
void const * pEnd = ReadVarInt64Array(pDataStart, pDataEnd,
|
||||
base::MakeBackInsertFunctor(result));
|
||||
void const * pEnd = ReadVarInt64Array(pDataStart, pDataEnd, base::MakeBackInsertFunctor(result));
|
||||
|
||||
TEST_EQUAL(pEnd, pDataEnd, ("UntilBufferEnd", data.size()));
|
||||
TEST_EQUAL(result, testValues, ("UntilBufferEnd", data.size()));
|
||||
}
|
||||
{
|
||||
vector<int64_t> result;
|
||||
void const * pEnd = ReadVarInt64Array(&data[0], testValues.size(),
|
||||
base::MakeBackInsertFunctor(result));
|
||||
void const * pEnd = ReadVarInt64Array(&data[0], testValues.size(), base::MakeBackInsertFunctor(result));
|
||||
|
||||
TEST_EQUAL(pEnd, &data[0] + data.size(), ("GivenSize", data.size()));
|
||||
TEST_EQUAL(result, testValues, ("GivenSize", data.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/buffered_file_writer.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/file_reader.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/internal/file_data.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
@@ -14,43 +14,43 @@ using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
static char const kTestWriteStr [] = "01234567";
|
||||
static char const kTestWriteStr[] = "01234567";
|
||||
|
||||
template <class WriterT>
|
||||
void TestWrite(WriterT & writer)
|
||||
{
|
||||
writer.Write("01", 2); // "01"
|
||||
TEST_EQUAL(writer.Pos(), 2, ());
|
||||
writer.Write("x", 1); // "01x"
|
||||
TEST_EQUAL(writer.Pos(), 3, ());
|
||||
writer.Write("3", 1); // "01x3"
|
||||
TEST_EQUAL(writer.Pos(), 4, ());
|
||||
writer.Seek(2);
|
||||
TEST_EQUAL(writer.Pos(), 2, ());
|
||||
writer.Write("2", 1); // "0123"
|
||||
TEST_EQUAL(writer.Pos(), 3, ());
|
||||
writer.Seek(7);
|
||||
TEST_EQUAL(writer.Pos(), 7, ());
|
||||
writer.Write("7", 1); // "0123???7"
|
||||
TEST_EQUAL(writer.Pos(), 8, ());
|
||||
writer.Seek(4);
|
||||
TEST_EQUAL(writer.Pos(), 4, ());
|
||||
writer.Write("45", 2); // "012345?7"
|
||||
writer.Write("6", 1); // "01234567"
|
||||
}
|
||||
template <class WriterT>
|
||||
void TestWrite(WriterT & writer)
|
||||
{
|
||||
writer.Write("01", 2); // "01"
|
||||
TEST_EQUAL(writer.Pos(), 2, ());
|
||||
writer.Write("x", 1); // "01x"
|
||||
TEST_EQUAL(writer.Pos(), 3, ());
|
||||
writer.Write("3", 1); // "01x3"
|
||||
TEST_EQUAL(writer.Pos(), 4, ());
|
||||
writer.Seek(2);
|
||||
TEST_EQUAL(writer.Pos(), 2, ());
|
||||
writer.Write("2", 1); // "0123"
|
||||
TEST_EQUAL(writer.Pos(), 3, ());
|
||||
writer.Seek(7);
|
||||
TEST_EQUAL(writer.Pos(), 7, ());
|
||||
writer.Write("7", 1); // "0123???7"
|
||||
TEST_EQUAL(writer.Pos(), 8, ());
|
||||
writer.Seek(4);
|
||||
TEST_EQUAL(writer.Pos(), 4, ());
|
||||
writer.Write("45", 2); // "012345?7"
|
||||
writer.Write("6", 1); // "01234567"
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(MemWriter_Smoke)
|
||||
{
|
||||
vector<char> s;
|
||||
MemWriter<vector<char> > writer(s);
|
||||
MemWriter<vector<char>> writer(s);
|
||||
TestWrite(writer);
|
||||
TEST_EQUAL(string(s.begin(), s.end()), kTestWriteStr, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(FileWriter_Smoke)
|
||||
{
|
||||
char const fileName [] = "file_writer_smoke_test.tmp";
|
||||
char const fileName[] = "file_writer_smoke_test.tmp";
|
||||
{
|
||||
FileWriter writer(fileName);
|
||||
TestWrite(writer);
|
||||
@@ -68,10 +68,10 @@ UNIT_TEST(FileWriter_Smoke)
|
||||
UNIT_TEST(SubWriter_MemWriter_Smoke)
|
||||
{
|
||||
vector<char> s;
|
||||
MemWriter<vector<char> > writer(s);
|
||||
MemWriter<vector<char>> writer(s);
|
||||
writer.Write("aa", 2);
|
||||
{
|
||||
SubWriter<MemWriter<vector<char> > > subWriter(writer);
|
||||
SubWriter<MemWriter<vector<char>>> subWriter(writer);
|
||||
TestWrite(subWriter);
|
||||
}
|
||||
writer.Write("bb", 2);
|
||||
@@ -80,7 +80,7 @@ UNIT_TEST(SubWriter_MemWriter_Smoke)
|
||||
|
||||
UNIT_TEST(SubWriter_FileWriter_Smoke)
|
||||
{
|
||||
char const fileName [] = "sub_file_writer_smoke_test.tmp";
|
||||
char const fileName[] = "sub_file_writer_smoke_test.tmp";
|
||||
{
|
||||
FileWriter writer(fileName);
|
||||
writer.Write("aa", 2);
|
||||
@@ -102,7 +102,7 @@ UNIT_TEST(SubWriter_FileWriter_Smoke)
|
||||
|
||||
UNIT_TEST(FileWriter_DeleteFile)
|
||||
{
|
||||
char const fileName [] = "delete_file_test";
|
||||
char const fileName[] = "delete_file_test";
|
||||
{
|
||||
FileWriter writer(fileName);
|
||||
writer.Write("123", 3);
|
||||
@@ -117,14 +117,13 @@ UNIT_TEST(FileWriter_DeleteFile)
|
||||
FileReader reader(fileName);
|
||||
TEST(false, ("Exception should be thrown!"));
|
||||
}
|
||||
catch (FileReader::OpenException & )
|
||||
{
|
||||
}
|
||||
catch (FileReader::OpenException &)
|
||||
{}
|
||||
}
|
||||
|
||||
UNIT_TEST(FileWriter_AppendAndOpenExisting)
|
||||
{
|
||||
char const fileName [] = "append_openexisting_file_test";
|
||||
char const fileName[] = "append_openexisting_file_test";
|
||||
{
|
||||
FileWriter writer(fileName);
|
||||
}
|
||||
@@ -187,14 +186,14 @@ void WriteTestData1(Writer & w)
|
||||
void WriteTestData2(Writer & w)
|
||||
{
|
||||
char c[CHUNK_SIZE];
|
||||
for (size_t i = 1; i < CHUNKS_COUNT; i +=2)
|
||||
for (size_t i = 1; i < CHUNKS_COUNT; i += 2)
|
||||
{
|
||||
for (size_t j = 0; j < ARRAY_SIZE(c); ++j)
|
||||
c[j] = i;
|
||||
w.Seek(i * CHUNK_SIZE);
|
||||
w.Write(&c[0], ARRAY_SIZE(c));
|
||||
}
|
||||
for (size_t i = 0; i < CHUNKS_COUNT; i +=2)
|
||||
for (size_t i = 0; i < CHUNKS_COUNT; i += 2)
|
||||
{
|
||||
for (size_t j = 0; j < ARRAY_SIZE(c); ++j)
|
||||
c[j] = i;
|
||||
|
||||
@@ -55,10 +55,7 @@ public:
|
||||
|
||||
void CharData(std::string const & ch) {}
|
||||
|
||||
void AddAttr(std::string key, std::string value)
|
||||
{
|
||||
m_addAttrs.emplace_back(std::move(key), std::move(value));
|
||||
}
|
||||
void AddAttr(std::string key, std::string value) { m_addAttrs.emplace_back(std::move(key), std::move(value)); }
|
||||
|
||||
bool Push(std::string push)
|
||||
{
|
||||
@@ -66,25 +63,13 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void Pop(std::string pop)
|
||||
{
|
||||
m_pops.emplace_back(std::move(pop));
|
||||
}
|
||||
void Pop(std::string pop) { m_pops.emplace_back(std::move(pop)); }
|
||||
|
||||
void TestAddAttrs(PairsOfStrings const & addAttrs)
|
||||
{
|
||||
TestEquality(m_addAttrs, addAttrs);
|
||||
}
|
||||
void TestAddAttrs(PairsOfStrings const & addAttrs) { TestEquality(m_addAttrs, addAttrs); }
|
||||
|
||||
void TestPushes(Strings const & pushes)
|
||||
{
|
||||
TestEquality(m_pushes, pushes);
|
||||
}
|
||||
void TestPushes(Strings const & pushes) { TestEquality(m_pushes, pushes); }
|
||||
|
||||
void TestPops(Strings const & pops)
|
||||
{
|
||||
TestEquality(m_pops, pops);
|
||||
}
|
||||
void TestPops(Strings const & pops) { TestEquality(m_pops, pops); }
|
||||
|
||||
private:
|
||||
template <typename F>
|
||||
@@ -123,13 +108,12 @@ UNIT_TEST(XmlParser_LongTest)
|
||||
{
|
||||
Dispatcher d;
|
||||
TestXML(longXml, d);
|
||||
d.TestAddAttrs({std::make_pair("vertical", "bottom"), std::make_pair("horizontal", "left"),
|
||||
std::make_pair("x", "10"), std::make_pair("vertical", "center"),
|
||||
std::make_pair("vertical", "top"), std::make_pair("vertical", "top"),
|
||||
std::make_pair("x", "34"), std::make_pair("y", "48")});
|
||||
d.TestPushes({"root", "ruler", "portrait", "anchor", "offset", "compass", "portrait", "anchor",
|
||||
"relative", "landscape", "relative", "offset"});
|
||||
d.TestPops({"anchor", "offset", "portrait", "ruler", "anchor", "relative", "portrait", "relative",
|
||||
"offset", "landscape", "compass", "root"});
|
||||
d.TestAddAttrs({std::make_pair("vertical", "bottom"), std::make_pair("horizontal", "left"), std::make_pair("x", "10"),
|
||||
std::make_pair("vertical", "center"), std::make_pair("vertical", "top"),
|
||||
std::make_pair("vertical", "top"), std::make_pair("x", "34"), std::make_pair("y", "48")});
|
||||
d.TestPushes({"root", "ruler", "portrait", "anchor", "offset", "compass", "portrait", "anchor", "relative",
|
||||
"landscape", "relative", "offset"});
|
||||
d.TestPops({"anchor", "offset", "portrait", "ruler", "anchor", "relative", "portrait", "relative", "offset",
|
||||
"landscape", "compass", "root"});
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/constants.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/internal/file_data.hpp"
|
||||
#include "coding/zip_creator.hpp"
|
||||
#include "coding/zip_reader.hpp"
|
||||
#include "coding/internal/file_data.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/constants.hpp"
|
||||
|
||||
#include "base/scope_guard.hpp"
|
||||
|
||||
@@ -30,8 +30,7 @@ void CreateAndTestZip(std::string const & filePath, std::string const & zipPath)
|
||||
TEST(base::DeleteFileX(unzippedFile), ());
|
||||
}
|
||||
|
||||
void CreateAndTestZip(std::vector<std::string> const & files, std::string const & zipPath,
|
||||
CompressionLevel compression)
|
||||
void CreateAndTestZip(std::vector<std::string> const & files, std::string const & zipPath, CompressionLevel compression)
|
||||
{
|
||||
TEST(CreateZipFromFiles(files, zipPath, compression), ());
|
||||
|
||||
@@ -50,8 +49,8 @@ void CreateAndTestZip(std::vector<std::string> const & files, std::string const
|
||||
TEST(base::DeleteFileX(zipPath), ());
|
||||
}
|
||||
|
||||
void CreateAndTestZipWithFolder(std::vector<std::string> const & files, std::vector<std::string> const & filesInArchive, std::string const & zipPath,
|
||||
CompressionLevel compression)
|
||||
void CreateAndTestZipWithFolder(std::vector<std::string> const & files, std::vector<std::string> const & filesInArchive,
|
||||
std::string const & zipPath, CompressionLevel compression)
|
||||
{
|
||||
TEST(CreateZipFromFiles(files, filesInArchive, zipPath, compression), ());
|
||||
|
||||
@@ -72,10 +71,10 @@ void CreateAndTestZipWithFolder(std::vector<std::string> const & files, std::vec
|
||||
|
||||
std::vector<CompressionLevel> GetCompressionLevels()
|
||||
{
|
||||
return {CompressionLevel::DefaultCompression, CompressionLevel::BestCompression,
|
||||
CompressionLevel::BestSpeed, CompressionLevel::NoCompression};
|
||||
}
|
||||
return {CompressionLevel::DefaultCompression, CompressionLevel::BestCompression, CompressionLevel::BestSpeed,
|
||||
CompressionLevel::NoCompression};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(CreateZip_BigFile)
|
||||
{
|
||||
@@ -105,7 +104,8 @@ UNIT_TEST(CreateZip_Smoke)
|
||||
UNIT_TEST(CreateZip_MultipleFiles)
|
||||
{
|
||||
std::vector<std::string> const fileData{"testf1", "testfile2", "testfile3_longname.txt.xml.csv"};
|
||||
SCOPE_GUARD(deleteFileGuard, [&fileData]() {
|
||||
SCOPE_GUARD(deleteFileGuard, [&fileData]()
|
||||
{
|
||||
for (auto const & file : fileData)
|
||||
TEST(base::DeleteFileX(file), ());
|
||||
});
|
||||
@@ -150,7 +150,5 @@ UNIT_TEST(CreateZip_MultipleFilesSingleEmpty)
|
||||
}
|
||||
|
||||
for (auto compression : GetCompressionLevels())
|
||||
{
|
||||
CreateAndTestZip(fileData, "testzip.zip", compression);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "coding/zip_reader.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/zip_reader.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/macros.hpp"
|
||||
@@ -11,17 +11,18 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
static char const zipBytes[] = "PK\003\004\n\0\0\0\0\0\222\226\342>\302\032"
|
||||
"x\372\005\0\0\0\005\0\0\0\b\0\034\0te"
|
||||
"st.txtUT\t\0\003\303>\017N\017"
|
||||
"?\017Nux\v\0\001\004\365\001\0\0\004P\0"
|
||||
"\0\0Test\nPK\001\002\036\003\n\0\0"
|
||||
"\0\0\0\222\226\342>\302\032x\372\005\0\0\0\005"
|
||||
"\0\0\0\b\0\030\0\0\0\0\0\0\0\0\0\244"
|
||||
"\201\0\0\0\0test.txtUT\005"
|
||||
"\0\003\303>\017Nux\v\0\001\004\365\001\0\0"
|
||||
"\004P\0\0\0PK\005\006\0\0\0\0\001\0\001"
|
||||
"\0N\0\0\0G\0\0\0\0\0";
|
||||
static char const zipBytes[] =
|
||||
"PK\003\004\n\0\0\0\0\0\222\226\342>\302\032"
|
||||
"x\372\005\0\0\0\005\0\0\0\b\0\034\0te"
|
||||
"st.txtUT\t\0\003\303>\017N\017"
|
||||
"?\017Nux\v\0\001\004\365\001\0\0\004P\0"
|
||||
"\0\0Test\nPK\001\002\036\003\n\0\0"
|
||||
"\0\0\0\222\226\342>\302\032x\372\005\0\0\0\005"
|
||||
"\0\0\0\b\0\030\0\0\0\0\0\0\0\0\0\244"
|
||||
"\201\0\0\0\0test.txtUT\005"
|
||||
"\0\003\303>\017Nux\v\0\001\004\365\001\0\0"
|
||||
"\004P\0\0\0PK\005\006\0\0\0\0\001\0\001"
|
||||
"\0N\0\0\0G\0\0\0\0\0";
|
||||
|
||||
UNIT_TEST(ZipReaderSmoke)
|
||||
{
|
||||
@@ -74,21 +75,22 @@ UNIT_TEST(ZipReaderSmoke)
|
||||
}
|
||||
|
||||
/// zip file with 3 files inside: 1.txt, 2.txt, 3.ttt
|
||||
static char const zipBytes2[] = "\x50\x4b\x3\x4\xa\x0\x0\x0\x0\x0\x92\x6b\xf6\x3e\x53\xfc\x51\x67\x2\x0\x0"
|
||||
"\x0\x2\x0\x0\x0\x5\x0\x1c\x0\x31\x2e\x74\x78\x74\x55\x54\x9\x0\x3\xd3\x50\x29\x4e\xd4\x50\x29\x4e\x75\x78"
|
||||
"\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0\x0\x0\x31\xa\x50\x4b\x3\x4\xa\x0\x0\x0\x0\x0\x95\x6b\xf6\x3e\x90\xaf"
|
||||
"\x7c\x4c\x2\x0\x0\x0\x2\x0\x0\x0\x5\x0\x1c\x0\x32\x2e\x74\x78\x74\x55\x54\x9\x0\x3\xd9\x50\x29\x4e\xd9\x50"
|
||||
"\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0\x0\x0\x32\xa\x50\x4b\x3\x4\xa\x0\x0\x0\x0\x0\x9c\x6b"
|
||||
"\xf6\x3e\xd1\x9e\x67\x55\x2\x0\x0\x0\x2\x0\x0\x0\x5\x0\x1c\x0\x33\x2e\x74\x74\x74\x55\x54\x9\x0\x3\xe8\x50"
|
||||
"\x29\x4e\xe9\x50\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0\x0\x0\x33\xa\x50\x4b\x1\x2\x1e\x3\xa"
|
||||
"\x0\x0\x0\x0\x0\x92\x6b\xf6\x3e\x53\xfc\x51\x67\x2\x0\x0\x0\x2\x0\x0\x0\x5\x0\x18\x0\x0\x0\x0\x0\x1\x0\x0"
|
||||
"\x0\xa4\x81\x0\x0\x0\x0\x31\x2e\x74\x78\x74\x55\x54\x5\x0\x3\xd3\x50\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0"
|
||||
"\x0\x4\x14\x0\x0\x0\x50\x4b\x1\x2\x1e\x3\xa\x0\x0\x0\x0\x0\x95\x6b\xf6\x3e\x90\xaf\x7c\x4c\x2\x0\x0\x0\x2"
|
||||
"\x0\x0\x0\x5\x0\x18\x0\x0\x0\x0\x0\x1\x0\x0\x0\xa4\x81\x41\x0\x0\x0\x32\x2e\x74\x78\x74\x55\x54\x5\x0\x3"
|
||||
"\xd9\x50\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0\x0\x0\x50\x4b\x1\x2\x1e\x3\xa\x0\x0\x0\x0\x0"
|
||||
"\x9c\x6b\xf6\x3e\xd1\x9e\x67\x55\x2\x0\x0\x0\x2\x0\x0\x0\x5\x0\x18\x0\x0\x0\x0\x0\x1\x0\x0\x0\xa4\x81\x82"
|
||||
"\x0\x0\x0\x33\x2e\x74\x74\x74\x55\x54\x5\x0\x3\xe8\x50\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0"
|
||||
"\x0\x0\x50\x4b\x5\x6\x0\x0\x0\x0\x3\x0\x3\x0\xe1\x0\x0\x0\xc3\x0\x0\x0\x0\x0";
|
||||
static char const zipBytes2[] =
|
||||
"\x50\x4b\x3\x4\xa\x0\x0\x0\x0\x0\x92\x6b\xf6\x3e\x53\xfc\x51\x67\x2\x0\x0"
|
||||
"\x0\x2\x0\x0\x0\x5\x0\x1c\x0\x31\x2e\x74\x78\x74\x55\x54\x9\x0\x3\xd3\x50\x29\x4e\xd4\x50\x29\x4e\x75\x78"
|
||||
"\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0\x0\x0\x31\xa\x50\x4b\x3\x4\xa\x0\x0\x0\x0\x0\x95\x6b\xf6\x3e\x90\xaf"
|
||||
"\x7c\x4c\x2\x0\x0\x0\x2\x0\x0\x0\x5\x0\x1c\x0\x32\x2e\x74\x78\x74\x55\x54\x9\x0\x3\xd9\x50\x29\x4e\xd9\x50"
|
||||
"\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0\x0\x0\x32\xa\x50\x4b\x3\x4\xa\x0\x0\x0\x0\x0\x9c\x6b"
|
||||
"\xf6\x3e\xd1\x9e\x67\x55\x2\x0\x0\x0\x2\x0\x0\x0\x5\x0\x1c\x0\x33\x2e\x74\x74\x74\x55\x54\x9\x0\x3\xe8\x50"
|
||||
"\x29\x4e\xe9\x50\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0\x0\x0\x33\xa\x50\x4b\x1\x2\x1e\x3\xa"
|
||||
"\x0\x0\x0\x0\x0\x92\x6b\xf6\x3e\x53\xfc\x51\x67\x2\x0\x0\x0\x2\x0\x0\x0\x5\x0\x18\x0\x0\x0\x0\x0\x1\x0\x0"
|
||||
"\x0\xa4\x81\x0\x0\x0\x0\x31\x2e\x74\x78\x74\x55\x54\x5\x0\x3\xd3\x50\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0"
|
||||
"\x0\x4\x14\x0\x0\x0\x50\x4b\x1\x2\x1e\x3\xa\x0\x0\x0\x0\x0\x95\x6b\xf6\x3e\x90\xaf\x7c\x4c\x2\x0\x0\x0\x2"
|
||||
"\x0\x0\x0\x5\x0\x18\x0\x0\x0\x0\x0\x1\x0\x0\x0\xa4\x81\x41\x0\x0\x0\x32\x2e\x74\x78\x74\x55\x54\x5\x0\x3"
|
||||
"\xd9\x50\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0\x0\x0\x50\x4b\x1\x2\x1e\x3\xa\x0\x0\x0\x0\x0"
|
||||
"\x9c\x6b\xf6\x3e\xd1\x9e\x67\x55\x2\x0\x0\x0\x2\x0\x0\x0\x5\x0\x18\x0\x0\x0\x0\x0\x1\x0\x0\x0\xa4\x81\x82"
|
||||
"\x0\x0\x0\x33\x2e\x74\x74\x74\x55\x54\x5\x0\x3\xe8\x50\x29\x4e\x75\x78\xb\x0\x1\x4\xf5\x1\x0\x0\x4\x14\x0"
|
||||
"\x0\x0\x50\x4b\x5\x6\x0\x0\x0\x0\x3\x0\x3\x0\xe1\x0\x0\x0\xc3\x0\x0\x0\x0\x0";
|
||||
|
||||
static char const invalidZip[] = "1234567890asdqwetwezxvcbdhg322353tgfsd";
|
||||
|
||||
@@ -132,8 +134,7 @@ UNIT_TEST(ZipFilesList)
|
||||
TEST(false, ("This test shouldn't be reached - exception should be thrown"));
|
||||
}
|
||||
catch (exception const &)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
FileWriter::DeleteFileX(ZIPFILE_INVALID);
|
||||
FileWriter::DeleteFileX(ZIPFILE);
|
||||
@@ -142,26 +143,26 @@ UNIT_TEST(ZipFilesList)
|
||||
/// Compressed zip file with 2 files in assets folder:
|
||||
/// assets/aaaaaaaaaa.txt (contains text "aaaaaaaaaa\x0A")
|
||||
/// assets/holalala.txt (contains text "Holalala\x0A")
|
||||
static char const zipBytes3[] = \
|
||||
"\x50\x4B\x03\x04\x14\x00\x02\x00\x08\x00\xAF\x96\x56\x40\x42\xE5\x26\x8F\x06\x00" \
|
||||
"\x00\x00\x0B\x00\x00\x00\x15\x00\x1C\x00\x61\x73\x73\x65\x74\x73\x2F\x61\x61\x61" \
|
||||
"\x61\x61\x61\x61\x61\x61\x61\x2E\x74\x78\x74\x55\x54\x09\x00\x03\x7A\x0F\x45\x4F" \
|
||||
"\xD8\x0F\x45\x4F\x75\x78\x0B\x00\x01\x04\xF5\x01\x00\x00\x04\x14\x00\x00\x00\x4B" \
|
||||
"\x4C\x84\x01\x2E\x00\x50\x4B\x03\x04\x14\x00\x02\x00\x08\x00\xE6\x96\x56\x40\x5E" \
|
||||
"\x76\x90\x07\x08\x00\x00\x00\x09\x00\x00\x00\x13\x00\x1C\x00\x61\x73\x73\x65\x74" \
|
||||
"\x73\x2F\x68\x6F\x6C\x61\x6C\x61\x6C\x61\x2E\x74\x78\x74\x55\x54\x09\x00\x03\xDF" \
|
||||
"\x0F\x45\x4F\xDC\x0F\x45\x4F\x75\x78\x0B\x00\x01\x04\xF5\x01\x00\x00\x04\x14\x00" \
|
||||
"\x00\x00\xF3\xC8\xCF\x49\x04\x41\x2E\x00\x50\x4B\x01\x02\x1E\x03\x14\x00\x02\x00" \
|
||||
"\x08\x00\xAF\x96\x56\x40\x42\xE5\x26\x8F\x06\x00\x00\x00\x0B\x00\x00\x00\x15\x00" \
|
||||
"\x18\x00\x00\x00\x00\x00\x01\x00\x00\x00\xA4\x81\x00\x00\x00\x00\x61\x73\x73\x65" \
|
||||
"\x74\x73\x2F\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x2E\x74\x78\x74\x55\x54\x05" \
|
||||
"\x00\x03\x7A\x0F\x45\x4F\x75\x78\x0B\x00\x01\x04\xF5\x01\x00\x00\x04\x14\x00\x00" \
|
||||
"\x00\x50\x4B\x01\x02\x1E\x03\x14\x00\x02\x00\x08\x00\xE6\x96\x56\x40\x5E\x76\x90" \
|
||||
"\x07\x08\x00\x00\x00\x09\x00\x00\x00\x13\x00\x18\x00\x00\x00\x00\x00\x01\x00\x00" \
|
||||
"\x00\xA4\x81\x55\x00\x00\x00\x61\x73\x73\x65\x74\x73\x2F\x68\x6F\x6C\x61\x6C\x61" \
|
||||
"\x6C\x61\x2E\x74\x78\x74\x55\x54\x05\x00\x03\xDF\x0F\x45\x4F\x75\x78\x0B\x00\x01" \
|
||||
"\x04\xF5\x01\x00\x00\x04\x14\x00\x00\x00\x50\x4B\x05\x06\x00\x00\x00\x00\x02\x00" \
|
||||
"\x02\x00\xB4\x00\x00\x00\xAA\x00\x00\x00\x00\x00";
|
||||
static char const zipBytes3[] =
|
||||
"\x50\x4B\x03\x04\x14\x00\x02\x00\x08\x00\xAF\x96\x56\x40\x42\xE5\x26\x8F\x06\x00"
|
||||
"\x00\x00\x0B\x00\x00\x00\x15\x00\x1C\x00\x61\x73\x73\x65\x74\x73\x2F\x61\x61\x61"
|
||||
"\x61\x61\x61\x61\x61\x61\x61\x2E\x74\x78\x74\x55\x54\x09\x00\x03\x7A\x0F\x45\x4F"
|
||||
"\xD8\x0F\x45\x4F\x75\x78\x0B\x00\x01\x04\xF5\x01\x00\x00\x04\x14\x00\x00\x00\x4B"
|
||||
"\x4C\x84\x01\x2E\x00\x50\x4B\x03\x04\x14\x00\x02\x00\x08\x00\xE6\x96\x56\x40\x5E"
|
||||
"\x76\x90\x07\x08\x00\x00\x00\x09\x00\x00\x00\x13\x00\x1C\x00\x61\x73\x73\x65\x74"
|
||||
"\x73\x2F\x68\x6F\x6C\x61\x6C\x61\x6C\x61\x2E\x74\x78\x74\x55\x54\x09\x00\x03\xDF"
|
||||
"\x0F\x45\x4F\xDC\x0F\x45\x4F\x75\x78\x0B\x00\x01\x04\xF5\x01\x00\x00\x04\x14\x00"
|
||||
"\x00\x00\xF3\xC8\xCF\x49\x04\x41\x2E\x00\x50\x4B\x01\x02\x1E\x03\x14\x00\x02\x00"
|
||||
"\x08\x00\xAF\x96\x56\x40\x42\xE5\x26\x8F\x06\x00\x00\x00\x0B\x00\x00\x00\x15\x00"
|
||||
"\x18\x00\x00\x00\x00\x00\x01\x00\x00\x00\xA4\x81\x00\x00\x00\x00\x61\x73\x73\x65"
|
||||
"\x74\x73\x2F\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x2E\x74\x78\x74\x55\x54\x05"
|
||||
"\x00\x03\x7A\x0F\x45\x4F\x75\x78\x0B\x00\x01\x04\xF5\x01\x00\x00\x04\x14\x00\x00"
|
||||
"\x00\x50\x4B\x01\x02\x1E\x03\x14\x00\x02\x00\x08\x00\xE6\x96\x56\x40\x5E\x76\x90"
|
||||
"\x07\x08\x00\x00\x00\x09\x00\x00\x00\x13\x00\x18\x00\x00\x00\x00\x00\x01\x00\x00"
|
||||
"\x00\xA4\x81\x55\x00\x00\x00\x61\x73\x73\x65\x74\x73\x2F\x68\x6F\x6C\x61\x6C\x61"
|
||||
"\x6C\x61\x2E\x74\x78\x74\x55\x54\x05\x00\x03\xDF\x0F\x45\x4F\x75\x78\x0B\x00\x01"
|
||||
"\x04\xF5\x01\x00\x00\x04\x14\x00\x00\x00\x50\x4B\x05\x06\x00\x00\x00\x00\x02\x00"
|
||||
"\x02\x00\xB4\x00\x00\x00\xAA\x00\x00\x00\x00\x00";
|
||||
|
||||
UNIT_TEST(ZipExtract)
|
||||
{
|
||||
|
||||
@@ -19,11 +19,10 @@ using namespace std;
|
||||
using Deflate = ZLib::Deflate;
|
||||
using Inflate = ZLib::Inflate;
|
||||
|
||||
pair<Deflate::Format, Inflate::Format> const g_combinations[] = {
|
||||
{Deflate::Format::ZLib, Inflate::Format::ZLib},
|
||||
{Deflate::Format::ZLib, Inflate::Format::Both},
|
||||
{Deflate::Format::GZip, Inflate::Format::GZip},
|
||||
{Deflate::Format::GZip, Inflate::Format::Both}};
|
||||
pair<Deflate::Format, Inflate::Format> const g_combinations[] = {{Deflate::Format::ZLib, Inflate::Format::ZLib},
|
||||
{Deflate::Format::ZLib, Inflate::Format::Both},
|
||||
{Deflate::Format::GZip, Inflate::Format::GZip},
|
||||
{Deflate::Format::GZip, Inflate::Format::Both}};
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -75,10 +74,9 @@ UNIT_TEST(GZip_ForeignData)
|
||||
// To get this array of bytes, type following:
|
||||
//
|
||||
// echo -n 'Hello World!' | gzip -c | od -t x1
|
||||
uint8_t const data[] = {0x1f, 0x8b, 0x08, 0x08, 0x6d, 0x55, 0x08, 0x59, 0x00, 0x03, 0x73,
|
||||
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x74, 0x78, 0x74, 0x00, 0xf3,
|
||||
0x48, 0xcd, 0xc9, 0xc9, 0xd7, 0x51, 0x08, 0xcf, 0x2f, 0xca, 0x49,
|
||||
0x51, 0x04, 0x00, 0xd0, 0xc3, 0x4a, 0xec, 0x0d, 0x00, 0x00, 0x00};
|
||||
uint8_t const data[] = {0x1f, 0x8b, 0x08, 0x08, 0x6d, 0x55, 0x08, 0x59, 0x00, 0x03, 0x73, 0x61, 0x6d, 0x70, 0x6c,
|
||||
0x65, 0x2e, 0x74, 0x78, 0x74, 0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0xd7, 0x51, 0x08, 0xcf,
|
||||
0x2f, 0xca, 0x49, 0x51, 0x04, 0x00, 0xd0, 0xc3, 0x4a, 0xec, 0x0d, 0x00, 0x00, 0x00};
|
||||
|
||||
string s;
|
||||
|
||||
@@ -90,11 +88,9 @@ UNIT_TEST(GZip_ForeignData)
|
||||
UNIT_TEST(GZip_ExtraDataInBuffer)
|
||||
{
|
||||
// Data from GZip_ForeignData + extra \n at the end of the buffer.
|
||||
uint8_t const data[] = {0x1f, 0x8b, 0x08, 0x08, 0x6d, 0x55, 0x08, 0x59, 0x00, 0x03, 0x73,
|
||||
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x74, 0x78, 0x74, 0x00, 0xf3,
|
||||
0x48, 0xcd, 0xc9, 0xc9, 0xd7, 0x51, 0x08, 0xcf, 0x2f, 0xca, 0x49,
|
||||
0x51, 0x04, 0x00, 0xd0, 0xc3, 0x4a, 0xec, 0x0d, 0x00, 0x00, 0x00,
|
||||
0x0a};
|
||||
uint8_t const data[] = {0x1f, 0x8b, 0x08, 0x08, 0x6d, 0x55, 0x08, 0x59, 0x00, 0x03, 0x73, 0x61, 0x6d, 0x70, 0x6c,
|
||||
0x65, 0x2e, 0x74, 0x78, 0x74, 0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0xd7, 0x51, 0x08, 0xcf,
|
||||
0x2f, 0xca, 0x49, 0x51, 0x04, 0x00, 0xd0, 0xc3, 0x4a, 0xec, 0x0d, 0x00, 0x00, 0x00, 0x0a};
|
||||
|
||||
string s;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user