indents(c): Refactor indent queries

This commit is contained in:
Pham Huy Hoang 2023-01-10 14:04:27 +09:00 committed by Stephan Seitz
parent 5ac2c92060
commit 2f5deed456
6 changed files with 179 additions and 15 deletions

60
tests/indent/c/if_else.c Normal file
View file

@ -0,0 +1,60 @@
int foo(int x){
if (x > 10)
return 10;
if (x > 10)
return 10;
else
return 10;
if (x > 20)
return 20;
else if (x > 15)
return 15;
else
return 10;
}
int bar(int x){
if (x > 20)
return 10;
else {
return 10;
}
if (x > 20)
return 10;
else if (x > 10) {
return 10;
}
}
int baz(int x){
if (x > 20)
return x;
else if(x > 10) {
if(x > 10) {
if(x > 10)
return 10;
if(x > 5) {
return 5;
}
}
}
if (x > 20)
if (x > 19)
if(x > 18)
return x;
if (x > 20)
return x;
else if (x > 19) {
if (x > 18)
return x;
else
x++;
}
else
return x;
}

View file

@ -0,0 +1,7 @@
int main(){
for(;;)
}
int foo(){
while(1)
}

View file

@ -0,0 +1,6 @@
int main(){
if(1){
}
else {
}
}

View file

@ -10,3 +10,4 @@ int foo(int x) {
for (int i = 0; i < 3; ++i)
x--;
}