MCPcopy Create free account
hub / github.com/ElementsProject/elements / CreateRandomString

Function CreateRandomString

src/leveldb/issues/issue320_test.cc:23–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21int GenerateRandomNumber(int max) { return std::rand() % max; }
22
23std::string CreateRandomString(int32_t index) {
24 static const size_t len = 1024;
25 char bytes[len];
26 size_t i = 0;
27 while (i < 8) {
28 bytes[i] = 'a' + ((index >> (4 * i)) & 0xf);
29 ++i;
30 }
31 while (i < sizeof(bytes)) {
32 bytes[i] = 'a' + GenerateRandomNumber(26);
33 ++i;
34 }
35 return std::string(bytes, sizeof(bytes));
36}
37
38} // namespace
39

Callers 1

TESTFunction · 0.85

Calls 1

GenerateRandomNumberFunction · 0.85

Tested by

no test coverage detected