openMSX
unittest
ScopedAssign_test.cc
Go to the documentation of this file.
1
#include "catch.hpp"
2
#include "
ScopedAssign.hh
"
3
4
TEST_CASE
(
"ScopedAssign, local"
)
5
{
6
int
l = 1;
7
CHECK
(l == 1);
8
{
9
ScopedAssign
sa1(l, 2);
10
CHECK
(l == 2);
11
{
12
ScopedAssign
sa2(l, 3);
13
CHECK
(l == 3);
14
}
15
CHECK
(l == 2);
16
}
17
CHECK
(l == 1);
18
}
19
20
int
g
;
21
static
void
testAssign()
22
{
23
CHECK
(
g
== 2);
24
ScopedAssign
sa(
g
, 3);
25
CHECK
(
g
== 3);
26
}
27
TEST_CASE
(
"ScopedAssign, global"
)
28
{
29
g
= 1;
30
CHECK
(
g
== 1);
31
{
32
ScopedAssign
sa(
g
, 2);
33
CHECK
(
g
== 2);
34
testAssign();
35
CHECK
(
g
== 2);
36
}
37
CHECK
(
g
== 1);
38
}
ScopedAssign.hh
TEST_CASE
TEST_CASE("ScopedAssign, local")
Definition
ScopedAssign_test.cc:4
g
int g
Definition
ScopedAssign_test.cc:20
ScopedAssign
Assign new value to some variable and restore the original value when this object goes out of scope.
Definition
ScopedAssign.hh:8
CHECK
CHECK(m3==m3)
Generated on Wed Nov 6 2024 21:13:39 for openMSX by
1.9.8