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 | |
27 | namespace folly { |
28 | namespace test { |
29 | namespace detail { |
30 | |
31 | RandomT rng(seed); |
32 | |
33 | std::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 | |
42 | template <> |
43 | int randomObject<int>() { |
44 | return random(0, 1024); |
45 | } |
46 | |
47 | template <> |
48 | std::string randomObject<std::string>() { |
49 | std::string result; |
50 | randomString(&result); |
51 | return result; |
52 | } |
53 | |
54 | template <> |
55 | folly::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 |