Skip to content

Commit

Permalink
run clang-format globally
Browse files Browse the repository at this point in the history
  • Loading branch information
bast committed Dec 29, 2017
1 parent 55902bd commit 1d28eb4
Show file tree
Hide file tree
Showing 32 changed files with 61 additions and 68 deletions.
4 changes: 2 additions & 2 deletions Chapter01/recipe-05/cxx-example/geometry_circle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
namespace geometry {
namespace area {
double circle(double radius) { return M_PI * std::pow(radius, 2); }
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-05/cxx-example/geometry_circle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double circle(double area);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-05/cxx-example/geometry_polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ double polygon(int nSides, double side) {
double apothem = side / (2.0 * std::tan(M_PI / nSides));
return (perimeter * apothem) / 2.0;
}
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-05/cxx-example/geometry_polygon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double polygon(int nSides, double side);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-05/cxx-example/geometry_rhombus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
namespace geometry {
namespace area {
double rhombus(double d1, double d2) { return (d1 * d2) / 2.0; }
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-05/cxx-example/geometry_rhombus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double rhombus(double d1, double d2);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-05/cxx-example/geometry_square.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace geometry {
namespace area {
double square(double l) { return std::pow(l, 2); }
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-05/cxx-example/geometry_square.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double square(double l);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-08/cxx-example/geometry_circle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
namespace geometry {
namespace area {
double circle(double radius) { return M_PI * std::pow(radius, 2); }
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-08/cxx-example/geometry_circle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double circle(double area);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-08/cxx-example/geometry_polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ double polygon(int nSides, double side) {
double apothem = side / (2.0 * std::tan(M_PI / nSides));
return (perimeter * apothem) / 2.0;
}
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-08/cxx-example/geometry_polygon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double polygon(int nSides, double side);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-08/cxx-example/geometry_rhombus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
namespace geometry {
namespace area {
double rhombus(double d1, double d2) { return (d1 * d2) / 2.0; }
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-08/cxx-example/geometry_rhombus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double rhombus(double d1, double d2);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-08/cxx-example/geometry_square.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace geometry {
namespace area {
double square(double l) { return std::pow(l, 2); }
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-08/cxx-example/geometry_square.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double square(double l);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-09/cxx-example/geometry_circle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
namespace geometry {
namespace area {
double circle(double radius) { return M_PI * std::pow(radius, 2); }
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-09/cxx-example/geometry_circle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double circle(double area);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-09/cxx-example/geometry_polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ double polygon(int nSides, double side) {
double apothem = side / (2.0 * std::tan(M_PI / nSides));
return (perimeter * apothem) / 2.0;
}
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-09/cxx-example/geometry_polygon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double polygon(int nSides, double side);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-09/cxx-example/geometry_rhombus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
namespace geometry {
namespace area {
double rhombus(double d1, double d2) { return (d1 * d2) / 2.0; }
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-09/cxx-example/geometry_rhombus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double rhombus(double d1, double d2);
}
}
} // namespace geometry
4 changes: 2 additions & 2 deletions Chapter01/recipe-09/cxx-example/geometry_square.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace geometry {
namespace area {
double square(double l) { return std::pow(l, 2); }
}
}
} // namespace area
} // namespace geometry
2 changes: 1 addition & 1 deletion Chapter01/recipe-09/cxx-example/geometry_square.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ namespace geometry {
namespace area {
double square(double l);
}
}
} // namespace geometry
3 changes: 2 additions & 1 deletion Chapter02/recipe-04/cxx-example/arch-dependent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ std::string say_hello() {
#elif IS_64_BIT_ARCH
return std::string("this code is compiled on a 64 bit host processor");
#else
return std::string("this code is compiled on a host processor with unknown architecture");
return std::string(
"this code is compiled on a host processor with unknown architecture");
#endif
}

Expand Down
7 changes: 4 additions & 3 deletions Chapter04/recipe-02/cxx-example/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

#include "sum_integers.h"

#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in
// one cpp file
#include "catch.hpp"

TEST_CASE("Sum of integers is computed", "[sum]") {
std::vector<int> integers = {1, 2, 3, 4, 5};
REQUIRE(sum_integers(integers) == 15);
std::vector<int> integers = {1, 2, 3, 4, 5};
REQUIRE(sum_integers(integers) == 15);
}
25 changes: 11 additions & 14 deletions Chapter04/recipe-03/cxx-example/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@
#include "sum_integers.h"
#include "gtest/gtest.h"

int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
int main(int argc, char ** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

TEST(example, sum_zero)
{
std::vector<int> integers = {1, -1, 2, -2, 3, -3};
int result = sum_integers(integers);
ASSERT_EQ(result, 0);
TEST(example, sum_zero) {
std::vector<int> integers = {1, -1, 2, -2, 3, -3};
int result = sum_integers(integers);
ASSERT_EQ(result, 0);
}

TEST(example, sum_five)
{
std::vector<int> integers = {1, 2, 3, 4, 5};
int result = sum_integers(integers);
ASSERT_EQ(result, 15);
TEST(example, sum_five) {
std::vector<int> integers = {1, 2, 3, 4, 5};
int result = sum_integers(integers);
ASSERT_EQ(result, 15);
}
9 changes: 4 additions & 5 deletions Chapter04/recipe-04/cxx-example/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
#define BOOST_TEST_MODULE example_test_suite
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(add_example)
{
std::vector<int> integers = {1, 2, 3, 4, 5};
int result = sum_integers(integers);
BOOST_REQUIRE(result == 15);
BOOST_AUTO_TEST_CASE(add_example) {
std::vector<int> integers = {1, 2, 3, 4, 5};
int result = sum_integers(integers);
BOOST_REQUIRE(result == 15);
}
2 changes: 1 addition & 1 deletion Chapter04/recipe-05/cxx-example/leaky_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
int do_some_work() {

// we allocate an array
double *my_array;
double * my_array;
my_array = new double[1000];

// do some work
Expand Down
4 changes: 1 addition & 3 deletions Chapter06/recipe-05/cxx-example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#include "version.h"

int main() {
std::cout << "This is output from example code v"
<< PROGRAM_VERSION
<< ":"
std::cout << "This is output from example code v" << PROGRAM_VERSION << ":"
<< std::endl;

std::cout << "Hello CMake world!" << std::endl;
Expand Down
3 changes: 1 addition & 2 deletions Chapter06/recipe-06/cxx-example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "version.h"

int main() {
std::cout << "This code has been configured from version "
<< GIT_HASH
std::cout << "This code has been configured from version " << GIT_HASH
<< std::endl;
}
4 changes: 1 addition & 3 deletions Chapter06/recipe-07/cxx-example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
#include "version.h"

int main() {
std::cout << "This code has been built from version "
<< GIT_HASH
<< std::endl;
std::cout << "This code has been built from version " << GIT_HASH << std::endl;
}

0 comments on commit 1d28eb4

Please sign in to comment.