LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
scopeguardtest.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "scopeguardtest.h"
10#include <QtTest>
11#include "util.h"
12
13QTEST_MAIN (LC::Util::ScopeGuardTest)
14
15namespace LC
16{
17namespace Util
18{
19 void ScopeGuardTest::testBasicGuard ()
20 {
21 bool triggered = false;
22
23 {
24 const auto guard = MakeScopeGuard ([&triggered] { triggered = true; });
25 }
26
27 QCOMPARE (triggered, true);
28 }
29
30 void ScopeGuardTest::testAssignmentGuard ()
31 {
32 bool first = false;
33 bool second = false;
34
35 {
37 guard = MakeScopeGuard ([&second] { second = true; });
38 }
39
40 QCOMPARE (first, true);
41 QCOMPARE (second, true);
42 }
43}
44}
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118
detail::ScopeGuard< F > MakeScopeGuard(const F &f)
Returns an object performing passed function on scope exit.
Definition util.h:155
detail::ScopeGuard< detail::DefaultScopeGuardDeleter > DefaultScopeGuard
Definition util.h:132
Definition constants.h:15