File: QueueMapTest_MemoryLeak.cpp

package info (click to toggle)
cryfs 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 28,412 kB
  • sloc: cpp: 150,187; asm: 10,493; python: 1,455; javascript: 65; sh: 50; makefile: 17; xml: 7
file content (87 lines) | stat: -rw-r--r-- 1,839 bytes parent folder | download | duplicates (6)
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
#include "testutils/QueueMapTest.h"

// Tests that QueueMap calls destructors correctly.
// This is needed, because QueueMap does its own memory management.
class QueueMapTest_MemoryLeak: public QueueMapTest {
public:
  void EXPECT_NUM_INSTANCES(int num) {
    EXPECT_EQ(num, MinimalKeyType::instances);
    EXPECT_EQ(num, MinimalValueType::instances);
  }
};

TEST_F(QueueMapTest_MemoryLeak, Empty) {
  EXPECT_NUM_INSTANCES(0);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingOne) {
  push(2, 3);
  EXPECT_NUM_INSTANCES(1);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingTwo) {
  push(2, 3);
  push(3, 4);
  EXPECT_NUM_INSTANCES(2);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingTwoAndPoppingOldest) {
  push(2, 3);
  push(3, 4);
  pop();
  EXPECT_NUM_INSTANCES(1);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingTwoAndPoppingFirst) {
  push(2, 3);
  push(3, 4);
  pop(2);
  EXPECT_NUM_INSTANCES(1);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingTwoAndPoppingLast) {
  push(2, 3);
  push(3, 4);
  pop(3);
  EXPECT_NUM_INSTANCES(1);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingOnePoppingOne) {
  push(2, 3);
  pop();
  EXPECT_NUM_INSTANCES(0);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingOnePoppingOnePerKey) {
  push(2, 3);
  pop(2);
  EXPECT_NUM_INSTANCES(0);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingOnePoppingOnePushingOne) {
  push(2, 3);
  pop();
  push(3, 4);
  EXPECT_NUM_INSTANCES(1);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingOnePoppingOnePerKeyPushingOne) {
  push(2, 3);
  pop(2);
  push(3, 4);
  EXPECT_NUM_INSTANCES(1);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingOnePoppingOnePushingSame) {
  push(2, 3);
  pop();
  push(2, 3);
  EXPECT_NUM_INSTANCES(1);
}

TEST_F(QueueMapTest_MemoryLeak, AfterPushingOnePoppingOnePerKeyPushingSame) {
  push(2, 3);
  pop(2);
  push(2, 3);
  EXPECT_NUM_INSTANCES(1);
}