forked from organicmaps/organicmaps
Removed dummy includes, avoid copy-paste.
This commit is contained in:
parent
494f5e6711
commit
69b4f096f7
8 changed files with 38 additions and 40 deletions
|
@ -29,6 +29,7 @@ SOURCES += \
|
|||
object_tracker.cpp \
|
||||
scheduled_task.cpp \
|
||||
thread_pool.cpp \
|
||||
pseudo_random.cpp \
|
||||
|
||||
HEADERS += \
|
||||
SRC_FIRST.hpp \
|
||||
|
|
20
base/pseudo_random.cpp
Normal file
20
base/pseudo_random.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include "pseudo_random.hpp"
|
||||
|
||||
|
||||
namespace rnd
|
||||
{
|
||||
|
||||
string GenerateString()
|
||||
{
|
||||
static PseudoRNG32 rng;
|
||||
|
||||
size_t const size = rng.Generate() % 20 + 1;
|
||||
string result;
|
||||
result.reserve(size);
|
||||
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
result.append(1, static_cast<char>(rng.Generate() + 1));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include "../base/base.hpp"
|
||||
|
||||
#include "../std/string.hpp"
|
||||
|
||||
|
||||
class LCG32
|
||||
{
|
||||
public:
|
||||
|
@ -19,3 +22,9 @@ private:
|
|||
};
|
||||
|
||||
typedef LCG32 PseudoRNG32;
|
||||
|
||||
|
||||
namespace rnd
|
||||
{
|
||||
string GenerateString();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
#include "../../testing/testing.hpp"
|
||||
|
||||
#include "../../base/logging.hpp"
|
||||
#include "../../base/pseudo_random.hpp"
|
||||
|
||||
#include "../base64.hpp"
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#include "../../base/SRC_FIRST.hpp"
|
||||
#include "../../testing/testing.hpp"
|
||||
|
||||
#include "../hex.hpp"
|
||||
|
||||
#include "../../base/pseudo_random.hpp"
|
||||
|
||||
#include "../../std/string.hpp"
|
||||
|
||||
|
||||
UNIT_TEST(GoldenRecode)
|
||||
{
|
||||
string data("\x01\x23\x45\x67\x89\xAB\xCD\xEF");
|
||||
|
@ -14,26 +16,12 @@ UNIT_TEST(GoldenRecode)
|
|||
TEST_EQUAL(data, FromHex(hexData), ());
|
||||
}
|
||||
|
||||
static string GenString()
|
||||
{
|
||||
static PseudoRNG32 rng;
|
||||
string result;
|
||||
// Avoid empty string, since we test it seperately.
|
||||
size_t size = rng.Generate() % 20 + 1;
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
result.append(1, static_cast<char>(rng.Generate() + 1));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
UNIT_TEST(RandomRecode)
|
||||
{
|
||||
for (size_t i = 0; i < 256; ++i)
|
||||
{
|
||||
string data = GenString();
|
||||
string recoded = FromHex(ToHex(data));
|
||||
TEST_EQUAL(data, recoded, ());
|
||||
string const data = rnd::GenerateString();
|
||||
TEST_EQUAL(data, FromHex(ToHex(data)), ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include "../../base/SRC_FIRST.hpp"
|
||||
#include "../var_serial_vector.hpp"
|
||||
|
||||
#include "../../testing/testing.hpp"
|
||||
|
@ -86,27 +85,12 @@ UNIT_TEST(ReadSerial)
|
|||
TEST_EQUAL(reader.Read(2), "ef", ());
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
string GenString()
|
||||
{
|
||||
static PseudoRNG32 rng;
|
||||
string result;
|
||||
size_t size = rng.Generate() % 20;
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
result.append(1, static_cast<char>(rng.Generate() + 1));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(EncodeDecode)
|
||||
{
|
||||
vector<string> elements;
|
||||
|
||||
for (size_t i = 0; i < 1024; ++i)
|
||||
elements.push_back(GenString());
|
||||
elements.push_back(rnd::GenerateString());
|
||||
|
||||
string serial;
|
||||
PushBackByteSink<string> sink(serial);
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
#include "../framework.hpp"
|
||||
#include "../mwm_url.hpp"
|
||||
|
||||
#include "../../coding/uri.hpp"
|
||||
|
||||
#include "../../base/string_format.hpp"
|
||||
#include "../../base/pseudo_random.hpp"
|
||||
#include "../../base/logging.hpp"
|
||||
|
||||
|
||||
using namespace url_scheme;
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#include "constants.hpp"
|
||||
|
||||
#include "../coding/file_reader.hpp"
|
||||
#include "../coding/base64.hpp"
|
||||
#include "../coding/sha2.hpp"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue