Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <deathbaba@gmail.com>2011-11-10 13:23:26 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:27:33 +0300
commitecb217280fefcf2a4306f39245c881ad38a96f16 (patch)
tree39b49c77f630c1e6c85dbccd9b2578f3cebd72c8 /platform/platform_tests
parent2dc0ca689c0ea24b5e8b28e89cabbf2bbe945fb5 (diff)
[downloader] Some fixes after code review
Diffstat (limited to 'platform/platform_tests')
-rw-r--r--platform/platform_tests/downloader_test.cpp80
1 files changed, 39 insertions, 41 deletions
diff --git a/platform/platform_tests/downloader_test.cpp b/platform/platform_tests/downloader_test.cpp
index 8cc2d32b11..2e56d401fb 100644
--- a/platform/platform_tests/downloader_test.cpp
+++ b/platform/platform_tests/downloader_test.cpp
@@ -188,7 +188,7 @@ UNIT_TEST(ChunksDownloadStrategy)
string const S1 = "UrlOfServer1";
string const S2 = "UrlOfServer2";
string const S3 = "UrlOfServer3";
- pair<int64_t, int64_t> const R1(0, 249), R2(250, 499), R3(500, 749), R4(750, 800);
+ ChunksDownloadStrategy::RangeT const R1(0, 249), R2(250, 499), R3(500, 749), R4(750, 800);
vector<string> servers;
servers.push_back(S1);
servers.push_back(S2);
@@ -198,74 +198,72 @@ UNIT_TEST(ChunksDownloadStrategy)
ChunksDownloadStrategy strategy(servers, FILE_SIZE, CHUNK_SIZE);
string s1;
- int64_t beg1, end1;
- TEST_EQUAL(strategy.NextChunk(s1, beg1, end1), ChunksDownloadStrategy::ENextChunk, ());
+ ChunksDownloadStrategy::RangeT r1;
+ TEST_EQUAL(strategy.NextChunk(s1, r1), ChunksDownloadStrategy::ENextChunk, ());
string s2;
- int64_t beg2, end2;
- TEST_EQUAL(strategy.NextChunk(s2, beg2, end2), ChunksDownloadStrategy::ENextChunk, ());
+ ChunksDownloadStrategy::RangeT r2;
+ TEST_EQUAL(strategy.NextChunk(s2, r2), ChunksDownloadStrategy::ENextChunk, ());
string s3;
- int64_t beg3, end3;
- TEST_EQUAL(strategy.NextChunk(s3, beg3, end3), ChunksDownloadStrategy::ENextChunk, ());
+ ChunksDownloadStrategy::RangeT r3;
+ TEST_EQUAL(strategy.NextChunk(s3, r3), ChunksDownloadStrategy::ENextChunk, ());
string sEmpty;
- int64_t begEmpty, endEmpty;
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
+ ChunksDownloadStrategy::RangeT rEmpty;
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
TEST(s1 != s2 && s2 != s3 && s3 != s1, (s1, s2, s3));
- pair<int64_t, int64_t> const r1(beg1, end1), r2(beg2, end2), r3(beg3, end3);
TEST(r1 != r2 && r2 != r3 && r3 != r1, (r1, r2, r3));
TEST(r1 == R1 || r1 == R2 || r1 == R3 || r1 == R4, (r1));
TEST(r2 == R1 || r2 == R2 || r2 == R3 || r2 == R4, (r2));
TEST(r3 == R1 || r3 == R2 || r3 == R3 || r3 == R4, (r3));
- strategy.ChunkFinished(true, beg1, end1);
+ strategy.ChunkFinished(true, r1);
string s4;
- int64_t beg4, end4;
- TEST_EQUAL(strategy.NextChunk(s4, beg4, end4), ChunksDownloadStrategy::ENextChunk, ());
+ ChunksDownloadStrategy::RangeT r4;
+ TEST_EQUAL(strategy.NextChunk(s4, r4), ChunksDownloadStrategy::ENextChunk, ());
TEST_EQUAL(s4, s1, ());
- pair<int64_t, int64_t> const r4(beg4, end4);
TEST(r4 != r1 && r4 != r2 && r4 != r3, (r4));
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
- strategy.ChunkFinished(false, beg2, end2);
+ strategy.ChunkFinished(false, r2);
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
- strategy.ChunkFinished(true, beg4, end4);
+ strategy.ChunkFinished(true, r4);
string s5;
- int64_t beg5, end5;
- TEST_EQUAL(strategy.NextChunk(s5, beg5, end5), ChunksDownloadStrategy::ENextChunk, ());
+ ChunksDownloadStrategy::RangeT r5;
+ TEST_EQUAL(strategy.NextChunk(s5, r5), ChunksDownloadStrategy::ENextChunk, ());
TEST_EQUAL(s5, s4, (s5, s4));
- TEST(beg5 == beg2 && end5 == end2, ());
+ TEST_EQUAL(r5, r2, ());
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
- strategy.ChunkFinished(true, beg5, end5);
+ strategy.ChunkFinished(true, r5);
// 3rd is still alive here
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::ENoFreeServers, ());
- strategy.ChunkFinished(true, beg3, end3);
+ strategy.ChunkFinished(true, r3);
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::EDownloadSucceeded, ());
- TEST_EQUAL(strategy.NextChunk(sEmpty, begEmpty, endEmpty), ChunksDownloadStrategy::EDownloadSucceeded, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::EDownloadSucceeded, ());
+ TEST_EQUAL(strategy.NextChunk(sEmpty, rEmpty), ChunksDownloadStrategy::EDownloadSucceeded, ());
}
UNIT_TEST(ChunksDownloadStrategyFAIL)
{
string const S1 = "UrlOfServer1";
string const S2 = "UrlOfServer2";
- pair<int64_t, int64_t> const R1(0, 249), R2(250, 499), R3(500, 749), R4(750, 800);
+ ChunksDownloadStrategy::RangeT const R1(0, 249), R2(250, 499), R3(500, 749), R4(750, 800);
vector<string> servers;
servers.push_back(S1);
servers.push_back(S2);
@@ -274,20 +272,20 @@ UNIT_TEST(ChunksDownloadStrategyFAIL)
ChunksDownloadStrategy strategy(servers, FILE_SIZE, CHUNK_SIZE);
string s1;
- int64_t beg1, end1;
- TEST_EQUAL(strategy.NextChunk(s1, beg1, end1), ChunksDownloadStrategy::ENextChunk, ());
+ ChunksDownloadStrategy::RangeT r1;
+ TEST_EQUAL(strategy.NextChunk(s1, r1), ChunksDownloadStrategy::ENextChunk, ());
string s2;
- int64_t beg2, end2;
- TEST_EQUAL(strategy.NextChunk(s2, beg2, end2), ChunksDownloadStrategy::ENextChunk, ());
- TEST_EQUAL(strategy.NextChunk(s2, beg2, end2), ChunksDownloadStrategy::ENoFreeServers, ());
+ ChunksDownloadStrategy::RangeT r2;
+ TEST_EQUAL(strategy.NextChunk(s2, r2), ChunksDownloadStrategy::ENextChunk, ());
+ TEST_EQUAL(strategy.NextChunk(s2, r2), ChunksDownloadStrategy::ENoFreeServers, ());
- strategy.ChunkFinished(false, beg1, end1);
+ strategy.ChunkFinished(false, r1);
- TEST_EQUAL(strategy.NextChunk(s2, beg2, end2), ChunksDownloadStrategy::ENoFreeServers, ());
+ TEST_EQUAL(strategy.NextChunk(s2, r2), ChunksDownloadStrategy::ENoFreeServers, ());
- strategy.ChunkFinished(false, beg2, end2);
+ strategy.ChunkFinished(false, r2);
- TEST_EQUAL(strategy.NextChunk(s2, beg2, end2), ChunksDownloadStrategy::EDownloadFailed, ());
+ TEST_EQUAL(strategy.NextChunk(s2, r2), ChunksDownloadStrategy::EDownloadFailed, ());
}
bool ReadFileAsString(string const & file, string & outStr)