cid#1608102 Double unlock
[libreoffice.git] / o3tl / qa / test-temporary.cxx
blob6f775de8473df1764fe398303c48abc88633c5f7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 <sal/config.h>
12 #include <cppunit/TestAssert.h>
13 #include <cppunit/TestFixture.h>
14 #include <cppunit/extensions/HelperMacros.h>
16 #include <o3tl/temporary.hxx>
18 namespace
20 void modify(int& n) { n = 1; }
22 class Test : public CppUnit::TestFixture
24 private:
25 CPPUNIT_TEST_SUITE(Test);
26 CPPUNIT_TEST(testLvalue);
27 CPPUNIT_TEST_SUITE_END();
29 void testLvalue()
32 int n = 0;
33 modify(n);
34 CPPUNIT_ASSERT_EQUAL(1, n);
37 int n = 0;
38 modify(o3tl::temporary(int(n)));
39 CPPUNIT_ASSERT_EQUAL(0, n);
44 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
47 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */