140 std::vector<
int> vec = {1, 2};
141 std::vector<
int> vec2 = {3, 4};
142 pdfium::span<
int> empty;
143 pdfium::span<
int> some =
pdfium::make_span(vec);
144 pdfium::span<
int> some2 =
pdfium::make_span(vec2);
145 EXPECT_FALSE(
fxcrt::span_equals(empty, some));
146 EXPECT_FALSE(
fxcrt::span_equals(some, empty));
147 EXPECT_TRUE(
fxcrt::span_equals(empty, empty));
148 EXPECT_TRUE(
fxcrt::span_equals(empty, some.first(0)));
149 EXPECT_TRUE(
fxcrt::span_equals(some.first(0), empty));
150 EXPECT_TRUE(
fxcrt::span_equals(some2.first(0), some.first(0)));
151 EXPECT_TRUE(
fxcrt::span_equals(some.first(0), some2.first(0)));
155 std::vector<
int> vec = {1, 2, 3};
156 std::vector<
int> vec2 = {1, 2, 4};
157 pdfium::span<
int> some =
pdfium::make_span(vec);
158 pdfium::span<
int> some2 =
pdfium::make_span(vec2);
159 EXPECT_FALSE(
fxcrt::span_equals(some, some2));
160 EXPECT_FALSE(
fxcrt::span_equals(some.first(2), some2));
161 EXPECT_FALSE(
fxcrt::span_equals(some, some2.first(2)));
162 EXPECT_TRUE(
fxcrt::span_equals(some.first(2), some2.first(2)));
174 pdfium::span<uint8_t> empty;
175 pdfium::span<uint32_t> converted =
fxcrt::reinterpret_span<uint32_t>(empty);
176 EXPECT_EQ(converted.data(),
nullptr);
177 EXPECT_EQ(converted.size(), 0u);
181 uint8_t aaaabbbb[8] = {0x61, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 0x62};
182 pdfium::span<uint8_t> original =
pdfium::make_span(aaaabbbb);
183 pdfium::span<uint32_t> converted =
184 fxcrt::reinterpret_span<uint32_t>(original);
185 ASSERT_NE(converted.data(),
nullptr);
186 ASSERT_EQ(converted.size(), 2u);
187 EXPECT_EQ(converted[0], 0x61616161u);
188 EXPECT_EQ(converted[1], 0x62626262u);
199 pdfium::span<
const uint32_t> kEmpty;
200 const uint32_t kHaystack[] = {0, 1, 2, 3, 4, 5};
201 const uint32_t kNeedle[] = {1, 2};
202 EXPECT_FALSE(
fxcrt::spanpos(kEmpty, kEmpty));
203 EXPECT_FALSE(
fxcrt::spanpos(
pdfium::make_span(kHaystack), kEmpty));
204 EXPECT_FALSE(
fxcrt::spanpos(kEmpty,
pdfium::make_span(kNeedle)));
208 const uint32_t kHaystack[] = {0, 1, 2, 3, 4, 5};
209 const uint32_t kStartMatch[] = {0, 1};
210 const uint32_t kEndMatch[] = {4, 5};
211 const uint32_t kNotFound[] = {256, 512};
212 const uint32_t kTooLong[] = {0, 1, 2, 3, 4, 5, 6};
213 EXPECT_THAT(fxcrt::spanpos(pdfium::make_span(kHaystack),
214 pdfium::make_span(kStartMatch)),
215 testing::Optional(0u));
216 EXPECT_THAT(fxcrt::spanpos(pdfium::make_span(kHaystack),
217 pdfium::make_span(kEndMatch)),
218 testing::Optional(4u));
219 EXPECT_FALSE(
fxcrt::spanpos(
pdfium::make_span(kHaystack),
220 pdfium::make_span(kNotFound)));
221 EXPECT_FALSE(
fxcrt::spanpos(
pdfium::make_span(kHaystack),
222 pdfium::make_span(kTooLong)));