Move test functions implementation to cpp.
GitOrigin-RevId: eec1d208f410a3f546dfe230d1780ecdac02d3b4
This commit is contained in:
parent
a9a3acf135
commit
9322bf68cd
|
@ -12,6 +12,7 @@
|
||||||
#include "td/utils/PathView.h"
|
#include "td/utils/PathView.h"
|
||||||
#include "td/utils/port/path.h"
|
#include "td/utils/port/path.h"
|
||||||
#include "td/utils/port/Stat.h"
|
#include "td/utils/port/Stat.h"
|
||||||
|
#include "td/utils/Random.h"
|
||||||
#include "td/utils/ScopeGuard.h"
|
#include "td/utils/ScopeGuard.h"
|
||||||
#include "td/utils/StringBuilder.h"
|
#include "td/utils/StringBuilder.h"
|
||||||
#include "td/utils/Time.h"
|
#include "td/utils/Time.h"
|
||||||
|
@ -20,10 +21,35 @@
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
string rand_string(int from, int to, size_t len) {
|
||||||
|
string res(len, '\0');
|
||||||
|
for (auto &c : res) {
|
||||||
|
c = static_cast<char>(Random::fast(from, to));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<string> rand_split(Slice str) {
|
||||||
|
vector<string> res;
|
||||||
|
size_t pos = 0;
|
||||||
|
while (pos < str.size()) {
|
||||||
|
size_t len;
|
||||||
|
if (Random::fast(0, 1) == 1) {
|
||||||
|
len = Random::fast(1, 10);
|
||||||
|
} else {
|
||||||
|
len = Random::fast(100, 200);
|
||||||
|
}
|
||||||
|
res.push_back(str.substr(pos, len).str());
|
||||||
|
pos += len;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
struct TestInfo {
|
struct TestInfo {
|
||||||
string name;
|
string name;
|
||||||
string result_hash; // base64
|
string result_hash; // base64
|
||||||
};
|
};
|
||||||
|
|
||||||
StringBuilder &operator<<(StringBuilder &sb, const TestInfo &info) {
|
StringBuilder &operator<<(StringBuilder &sb, const TestInfo &info) {
|
||||||
// should I use JSON?
|
// should I use JSON?
|
||||||
CHECK(!info.name.empty());
|
CHECK(!info.name.empty());
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "td/utils/format.h"
|
#include "td/utils/format.h"
|
||||||
#include "td/utils/logging.h"
|
#include "td/utils/logging.h"
|
||||||
#include "td/utils/port/thread.h"
|
#include "td/utils/port/thread.h"
|
||||||
#include "td/utils/Random.h"
|
|
||||||
#include "td/utils/Slice.h"
|
#include "td/utils/Slice.h"
|
||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
|
|
||||||
|
@ -146,29 +145,9 @@ class Stage {
|
||||||
std::atomic<uint64> value_{0};
|
std::atomic<uint64> value_{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
inline string rand_string(int from, int to, size_t len) {
|
string rand_string(int from, int to, size_t len);
|
||||||
string res(len, '\0');
|
|
||||||
for (auto &c : res) {
|
|
||||||
c = static_cast<char>(Random::fast(from, to));
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline vector<string> rand_split(Slice str) {
|
vector<string> rand_split(Slice str);
|
||||||
vector<string> res;
|
|
||||||
size_t pos = 0;
|
|
||||||
while (pos < str.size()) {
|
|
||||||
size_t len;
|
|
||||||
if (Random::fast(0, 1) == 1) {
|
|
||||||
len = Random::fast(1, 10);
|
|
||||||
} else {
|
|
||||||
len = Random::fast(100, 200);
|
|
||||||
}
|
|
||||||
res.push_back(str.substr(pos, len).str());
|
|
||||||
pos += len;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
void assert_eq_impl(const T1 &expected, const T2 &got, const char *file, int line) {
|
void assert_eq_impl(const T1 &expected, const T2 &got, const char *file, int line) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user