-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
176 lines (150 loc) · 5.44 KB
/
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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#include <iostream>
// IndentPPDirectives
#ifdef WIN32
#include <windows.h>
#endif
// SortIncludes
#include "AnotherHeader.h"
#include "MyHeader.h"
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/signal_set.hpp>
#include <boost/asio/write.hpp>
#include <map>
#include <string>
#include <vector>
// AlignConsecutiveMacros
#define SHORT_NAME 42
#define LONGER_NAME 0x007f
#define EVEN_LONGER_NAME (2)
#define fooo(x) (x * x)
#define baar(y, z) (y + z)
// AlignEscapedNewlines
#define PPP \
int aaaa; \
int b; \
int dddddddddd;
namespace LevelOneNamespace {
namespace LevelTwoNamespace {
struct AAAAAAAAAAAAAAAAAAAA {
// AlignConsecutiveDeclarations
int a;
int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
std::string cccccccccccccccccc;
};
// AlwaysBreakTemplateDeclarations
template <typename T> T foo() {}
template <typename T> T foo(int aaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbbbbbbbbbb) {}
// AllowShortEnumsOnASingleLine
enum : unsigned int { AA = 0, BB } myEnum;
// SpaceBeforeInheritanceColon
class B : public E {
private:
// AlignArrayOfStructures
struct AAAAAAAAAAAAAAAAAAAA test[3] = {{56, 23, "hello"}, {-1, 93463, "world"}, {7, 5, "!!"}};
// AlignTrailingComments, AlignConsecutiveDeclarations, QualifierOrder,
// QualifierAlignment, AlignTrailingComments
static char const *variable; // very important variable
void *const *x = nullptr; // not so important variable
char const *anotherVariable; // another comment
int a = 1; // another variable
// used for this, this, and that
int longComplicatedName = 4;
int b = 3;
protected:
// AlwaysBreakAfterReturnType, QualifierAlignment
constexpr static inline int function(int a, int b) { return (a + b) / 2; }
// AllowShortFunctionsOnASingleLine
static bool shortFilter(AAAAAAAAAAAAAAAAAAAA v) { return v.a != 4; }
void empty() {}
// IndentWrappedFunctionNames
std::map<std::basic_string<wchar_t>, std::vector<std::pair<char, int>>>
func(AAAAAAAAAAAAAAAAAAAA *v);
public:
// SpaceBeforeCtorInitializerColon
explicit B() : a(9){};
// PackConstructorInitializers
explicit B(int _a, int _b, int _c, std::vector<std::string> str)
: a(_a), b(_b), longComplicatedName(_c), anotherVariable(str[0].c_str()) {
// AllowShortIfStatementsOnASingleLine, SpaceBeforeParens
if (_c)
anotherVariable = nullptr;
if (_a)
anotherVariable = "baz";
else
anotherVariable = "bar";
}
// AllowAllParametersOfDeclarationOnNextLine BinPackParameters
int myFunction(int aaaaaaaaaaaaa, int bbbbbbbbbbbbbbbbbbbbbbb, int ccccccccccccc, int d, int e) {
int myvar = aaaaaaaaaaaaa / 10;
long anothervaw = d % 2;
// comment
char *msg = "Hello all";
// AlignOperands
myvar = bbbbbbbbbbbbbbbbbbbbbbb + ccccccccccccc + aaaaaaaaaaaaa;
// AllowShortCaseLabelsOnASingleLine, SpaceBeforeParens
switch (e) {
case 1:
return e;
case 2:
return 2;
};
// AllowShortBlocksOnASingleLine, SpaceBeforeParens
while (true) {
}
while (true) {
continue;
}
}
// AlignAfterOpenBracket, BinPackParameters,
void loooonFunctionIsVeryLongButNotAsLongAsJavaTypeNames(
std::vector<AAAAAAAAAAAAAAAAAAAA> const &inputVector, std::map<int, std::string> *outputMap) {
std::vector<AAAAAAAAAAAAAAAAAAAA> bar;
std::copy_if(inputVector.begin(), inputVector.end(), std::back_inserter(bar), &shortFilter);
// AllowShortLambdasOnASingleLine
std::sort(inputVector.begin(), inputVector.end(), [](auto v) { return v.a < v.b; });
std::transform(inputVector.begin(),
inputVector.end(),
std::inserter(*outputMap, outputMap->end()),
[](const AAAAAAAAAAAAAAAAAAAA &element) {
// LambdaBodyIndentation
return std::make_pair(element.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
element.cccccccccccccccccc);
});
};
int notInline(AAAAAAAAAAAAAAAAAAAA *v);
};
// AllowShortFunctionsOnASingleLine
int notInline(AAAAAAAAAAAAAAAAAAAA *v) { return v->a + 1; }
} // namespace LevelTwoNamespace
} // namespace LevelOneNamespace
int main() {
// ReflowComments
// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
// information
/* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty
* of information */
// SortUsingDeclarations
using std::cin;
using std::cout;
int aaaaaaaaaaaaaaaaaaa, bbbbbbbbbbb, ppppppppppp, eeeee;
// AlignConsecutiveAssignments
aaaaaaaaaaaaaaaaaaa = 6;
bbbbbbbbbbb = 5;
ppppppppppp = 10;
LevelOneNamespace::LevelTwoNamespace::B b{
1,
3,
4,
// SpaceBeforeCpp11BracedList
std::vector<std::string>{
"aaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbb", "cccccccccccccccccccccccccccc"}};
// AllowShortLoopsOnASingleLine
for (int i = 0; i < 10; i++)
cout << i;
LevelOneNamespace::LevelTwoNamespace::AAAAAAAAAAAAAAAAAAAA ddddddddddddddddddddddddd{5, 5, "ff"};
b.notInline(ddddddddddddddddddddddddd);
// SpaceAfterCStyleCast, AllowAllArgumentsOnNextLine
cout << (bool)b.myFunction(aaaaaaaaaaaaaaaaaaa, bbbbbbbbbbb, ppppppppppp, eeeee, 0);
return 0;
}