-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRingTest.cpp
More file actions
85 lines (59 loc) · 1.02 KB
/
Copy pathRingTest.cpp
File metadata and controls
85 lines (59 loc) · 1.02 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
#include "Ring.h"
#include <exception>
#include <fstream>
#include <iostream>
#include <sstream>
using namespace std;
RingBuffer debugBuf;
#define log(...) debugBuf.addEntry(__func__, "(): ", __VA_ARGS__)
class Complicated
{
};
ostream& operator<<(ostream& out, const Complicated&)
{
out << "Complicated";
return out;
}
class UserCommand
{
};
ostream& operator<<(ostream& out, const UserCommand&)
{
out << "UserCommand";
return out;
}
UserCommand getNext(Complicated*)
{
UserCommand cmd;
return cmd;
}
void processCommand(UserCommand&)
{
}
void trickyFunction(Complicated* obj)
{
log("given argument: ", *obj);
for (size_t i = 0; i < 100; i++)
{
UserCommand cmd = getNext(obj);
log("retrieved cmd ", i, ": ", cmd);
try {
processCommand(cmd);
}
catch (const exception& e)
{
log("exception from proecessCommand", e.what());
}
}
}
int main(int argc, char* argv[])
{
for (int i = 1; i < argc; i++)
{
log(argv[i]);
}
Complicated obj;
trickyFunction(&obj);
cout << debugBuf;
return 0;
}