nss: upgrade to release 3.73
[LibreOffice.git] / o3tl / qa / test-typed_flags.cxx
blobef6e4faaedceca169d3a7ae464baab87176f2119
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <cppunit/TestAssert.h>
11 #include <cppunit/TestFixture.h>
12 #include <cppunit/extensions/HelperMacros.h>
14 #include <o3tl/typed_flags_set.hxx>
16 using namespace ::o3tl;
18 namespace {
20 enum class ConfigurationChangedHint { NONE, ONE, TWO };
24 namespace o3tl
26 template<> struct typed_flags< ConfigurationChangedHint> : is_typed_flags< ConfigurationChangedHint, 0xFF> {};
29 class typed_flags_test : public CppUnit::TestFixture
31 public:
32 void testBasics()
34 ConfigurationChangedHint nHint = ConfigurationChangedHint::ONE;
36 CPPUNIT_ASSERT( ConfigurationChangedHint::ONE & ConfigurationChangedHint::ONE );
37 CPPUNIT_ASSERT( nHint & ConfigurationChangedHint::ONE );
38 CPPUNIT_ASSERT( ConfigurationChangedHint::ONE & nHint );
40 CPPUNIT_ASSERT( ConfigurationChangedHint::ONE | ConfigurationChangedHint::ONE );
41 CPPUNIT_ASSERT( nHint | ConfigurationChangedHint::ONE );
42 CPPUNIT_ASSERT( ConfigurationChangedHint::ONE | nHint );
44 CPPUNIT_ASSERT( ~nHint );
45 CPPUNIT_ASSERT( ~ConfigurationChangedHint::ONE );
47 nHint |= ConfigurationChangedHint::ONE;
48 CPPUNIT_ASSERT( bool(nHint |= ConfigurationChangedHint::ONE) );
50 nHint &= ConfigurationChangedHint::ONE;
51 CPPUNIT_ASSERT( bool(nHint &= ConfigurationChangedHint::ONE) );
53 CPPUNIT_ASSERT(
54 !((ConfigurationChangedHint::NONE | ConfigurationChangedHint::ONE)
55 & (ConfigurationChangedHint::NONE
56 | ConfigurationChangedHint::TWO)));
59 // Change the following lines only, if you add, remove or rename
60 // member functions of the current class,
61 // because these macros are need by auto register mechanism.
63 CPPUNIT_TEST_SUITE(typed_flags_test);
64 CPPUNIT_TEST(testBasics);
65 CPPUNIT_TEST_SUITE_END();
69 CPPUNIT_TEST_SUITE_REGISTRATION(typed_flags_test);
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */