1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sal/config.h>
15 #include <cppunit/TestAssert.h>
16 #include <cppunit/TestFixture.h>
17 #include <cppunit/extensions/HelperMacros.h>
19 #include <o3tl/span.hxx>
23 class Test
: public CppUnit::TestFixture
{
25 CPPUNIT_TEST_SUITE(Test
);
26 CPPUNIT_TEST(testOperations
);
27 CPPUNIT_TEST_SUITE_END();
30 void testOperations() {
31 int const some_data
[] { 1, 2, 3 };
32 o3tl::span
<int const> v(some_data
);
34 CPPUNIT_ASSERT_EQUAL(1, *v
.begin());
36 o3tl::span
<int>::difference_type(3), v
.end() - v
.begin());
37 CPPUNIT_ASSERT_EQUAL(3, *v
.rbegin());
39 o3tl::span
<int>::difference_type(3), v
.rend() - v
.rbegin());
40 CPPUNIT_ASSERT_EQUAL(std::size_t(3), v
.size());
41 CPPUNIT_ASSERT(!v
.empty());
42 CPPUNIT_ASSERT_EQUAL(2, v
[1]);
43 CPPUNIT_ASSERT_EQUAL(1, *v
.data());
45 int const d1
[] { 1, 2 };
46 int const d2
[] { 3, 4, 5, 6 };
47 o3tl::span
<int const> v1( d1
);
48 o3tl::span
<int const> v2( d2
);
50 CPPUNIT_ASSERT_EQUAL(std::size_t(4), v1
.size());
51 CPPUNIT_ASSERT_EQUAL(std::size_t(2), v2
.size());
56 CPPUNIT_TEST_SUITE_REGISTRATION(Test
);
60 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */