summaryrefslogtreecommitdiff
path: root/o3tl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-10-24 14:59:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-10-25 16:42:08 +0200
commita0032a2dc2e4ac7615baaacdde5fefa64048822e (patch)
tree67464978e1429652f66bae1668a9484226dce80c /o3tl
parent6ff4688b36bd6ff1273cfc20639df1b1cddd4bb2 (diff)
improve o3tl::enumarray const-ness
Change-Id: I7b0d10b024edf604a7dea0e3b1399073f4bcba92 Reviewed-on: https://gerrit.libreoffice.org/43773 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'o3tl')
-rw-r--r--o3tl/CppunitTest_o3tl_tests.mk1
-rw-r--r--o3tl/qa/test-enumarray.cxx48
2 files changed, 49 insertions, 0 deletions
diff --git a/o3tl/CppunitTest_o3tl_tests.mk b/o3tl/CppunitTest_o3tl_tests.mk
index 01a7cc0cbdc5..e8fd27095b06 100644
--- a/o3tl/CppunitTest_o3tl_tests.mk
+++ b/o3tl/CppunitTest_o3tl_tests.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,o3tl_tests,\
o3tl/qa/cow_wrapper_clients \
o3tl/qa/test-array_view \
o3tl/qa/test-cow_wrapper \
+ o3tl/qa/test-enumarray \
o3tl/qa/test-lru_map \
o3tl/qa/test-sorted_vector \
o3tl/qa/test-string_view \
diff --git a/o3tl/qa/test-enumarray.cxx b/o3tl/qa/test-enumarray.cxx
new file mode 100644
index 000000000000..9da8dae18f0b
--- /dev/null
+++ b/o3tl/qa/test-enumarray.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <stdexcept>
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <o3tl/enumarray.hxx>
+
+namespace {
+
+class Test: public CppUnit::TestFixture {
+private:
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(testOperations);
+ CPPUNIT_TEST_SUITE_END();
+
+
+ void testOperations() {
+ enum class MyEnum { ONE, TWO, THREE, LAST = THREE };
+ o3tl::enumarray<MyEnum, int> aModules;
+
+ aModules[MyEnum::ONE] = 1;
+ aModules[MyEnum::TWO] = 1;
+ aModules[MyEnum::THREE] = 1;
+
+ o3tl::enumarray<MyEnum, int> const & rModules = aModules;
+
+ for (auto const & i : rModules)
+ CPPUNIT_ASSERT_EQUAL( 1, i );
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */