1 // Copyright 2018 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "third_party/base/span.h"
7
8 // Tests PDFium-modifications to base::span. The name of this file is
9 // chosen to avoid collisions with base's span_unittest.cc
10
TEST(PdfiumSpan,EmptySpan)11 TEST(PdfiumSpan, EmptySpan) {
12 int stuff[] = {1, 2, 3};
13 pdfium::span<int> stuff_span(stuff);
14 pdfium::span<int> empty_first_span = stuff_span.first(0);
15 pdfium::span<int> empty_last_span = stuff_span.last(0);
16 pdfium::span<int> empty_sub_span1 = stuff_span.subspan(0, 0);
17 pdfium::span<int> empty_sub_span2 = stuff_span.subspan(3, 0);
18 EXPECT_TRUE(empty_first_span.empty());
19 EXPECT_TRUE(empty_last_span.empty());
20 EXPECT_TRUE(empty_sub_span1.empty());
21 EXPECT_TRUE(empty_sub_span2.empty());
22 }
23
TEST(PdfiumSpan,EmptySpanDeath)24 TEST(PdfiumSpan, EmptySpanDeath) {
25 int stuff[] = {1, 2, 3};
26 pdfium::span<int> stuff_span(stuff);
27 pdfium::span<int> empty_span = stuff_span.last(0);
28 EXPECT_DEATH(empty_span[0] += 1, ".*");
29 }
30