fix formatting for (non-generated) internal source files

- Change formatting standard to Cpp11. Main difference is not having
  the space between two closing >> for nested templates. We don't
  choose c++14, because older versions of clang-format (version 9
  and earlier) don't know this value yet, and it doesn't make a
  difference in the formatting.
- Apply clang-format to all (non generated) internal source files.
- Manually fix some code sections (clang-format on/off) and c-strings
- Exclude some embedded external files with very different formatting
  (gtest/gmock)
- Add script to format all source files

Change-Id: Ic6cea41575ad6e37c9e136dbce176b0d505dc44d
This commit is contained in:
Nikolaus Demmel
2020-09-20 21:45:24 +02:00
parent 921368ce31
commit 7b8f675bfd
272 changed files with 3449 additions and 3319 deletions
+15 -23
View File
@@ -31,6 +31,7 @@
#include "ceres/reorder_program.h"
#include <random>
#include "ceres/parameter_block.h"
#include "ceres/problem_impl.h"
#include "ceres/program.h"
@@ -107,9 +108,7 @@ TEST(_, ReorderResidualBlockNormalFunction) {
std::string message;
EXPECT_TRUE(LexicographicallyOrderResidualBlocks(
2,
problem.mutable_program(),
&message));
2, problem.mutable_program(), &message));
EXPECT_EQ(residual_blocks.size(), expected_residual_blocks.size());
for (int i = 0; i < expected_residual_blocks.size(); ++i) {
EXPECT_EQ(residual_blocks[i], expected_residual_blocks[i]);
@@ -132,10 +131,8 @@ TEST(_, ApplyOrderingOrderingTooSmall) {
Program program(problem.program());
std::string message;
EXPECT_FALSE(ApplyOrdering(problem.parameter_map(),
linear_solver_ordering,
&program,
&message));
EXPECT_FALSE(ApplyOrdering(
problem.parameter_map(), linear_solver_ordering, &program, &message));
}
TEST(_, ApplyOrderingNormal) {
@@ -156,10 +153,8 @@ TEST(_, ApplyOrderingNormal) {
Program* program = problem.mutable_program();
std::string message;
EXPECT_TRUE(ApplyOrdering(problem.parameter_map(),
linear_solver_ordering,
program,
&message));
EXPECT_TRUE(ApplyOrdering(
problem.parameter_map(), linear_solver_ordering, program, &message));
const vector<ParameterBlock*>& parameter_blocks = program->parameter_blocks();
EXPECT_EQ(parameter_blocks.size(), 3);
@@ -169,8 +164,8 @@ TEST(_, ApplyOrderingNormal) {
}
#ifndef CERES_NO_SUITESPARSE
class ReorderProgramFoSparseCholeskyUsingSuiteSparseTest :
public ::testing::Test {
class ReorderProgramFoSparseCholeskyUsingSuiteSparseTest
: public ::testing::Test {
protected:
void SetUp() {
problem_.AddResidualBlock(new UnaryCostFunction(), nullptr, &x_);
@@ -188,12 +183,11 @@ class ReorderProgramFoSparseCholeskyUsingSuiteSparseTest :
program->parameter_blocks();
std::string error;
EXPECT_TRUE(ReorderProgramForSparseCholesky(
ceres::SUITE_SPARSE,
linear_solver_ordering,
0, /* use all rows */
program,
&error));
EXPECT_TRUE(ReorderProgramForSparseCholesky(ceres::SUITE_SPARSE,
linear_solver_ordering,
0, /* use all rows */
program,
&error));
const vector<ParameterBlock*>& ordered_parameter_blocks =
program->parameter_blocks();
EXPECT_EQ(ordered_parameter_blocks.size(),
@@ -219,8 +213,7 @@ TEST_F(ReorderProgramFoSparseCholeskyUsingSuiteSparseTest,
ComputeAndValidateOrdering(linear_solver_ordering);
}
TEST_F(ReorderProgramFoSparseCholeskyUsingSuiteSparseTest,
ContiguousGroups) {
TEST_F(ReorderProgramFoSparseCholeskyUsingSuiteSparseTest, ContiguousGroups) {
ParameterBlockOrdering linear_solver_ordering;
linear_solver_ordering.AddElementToGroup(&x_, 0);
linear_solver_ordering.AddElementToGroup(&y_, 1);
@@ -229,8 +222,7 @@ TEST_F(ReorderProgramFoSparseCholeskyUsingSuiteSparseTest,
ComputeAndValidateOrdering(linear_solver_ordering);
}
TEST_F(ReorderProgramFoSparseCholeskyUsingSuiteSparseTest,
GroupsWithGaps) {
TEST_F(ReorderProgramFoSparseCholeskyUsingSuiteSparseTest, GroupsWithGaps) {
ParameterBlockOrdering linear_solver_ordering;
linear_solver_ordering.AddElementToGroup(&x_, 0);
linear_solver_ordering.AddElementToGroup(&y_, 2);