replace boost filesystem with std filesystem; upgrade gtest and find it using cmake.

This commit is contained in:
Chunting Gu
2020-02-15 12:04:51 +08:00
parent 7e3da65e73
commit 7e7ab1c1e8
72 changed files with 233 additions and 31551 deletions
+40
View File
@@ -0,0 +1,40 @@
#include "webcc/string.h"
#include <random>
namespace webcc {
namespace string {
// See: https://stackoverflow.com/a/24586587
std::string RandomString(std::size_t length) {
static const char chrs[] =
"0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
thread_local static std::mt19937 rg{ std::random_device{}() };
thread_local static std::uniform_int_distribution<std::string::size_type>
pick(0, sizeof(chrs) - 2);
std::string s;
s.reserve(length);
while (length--) {
s += chrs[pick(rg)];
}
return s;
}
bool EqualsNoCase(const std::string& str1, const std::string& str2) {
if (str1.size() != str2.size()) {
return false;
}
return std::equal(str1.begin(), str1.end(), str2.begin(), [](int c1, int c2) {
return std::toupper(c1) == std::toupper(c2);
});
}
} // namespace string
} // namespace webcc