forked from vikshanker/sponge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfsm_stream_reassembler_seq.cc
75 lines (58 loc) · 1.97 KB
/
fsm_stream_reassembler_seq.cc
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
#include "byte_stream.hh"
#include "fsm_stream_reassembler_harness.hh"
#include "stream_reassembler.hh"
#include "util.hh"
#include <exception>
#include <iostream>
using namespace std;
int main() {
try {
{
ReassemblerTestHarness test{65000};
test.execute(SubmitSegment{"abcd", 0});
test.execute(BytesAssembled(4));
test.execute(BytesAvailable("abcd"));
test.execute(NotAtEof{});
test.execute(SubmitSegment{"efgh", 4});
test.execute(BytesAssembled(8));
test.execute(BytesAvailable("efgh"));
test.execute(NotAtEof{});
}
{
ReassemblerTestHarness test{65000};
test.execute(SubmitSegment{"abcd", 0});
test.execute(BytesAssembled(4));
test.execute(NotAtEof{});
test.execute(SubmitSegment{"efgh", 4});
test.execute(BytesAssembled(8));
test.execute(BytesAvailable("abcdefgh"));
test.execute(NotAtEof{});
}
{
ReassemblerTestHarness test{65000};
std::ostringstream ss;
for (size_t i = 0; i < 100; ++i) {
test.execute(BytesAssembled(4 * i));
test.execute(SubmitSegment{"abcd", 4 * i});
test.execute(NotAtEof{});
ss << "abcd";
}
test.execute(BytesAvailable(ss.str()));
test.execute(NotAtEof{});
}
{
ReassemblerTestHarness test{65000};
std::ostringstream ss;
for (size_t i = 0; i < 100; ++i) {
test.execute(BytesAssembled(4 * i));
test.execute(SubmitSegment{"abcd", 4 * i});
test.execute(NotAtEof{});
test.execute(BytesAvailable("abcd"));
}
}
} catch (const exception &e) {
cerr << "Exception: " << e.what() << endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}