summaryrefslogtreecommitdiff
path: root/main/tests/test_astar.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-10 12:56:01 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-10 13:12:16 +0200
commite956e80c1fa1cc8aefcb1533e5acf5cf3c8ffdd9 (patch)
tree8f162f9162ca0dfa35841a9c734a0529764cb458 /main/tests/test_astar.cpp
parent03b13e0c695bb63043c3ca8665083bae1960aca4 (diff)
Style: clang-format: Disable AllowShortIfStatementsOnASingleLine
Part of #33027, also discussed in #29848. Enforcing the use of brackets even on single line statements would be preferred, but `clang-format` doesn't have this functionality yet.
Diffstat (limited to 'main/tests/test_astar.cpp')
-rw-r--r--main/tests/test_astar.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/main/tests/test_astar.cpp b/main/tests/test_astar.cpp
index e0b4a7f2c8..66f9aa8ad6 100644
--- a/main/tests/test_astar.cpp
+++ b/main/tests/test_astar.cpp
@@ -173,7 +173,8 @@ bool test_add_remove() {
for (int i = 0; i < 20000; i++) {
int u = Math::rand() % 5;
int v = Math::rand() % 4;
- if (u == v) v = 4;
+ if (u == v)
+ v = 4;
if (Math::rand() % 2 == 1) {
// Add a (possibly existing) directed edge and confirm connectivity
a.connect_points(u, v, false);
@@ -195,7 +196,8 @@ bool test_add_remove() {
for (int j = 0; j < 10; j++) {
int u = Math::rand() % 5;
int v = Math::rand() % 4;
- if (u == v) v = 4;
+ if (u == v)
+ v = 4;
if (Math::rand() % 2 == 1)
a.connect_points(u, v, false);
else
@@ -239,7 +241,8 @@ bool test_solutions() {
int u, v;
u = Math::rand() % N;
v = Math::rand() % (N - 1);
- if (u == v) v = N - 1;
+ if (u == v)
+ v = N - 1;
// Pick a random operation
int op = Math::rand();
@@ -253,14 +256,16 @@ bool test_solutions() {
// Add edge (u, v); possibly bidirectional
a.connect_points(u, v, op % 2);
adj[u][v] = true;
- if (op % 2) adj[v][u] = true;
+ if (op % 2)
+ adj[v][u] = true;
break;
case 6:
case 7:
// Remove edge (u, v); possibly bidirectional
a.disconnect_points(u, v, op % 2);
adj[u][v] = false;
- if (op % 2) adj[v][u] = false;
+ if (op % 2)
+ adj[v][u] = false;
break;
case 8:
// Remove point u and add it back; clears adjacent edges and changes coordinates
@@ -291,12 +296,14 @@ bool test_solutions() {
int count = 0;
for (int u = 0; u < N; u++)
for (int v = 0; v < N; v++)
- if (adj[u][v]) count++;
+ if (adj[u][v])
+ count++;
printf("Test #%4d: %3d edges, ", test + 1, count);
count = 0;
for (int u = 0; u < N; u++)
for (int v = 0; v < N; v++)
- if (!Math::is_inf(d[u][v])) count++;
+ if (!Math::is_inf(d[u][v]))
+ count++;
printf("%3d/%d pairs of reachable points\n", count - N, N * (N - 1));
// Check A*'s output
@@ -339,7 +346,8 @@ bool test_solutions() {
}
exit:
- if (!match) return false;
+ if (!match)
+ return false;
}
return true;
}