MCPcopy Create free account
hub / github.com/facebook/CacheLib / getRandomAsciiStr

Function getRandomAsciiStr

cachelib/common/TestUtils.cpp:95–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95std::string getRandomAsciiStr(unsigned int len) {
96 std::string s;
97 s.reserve(len);
98 static const char start[] = {'a', 'A', '0'};
99 static const int size[] = {26, 26, 10};
100
101 for (unsigned int i = 0; i < len; i++) {
102 unsigned int index =
103 folly::Random::rand32(sizeof(start) / sizeof(start[0]));
104 const char c =
105 (start[index] + static_cast<char>(folly::Random::rand32(size[index])));
106 s += c;
107 }
108 XDCHECK_EQ(s.length(), len);
109 return s;
110}
111
112} // namespace test_util
113} // namespace cachelib

Callers 10

getRandomStrMethod · 0.85
testAllocExceptionMethod · 0.85
testLargeKeysMethod · 0.85
testPoolNameMethod · 0.85
testCacheStatsMethod · 0.85
getRandomNewKeyMethod · 0.85
TESTFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected