summaryrefslogtreecommitdiffstats
path: root/debian/uncrustify-trinity/uncrustify-trinity-0.73.0/tests/input/cpp/indent_shift.cpp
blob: 54684fa722d4aeef8b077c9df7ab86b87276b1c0 (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
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
// We want simple 4-space indentation for each nesting "level".

// cannot find a way to tell uncrustify to indent the line with parenthesis
int case2() {

    if (condition) {
        // some code here
    }

    std::out <<
       "hello " << "world " <<
     (who ? "and " : "or ") <<
			"all " <<
  "others" << ";" << std::endl;

    // and

    if (condition) {
        // some code here
    }

    std::out <<
       "hello " << "world " <<
     ("and ") <<
        "all " <<
      "others" << ";" << std::endl;

	if (cond)
			std::out << "hi";

if (cond)
std::out
<< "hi"
<< "and"
<< "more"
;

switch (var) {
		case 0:
log() << 5
<< 5;
		break;
}

#if 0
	out
	<< 5;
#endif

 return log
        >> var
        >> second
 ;
}


// uncrustify aligns (with the << on the first line) instead of indenting
void case3()
{

    if (condition1) {

        if (condition2) {

    std::out << "hello "
			<< "world "
      << (who ? "and " : "or ")
       << "all "
          << "others" << ";" << std::endl;

        }
    }

    // this often works better, but has problems with parentheses:

    if (condition1) {
        if (condition2) {
    std::out << "hello " <<
         "world " <<
     (who ? "and " : "or ") <<
    "all " <<
   "others" << ";" << std::endl;
		}
	}
}

// uncrustify does not indent >> at all!
void case4()
{
    if (condition) {
        // some code here
    }

    std::in >> a
		>> b
      >> (who ? c : d) >>
    >> e;

    // and

    if (condition1) {

        if (condition2) {
    std::in >> a >>
     b >>
       (who ? c : d) >>
   e;
		}
	}
}

void foo() {

	if (head())
		os << "HEAD,";
	else
	if (tail())
		os << "TAIL,";

	if (a >= 0 &&
		b <= 0)
			cerr << "it is";
}

int list[] = {
	1,
2,
	1 << 5,
	1 << 6
};

void check() {
	ostream &os = Comment(1) << "error: " << workerName <<
		" terminated by signal " << WTERMSIG(exitStatus);

	return theAddr.addrN().family() == AF_INET6 ?
		(theAddr.octet(idx * 2) << 8) + theAddr.octet(idx * 2 + 1) :
		theAddr.octet(idx);
}