Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : */
9 :
10 : #include "cppunit/TestAssert.h"
11 : #include "cppunit/TestFixture.h"
12 : #include "cppunit/extensions/HelperMacros.h"
13 :
14 : #include <o3tl/typed_flags_set.hxx>
15 :
16 : using namespace ::o3tl;
17 :
18 :
19 : enum class ConfigurationChangedHint { NONE, ONE, TWO };
20 :
21 : namespace o3tl
22 : {
23 : template<> struct typed_flags< ConfigurationChangedHint> : is_typed_flags< ConfigurationChangedHint, 0xFF> {};
24 : }
25 :
26 3 : class typed_flags_test : public CppUnit::TestFixture
27 : {
28 : public:
29 1 : void testBasics()
30 : {
31 1 : ConfigurationChangedHint nHint = ConfigurationChangedHint::ONE;
32 :
33 1 : CPPUNIT_ASSERT( ConfigurationChangedHint::ONE & ConfigurationChangedHint::ONE );
34 1 : CPPUNIT_ASSERT( nHint & ConfigurationChangedHint::ONE );
35 1 : CPPUNIT_ASSERT( ConfigurationChangedHint::ONE & nHint );
36 :
37 1 : CPPUNIT_ASSERT( ConfigurationChangedHint::ONE | ConfigurationChangedHint::ONE );
38 1 : CPPUNIT_ASSERT( nHint | ConfigurationChangedHint::ONE );
39 1 : CPPUNIT_ASSERT( ConfigurationChangedHint::ONE | nHint );
40 :
41 1 : CPPUNIT_ASSERT( ~nHint );
42 1 : CPPUNIT_ASSERT( ~ConfigurationChangedHint::ONE );
43 :
44 1 : nHint |= ConfigurationChangedHint::ONE;
45 1 : CPPUNIT_ASSERT( bool(nHint |= ConfigurationChangedHint::ONE) );
46 :
47 1 : nHint &= ConfigurationChangedHint::ONE;
48 1 : CPPUNIT_ASSERT( bool(nHint &= ConfigurationChangedHint::ONE) );
49 :
50 1 : }
51 :
52 : // Change the following lines only, if you add, remove or rename
53 : // member functions of the current class,
54 : // because these macros are need by auto register mechanism.
55 :
56 2 : CPPUNIT_TEST_SUITE(typed_flags_test);
57 1 : CPPUNIT_TEST(testBasics);
58 5 : CPPUNIT_TEST_SUITE_END();
59 : };
60 :
61 :
62 3 : CPPUNIT_TEST_SUITE_REGISTRATION(typed_flags_test);
63 :
64 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|