forked from chcg/PythonScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestDepthCounter.cpp
More file actions
94 lines (64 loc) · 2.12 KB
/
TestDepthCounter.cpp
File metadata and controls
94 lines (64 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "stdafx.h"
#include <gtest/gtest.h>
#include "DepthCounter.h"
namespace NppPythonScript
{
class DepthCounterTest : public ::testing::Test {
virtual void SetUp() {
}
};
TEST_F(DepthCounterTest, testInitialStateIsZero) {
DepthCounter depthCounter;
int depth = depthCounter.getDepth();
ASSERT_EQ(depth, 0);
}
TEST_F(DepthCounterTest, testIncreaseIncreasesDepth) {
DepthCounter depthCounter;
DepthLevel depthLevel = depthCounter.increase();
int depth = depthCounter.getDepth();
ASSERT_EQ(depth, 1);
}
TEST_F(DepthCounterTest, testDestructorReturnsDepthToZero) {
DepthCounter depthCounter;
int insideBlockDepth, outsideBlockDepth;
{
DepthLevel depthLevel = depthCounter.increase();
insideBlockDepth = depthCounter.getDepth();
} // call depthLevel destructors
outsideBlockDepth = depthCounter.getDepth();
EXPECT_EQ(insideBlockDepth, 1);
ASSERT_EQ(outsideBlockDepth, 0);
}
TEST_F(DepthCounterTest, testMultipleDepth) {
DepthCounter depthCounter;
int insideBlock1, insideBlock2;
int outsideBlock1, outsideBlock2;
{
DepthLevel depthLevel = depthCounter.increase();
insideBlock1 = depthCounter.getDepth();
{
DepthLevel depthLevel2 = depthCounter.increase();
insideBlock2 = depthCounter.getDepth();
}
outsideBlock2 = depthCounter.getDepth();
}
outsideBlock1 = depthCounter.getDepth();
EXPECT_EQ(insideBlock1, 1);
EXPECT_EQ(insideBlock2, 2);
EXPECT_EQ(outsideBlock2, 1);
EXPECT_EQ(outsideBlock1, 0);
}
TEST_F(DepthCounterTest, testAssignment) {
DepthCounter depthCounter;
int insideBlock, outsideBlock;
// As the DepthLevel is declared outside the block, we should have the same depth inside and outside the block.
DepthLevel depthLevel;
{
depthLevel = depthCounter.increase();
insideBlock = depthCounter.getDepth();
}
outsideBlock = depthCounter.getDepth();
ASSERT_EQ(insideBlock, 1);
ASSERT_EQ(outsideBlock, 1);
}
}