| 365 | static const char AlphabetChSeq[AlphabetChSeqLen] = "你好中文字符串|。,;()【】?!测试啊哈"; // len 64 |
| 366 | |
| 367 | inline std::string getRandomChars() { |
| 368 | std::stringstream randomStringStream; |
| 369 | int len = randomInt(11, 1000); |
| 370 | auto seed = (unsigned int) std::time(nullptr); |
| 371 | while (len-- > 0) { |
| 372 | std::srand(len * 2 ^ 8 + seed); |
| 373 | int rand = std::rand(); |
| 374 | int i = rand % (AlphabetSeqLen * 4 + AlphabetChSeqLen); |
| 375 | if (i < AlphabetSeqLen * 4) { |
| 376 | i /= 4; |
| 377 | randomStringStream << AlphabetSeq[i]; |
| 378 | } else { |
| 379 | i -= (AlphabetSeqLen * 4); |
| 380 | i = i / 3 * 3; |
| 381 | randomStringStream << AlphabetChSeq[i] << AlphabetChSeq[i + 1] |
| 382 | << AlphabetChSeq[i + 2]; |
| 383 | len -= 2; |
| 384 | } |
| 385 | } |
| 386 | return randomStringStream.str(); |
| 387 | } |
| 388 | |
| 389 | } |
| 390 | #endif //BASE_H_ |