blob: 534f490f6a92cd421f6e5e9a2b9c75b631312c94 (
plain)
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
|
/********************* -*- C++ -*- */
/** context_mm_black.h
** Original author: dejan
** This file is part of the CVC4 prototype.
** Copyright (c) 2009 The Analysis of Computer Systems Group (ACSys)
** Courant Institute of Mathematical Sciences
** New York University
** See the file COPYING in the top-level source directory for licensing
** information.
**
** Black box testing of CVC4::Node.
**/
#include <cxxtest/TestSuite.h>
#include <cstring>
//Used in some of the tests
#include <vector>
#include <iostream>
#include "context/context_mm.h"
using namespace std;
using namespace CVC4::context;
class ContextBlack : public CxxTest::TestSuite {
private:
ContextMemoryManager* d_cmm;
public:
void setUp() {
d_cmm = new ContextMemoryManager();
}
void testPushPop() {
// Push, then allocate, then pop
for (int p = 0; p < 5; ++ p) {
d_cmm->push();
for (int i = 1; i < 16384/3; ++i) {
int len = i*3;
char* newMem = (char*)d_cmm->newData(len);
for(int k = 0; k < len - 1; k ++)
newMem[k] = 'a';
newMem[len-1] = 0;
TS_ASSERT(strlen(newMem) == len - 1);
}
d_cmm->pop();
}
// Push, then allocate, then pop all at once
for (int p = 0; p < 5; ++ p) {
d_cmm->push();
for (int i = 1; i < 16384/3; ++i) {
int len = i*3;
char* newMem = (char*)d_cmm->newData(len);
for(int k = 0; k < len - 1; k ++)
newMem[k] = 'a';
newMem[len-1] = 0;
TS_ASSERT(strlen(newMem) == len - 1);
}
}
for (int p = 0; p < 5; ++ p) {
d_cmm->pop();
}
// Try poping out of scope
d_cmm->pop();
}
void tearDown() {
delete d_cmm;
}
};
|