LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
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
13
QTEST_MAIN (
LC::Util::ScopeGuardTest
)
14
15
namespace
LC
16
{
17
namespace
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
{
36
DefaultScopeGuard
guard =
MakeScopeGuard
([&first] { first =
true
; });
37
guard =
MakeScopeGuard
([&second] { second =
true
; });
38
}
39
40
QCOMPARE (first,
true
);
41
QCOMPARE (second,
true
);
42
}
43
}
44
}
LC::Util::DefaultScopeGuard
detail::ScopeGuard< detail::DefaultScopeGuardDeleter > DefaultScopeGuard
Definition:
util.h:125
LC::Util::ScopeGuardTest
Definition:
scopeguardtest.h:29
scopeguardtest.h
LC::Util::MakeScopeGuard
detail::ScopeGuard< F > MakeScopeGuard(const F &f)
Returns an object performing passed function on scope exit.
Definition:
util.h:148
LC
Definition:
constants.h:14
src
util
sll
tests
scopeguardtest.cpp
Generated by
1.8.17