1/*
2 * Copyright 2018-present Facebook, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <folly/test/FBVectorTestUtil.h>
18
19#include <list>
20#include <string>
21
22#include <boost/random/mersenne_twister.hpp>
23
24#include <folly/FBString.h>
25#include <folly/Random.h>
26
27namespace folly {
28namespace test {
29namespace detail {
30
31RandomT rng(seed);
32
33std::list<char> RandomList(unsigned int maxSize) {
34 std::list<char> lst(random(0u, maxSize));
35 std::list<char>::iterator i = lst.begin();
36 for (; i != lst.end(); ++i) {
37 *i = random('a', 'z');
38 }
39 return lst;
40}
41
42template <>
43int randomObject<int>() {
44 return random(0, 1024);
45}
46
47template <>
48std::string randomObject<std::string>() {
49 std::string result;
50 randomString(&result);
51 return result;
52}
53
54template <>
55folly::fbstring randomObject<folly::fbstring>() {
56 folly::fbstring result;
57 randomString(&result);
58 return result;
59}
60} // namespace detail
61} // namespace test
62} // namespace folly
63