-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
41 lines (31 loc) · 805 Bytes
/
test.cpp
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
#include "RemoteBuf.h"
#include <string.h>
#include <iostream>
#undef NDEBUG
#include <cassert>
using namespace RemoteBuf;
int main(int argc, char *argv[]) {
BufferManager BM;
Buffer *B = BM.createBuffer("hi");
assert(BM.bufferExists("hi"));
char buf[] = "hello";
B->write(buf, strlen(buf));
B->flush();
B = BM.getBuffer("hi");
char *buf2 = new char[B->getSize()];
B->read(buf2);
std::cout << "read: " << buf2 << "\n";
if (memcmp("hellohello", buf2, B->getSize()) != 0) {
std::cout << "strings not equal\n";
return 1;
}
delete[] buf2;
Buffer *B2 = BM.createBuffer("hi2");
assert(BM.bufferExists("hi2"));
B2->write(buf, strlen(buf));
B2->flush();
BM.deleteBuffer("hi2");
assert(!BM.bufferExists("hi2"));
std::cout << "test passed\n";
return 0;
}