summaryrefslogtreecommitdiff
path: root/o3tl
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-10-14 10:36:45 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-10-14 13:01:43 +0200
commit2cd1128555cec70b6ba3d977f6a156b2be1659ad (patch)
tree453961214140b6ab78e856f702e338aa9487ecef /o3tl
parenta1a83ceb8bd2723be49f8282e887da24f4a421f2 (diff)
fixes and tests for o3tl::typed_flags
create test suite for typed_flags template. fix the operator&= and operator|= definitions Signed-off-by: Stephan Bergmann <sbergman@redhat.com> Conflicts: include/o3tl/typed_flags_set.hxx Change-Id: I1df9ae197889af98a2fd76ff2bc07756c7b14ced
Diffstat (limited to 'o3tl')
-rw-r--r--o3tl/CppunitTest_o3tl_tests.mk1
-rw-r--r--o3tl/qa/test-typed_flags.cxx63
2 files changed, 64 insertions, 0 deletions
diff --git a/o3tl/CppunitTest_o3tl_tests.mk b/o3tl/CppunitTest_o3tl_tests.mk
index a4d6d715853c..66f2951bf4f6 100644
--- a/o3tl/CppunitTest_o3tl_tests.mk
+++ b/o3tl/CppunitTest_o3tl_tests.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,o3tl_tests,\
o3tl/qa/test-range \
o3tl/qa/test-vector_pool \
o3tl/qa/test-sorted_vector \
+ o3tl/qa/test-typed_flags \
))
# vim: set noet sw=4:
diff --git a/o3tl/qa/test-typed_flags.cxx b/o3tl/qa/test-typed_flags.cxx
new file mode 100644
index 000000000000..de6e080eddd0
--- /dev/null
+++ b/o3tl/qa/test-typed_flags.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+
+#include <o3tl/typed_flags_set.hxx>
+
+using namespace ::o3tl;
+
+
+enum class ConfigurationChangedHint { NONE, ONE, TWO };
+
+namespace o3tl
+{
+ template<> struct typed_flags< ConfigurationChangedHint> : is_typed_flags< ConfigurationChangedHint, 0xFF> {};
+}
+
+class typed_flags_test : public CppUnit::TestFixture
+{
+public:
+ void testBasics()
+ {
+ ConfigurationChangedHint nHint = ConfigurationChangedHint::ONE;
+
+ CPPUNIT_ASSERT( ConfigurationChangedHint::ONE & ConfigurationChangedHint::ONE );
+ CPPUNIT_ASSERT( nHint & ConfigurationChangedHint::ONE );
+ CPPUNIT_ASSERT( ConfigurationChangedHint::ONE & nHint );
+
+ CPPUNIT_ASSERT( ConfigurationChangedHint::ONE | ConfigurationChangedHint::ONE );
+ CPPUNIT_ASSERT( nHint | ConfigurationChangedHint::ONE );
+ CPPUNIT_ASSERT( ConfigurationChangedHint::ONE | nHint );
+
+ CPPUNIT_ASSERT( ~nHint );
+ CPPUNIT_ASSERT( ~ConfigurationChangedHint::ONE );
+
+ nHint |= ConfigurationChangedHint::ONE;
+ CPPUNIT_ASSERT( nHint |= ConfigurationChangedHint::ONE );
+
+ nHint &= ConfigurationChangedHint::ONE;
+ CPPUNIT_ASSERT( nHint &= ConfigurationChangedHint::ONE );
+ }
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE(typed_flags_test);
+ CPPUNIT_TEST(testBasics);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION(typed_flags_test);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */