29 #if FOLLY_HAS_STRING_VIEW 30 #include <string_view> 33 using namespace folly;
37 template <
typename T,
typename Enable =
void>
44 void checkTransparent() {
50 void checkNotTransparent() {
56 std::vector<std::string>
data_;
59 return {&data_[0], data_.size()};
73 TEST(HeterogeneousAccess, transparentIsSelected) {
74 checkTransparent<std::string>();
75 checkTransparent<std::wstring>();
76 checkTransparent<std::u16string>();
77 checkTransparent<std::u32string>();
79 #if FOLLY_HAS_STRING_VIEW 80 checkTransparent<std::string_view>();
81 checkTransparent<std::wstring_view>();
82 checkTransparent<std::u16string_view>();
83 checkTransparent<std::u32string_view>();
86 checkTransparent<fbstring>();
88 checkTransparent<StringPiece>();
89 checkTransparent<MutableStringPiece>();
91 checkTransparent<Range<char const*>>();
92 checkTransparent<Range<wchar_t const*>>();
93 checkTransparent<Range<char16_t const*>>();
94 checkTransparent<Range<char32_t const*>>();
95 checkTransparent<Range<int const*>>();
97 checkTransparent<Range<char*>>();
98 checkTransparent<Range<wchar_t*>>();
99 checkTransparent<Range<char16_t*>>();
100 checkTransparent<Range<char32_t*>>();
101 checkTransparent<Range<int*>>();
103 checkTransparent<std::vector<char>>();
104 checkTransparent<std::vector<wchar_t>>();
105 checkTransparent<std::vector<char16_t>>();
106 checkTransparent<std::vector<char32_t>>();
107 checkTransparent<std::vector<int>>();
109 checkTransparent<std::array<char const, 2>>();
110 checkTransparent<std::array<wchar_t const, 2>>();
111 checkTransparent<std::array<char16_t const, 2>>();
112 checkTransparent<std::array<char32_t const, 2>>();
113 checkTransparent<std::array<int const, 2>>();
115 checkTransparent<std::array<char, 2>>();
116 checkTransparent<std::array<wchar_t, 2>>();
117 checkTransparent<std::array<char16_t, 2>>();
118 checkTransparent<std::array<char32_t, 2>>();
119 checkTransparent<std::array<int, 2>>();
122 TEST(HeterogeneousAccess, transparentIsNotSelected) {
123 checkNotTransparent<char>();
124 checkNotTransparent<int>();
125 checkNotTransparent<float>();
126 checkNotTransparent<std::pair<StringPiece, StringPiece>>();
127 checkNotTransparent<StringVector>();
130 template <
typename L,
typename R,
typename S>
133 smaller.resize(smaller.size() - 1);
137 L lhs1{RangeType{&src[0], src.size()}};
138 L lhs2{RangeType{&smaller[0], smaller.size()}};
139 R rhs1{RangeType{&src[0], src.size()}};
140 R rhs2{RangeType{&smaller[0], smaller.size()}};
155 auto v0 = smaller[0];
156 std::array<decltype(v0), 1>
a{{v0}};
168 template <
typename S>
172 #if FOLLY_HAS_STRING_VIEW 173 using SV = std::basic_string_view<typename S::value_type>;
177 using V = std::vector<typename S::value_type>;
179 runTestMatches2<S, S>(src);
180 runTestMatches2<S, SP>(src);
181 runTestMatches2<S, MSP>(src);
182 runTestMatches2<S, SV>(src);
183 runTestMatches2<S, V>(src);
184 runTestMatches2<SP, S>(src);
185 runTestMatches2<SP, SP>(src);
186 runTestMatches2<SP, MSP>(src);
187 runTestMatches2<SP, SV>(src);
188 runTestMatches2<SP, V>(src);
189 runTestMatches2<MSP, S>(src);
190 runTestMatches2<MSP, SP>(src);
191 runTestMatches2<MSP, MSP>(src);
192 runTestMatches2<MSP, SV>(src);
193 runTestMatches2<MSP, V>(src);
194 runTestMatches2<SV, S>(src);
195 runTestMatches2<SV, SP>(src);
196 runTestMatches2<SV, MSP>(src);
197 runTestMatches2<SV, SV>(src);
198 runTestMatches2<SV, V>(src);
199 runTestMatches2<V, S>(src);
200 runTestMatches2<V, SP>(src);
201 runTestMatches2<V, MSP>(src);
202 runTestMatches2<V, SV>(src);
203 runTestMatches2<V, V>(src);
210 TEST(HeterogeneousAccess, transparentMatches) {
211 runTestMatches<std::string>(
"abcd");
212 runTestMatches<std::string>(u8
"abcd");
213 runTestMatches<std::wstring>(L
"abcd");
214 runTestMatches<std::u16string>(u
"abcd");
215 runTestMatches<std::u32string>(U
"abcd");
216 runTestMatches<fbstring>(
"abcd");
217 runTestMatches<std::vector<int>>({1, 2, 3, 4});
221 runTestMatches<small_vector<int, 2>>({1, 2, 3, 4});
#define EXPECT_EQ(val1, val2)
—— Concurrent Priority Queue Implementation ——
bool_constant< true > true_type
vector< std::string > StringVector
uint64_t hash_range(Iter begin, Iter end, uint64_t hash=0, Hash hasher=Hash())
void runTestMatches(S const &src)
type_t< void, Ts... > void_t
#define EXPECT_TRUE(condition)
#define EXPECT_NE(val1, val2)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
bool_constant< false > false_type
#define EXPECT_FALSE(condition)
void runTestMatches2(S src)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
std::size_t operator()(StringVector const &value) const