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:
authorYury Melnichek <melnichek@gmail.com>2012-07-24 03:08:17 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:43:30 +0300
commit3d019bb1c8b41d94427a10b5b0a371f72821dc54 (patch)
tree47fb2cbc1eb7cafc5a473eff803f037cc5043fbb /publisher
parent2a5f6bcc14ec1901c37303aad8d94e51b097fb68 (diff)
[sloynik] Minor test refactoring.
Diffstat (limited to 'publisher')
-rw-r--r--publisher/publisher_tests/slof_indexer_test.cpp27
1 files changed, 7 insertions, 20 deletions
diff --git a/publisher/publisher_tests/slof_indexer_test.cpp b/publisher/publisher_tests/slof_indexer_test.cpp
index 29ef3a87c4..4a21a2c59f 100644
--- a/publisher/publisher_tests/slof_indexer_test.cpp
+++ b/publisher/publisher_tests/slof_indexer_test.cpp
@@ -1,5 +1,8 @@
#include "../../testing/testing.hpp"
#include "../slof_indexer.hpp"
+
+#include "../../coding/coding_tests/compressor_test_utils.hpp"
+
#include "../../words/slof_dictionary.hpp"
#include "../../words/sloynik_engine.hpp"
#include "../../coding/reader.hpp"
@@ -11,22 +14,6 @@
namespace
{
- void TestCompressor(char const * pSrc, size_t srcSize, string & res)
- {
- res = "<";
- res.insert(res.end(), pSrc, pSrc + srcSize);
- res.insert(res.end(), '>');
- }
-
- void TestDecompressor(char const * pSrc, size_t srcSize, char * pDst, size_t dstSize)
- {
- TEST_GREATER_OR_EQUAL(srcSize, 2, ());
- TEST_EQUAL(srcSize - 2, dstSize, ());
- TEST_EQUAL(pSrc[0], '<', ());
- TEST_EQUAL(pSrc[srcSize-1], '>', ());
- memcpy(pDst, pSrc + 1, srcSize - 2);
- }
-
string Key(sl::SlofDictionary const & dic, sl::Dictionary::Id id)
{
string res;
@@ -47,10 +34,10 @@ UNIT_TEST(SlofIndexerEmptyTest)
string serializedDictionary;
{
MemWriter<string> writer(serializedDictionary);
- sl::SlofIndexer indexer(writer, 20, &TestCompressor);
+ sl::SlofIndexer indexer(writer, 20, &coding::TestCompressor);
}
sl::SlofDictionary dic(new MemReader(&serializedDictionary[0], serializedDictionary.size()),
- &TestDecompressor);
+ &coding::TestDecompressor);
TEST_EQUAL(dic.KeyCount(), 0, ());
}
@@ -59,7 +46,7 @@ UNIT_TEST(SlofIndexerSmokeTest)
string serializedDictionary;
{
MemWriter<string> writer(serializedDictionary);
- sl::SlofIndexer indexer(writer, 25, &TestCompressor);
+ sl::SlofIndexer indexer(writer, 25, &coding::TestCompressor);
uint64_t articleM = indexer.AddArticle("ArticleM");
indexer.AddKey("M", articleM);
uint64_t articleHello = indexer.AddArticle("ArticleHello");
@@ -70,7 +57,7 @@ UNIT_TEST(SlofIndexerSmokeTest)
}
{
sl::SlofDictionary dic(new MemReader(&serializedDictionary[0], serializedDictionary.size()),
- &TestDecompressor);
+ &coding::TestDecompressor);
TEST_EQUAL(dic.KeyCount(), 4, ());
TEST_EQUAL(Key(dic, 0), "He", ());
TEST_EQUAL(Key(dic, 1), "Hello", ());