Pārlūkot izejas kodu

Run clang-format because it got dropped from upgrading OS.

Sam Jaffe 6 gadi atpakaļ
vecāks
revīzija
5358d47506

+ 10 - 13
engine/test/entity_test.cxx

@@ -28,12 +28,10 @@ namespace math { namespace dim2 {
     return !(lhs == rhs);
   }
   bool operator==(quad const & lhs, quad const & rhs) {
-    return lhs.ll == rhs.ll && lhs.lr == rhs.lr && lhs.ul == rhs.ul
-        && lhs.ur == rhs.ur;
-  }
-  bool operator!=(quad const & lhs, quad const & rhs) {
-    return !(lhs == rhs);
+    return lhs.ll == rhs.ll && lhs.lr == rhs.lr && lhs.ul == rhs.ul &&
+           lhs.ur == rhs.ur;
   }
+  bool operator!=(quad const & lhs, quad const & rhs) { return !(lhs == rhs); }
 }}
 
 inline Json::Value to_json(std::string const & str) {
@@ -45,7 +43,7 @@ inline Json::Value to_json(std::string const & str) {
 TEST(CollidableTest, ConstructsUsingGraphics) {
   math::dim2::rectangle bounds{make_vector(0.f, 0.f), make_vector(1.f, 1.f)};
   graphics::object obj{bounds, bounds, cast<graphics::material>(1), bounds};
-  
+
   collidable collide{obj};
   EXPECT_THAT(collide.render_info().location, Eq(obj.location));
 }
@@ -60,16 +58,15 @@ std::string const data = R"(
 TEST(EntityTest, ConstructsFromJson) {
   math::dim2::rectangle bounds{make_vector(0.f, 0.f), make_vector(1.f, 1.f)};
   graphics::object obj{bounds, bounds, cast<graphics::material>(1), bounds};
-  
+
   entity ent{to_json(data), obj};
   EXPECT_THAT(ent.render_info().location, Eq(obj.location));
 }
 
-
 TEST(EntityTest, SizeParamAltersLocation) {
   math::dim2::rectangle bounds{make_vector(0.f, 0.f), make_vector(1.f, 1.f)};
   graphics::object obj{bounds, bounds, cast<graphics::material>(1), bounds};
-  
+
   Json::Value json = to_json(data);
   json["size"] = 2.f;
   entity ent{json, obj};
@@ -81,10 +78,10 @@ TEST(EntityTest, SizeParamAltersLocation) {
 TEST(EntityTest, MoveWillAdjustPointsAndBounds) {
   math::dim2::rectangle bounds{make_vector(0.f, 0.f), make_vector(1.f, 1.f)};
   graphics::object obj{bounds, bounds, cast<graphics::material>(1), bounds};
-  
+
   entity ent{to_json(data), obj};
   ent.update(1.f);
-  
+
   math::dim2::rectangle expected{make_vector(1.f, 2.f), make_vector(1.f, 1.f)};
   EXPECT_THAT(ent.render_info().location, Eq(expected));
   EXPECT_THAT(ent.render_info().points, Eq(math::dim2::quad(expected)));
@@ -93,10 +90,10 @@ TEST(EntityTest, MoveWillAdjustPointsAndBounds) {
 TEST(EntityTest, MoveIsAFunctionOfVelocity) {
   math::dim2::rectangle bounds{make_vector(0.f, 0.f), make_vector(1.f, 1.f)};
   graphics::object obj{bounds, bounds, cast<graphics::material>(1), bounds};
-  
+
   entity ent{to_json(data), obj};
   ent.update(0.5f);
-  
+
   math::dim2::rectangle expected{make_vector(0.5f, 1.f), make_vector(1.f, 1.f)};
   EXPECT_THAT(ent.render_info().location, Eq(expected));
   EXPECT_THAT(ent.render_info().points, Eq(math::dim2::quad(expected)));

+ 3 - 4
engine/test/game_dispatch_test.cxx

@@ -21,9 +21,8 @@
 struct mock_scene : engine::scene {
   mock_scene(std::shared_ptr<engine::game_dispatch> game)
       : engine::scene("mock", make_vector(0.f, 0.f), game) {}
-  mock_scene(std::shared_ptr<engine::game_dispatch> game,
-             math::vec2 dim)
-  : engine::scene("mock2", dim, game) {}
+  mock_scene(std::shared_ptr<engine::game_dispatch> game, math::vec2 dim)
+      : engine::scene("mock2", dim, game) {}
   MOCK_METHOD1(update, void(float));
   MOCK_METHOD0(render, void());
   MOCK_METHOD1(handle_key_event, void(engine::event::key_event));
@@ -59,6 +58,7 @@ void GameDispatchTest::TearDown() {
   renderer_.reset();
 }
 
+using testing::_;
 using testing::AnyNumber;
 using testing::Eq;
 using testing::Field;
@@ -66,7 +66,6 @@ using testing::FloatNear;
 using testing::Ge;
 using testing::Lt;
 using testing::Not;
-using testing::_;
 
 TEST_F(GameDispatchTest, ManagerIsFetchedFromRenderer) {
   EXPECT_THAT(&game().graphics_manager(), Eq(renderer_->manager().get()));

+ 22 - 16
engine/test/scene_test.cxx

@@ -25,9 +25,15 @@ struct test_scene : engine::scene {
   void render() override {}
   void handle_key_event(engine::event::key_event) override {}
   void handle_mouse_event(engine::event::mouse_event) override {}
-  bool in_bounds(math::dim2::point c) const { return engine::scene::in_bounds(c); }
-  bool in_bounds(engine::collidable * c) const { return engine::scene::in_bounds(c); }
-  graphics::manager const & graphics_manager() const { return engine::scene::graphics_manager(); }
+  bool in_bounds(math::dim2::point c) const {
+    return engine::scene::in_bounds(c);
+  }
+  bool in_bounds(engine::collidable * c) const {
+    return engine::scene::in_bounds(c);
+  }
+  graphics::manager const & graphics_manager() const {
+    return engine::scene::graphics_manager();
+  }
 
   void add_with(engine::collision_t t, engine::collidable & c) {
     colliders[t].push_back(&c);
@@ -166,34 +172,34 @@ struct BoundsTest : SceneTest, testing::WithParamInterface<math::vec2> {};
 TEST_F(BoundsTest, BoundsCheckIsPointInScreenZone) {
   // Confirm that the size is as expected...
   EXPECT_THAT(scene().size(), Eq(make_vector(1600.f, 900.f)));
-  
+
   // Lower-Left Corner
-  EXPECT_FALSE(scene().in_bounds(make_vector(  -1.f,   0.f)));
-  EXPECT_FALSE(scene().in_bounds(make_vector(   0.f,  -1.f)));
+  EXPECT_FALSE(scene().in_bounds(make_vector(-1.f, 0.f)));
+  EXPECT_FALSE(scene().in_bounds(make_vector(0.f, -1.f)));
   EXPECT_TRUE(scene().in_bounds(make_vector(0.f, 0.f)));
   // Lower-Right Corner
-  EXPECT_FALSE(scene().in_bounds(make_vector(1600.f,  -1.f)));
-  EXPECT_FALSE(scene().in_bounds(make_vector(1601.f,   0.f)));
-  EXPECT_TRUE(scene().in_bounds(make_vector(1600.f,   0.f)));
+  EXPECT_FALSE(scene().in_bounds(make_vector(1600.f, -1.f)));
+  EXPECT_FALSE(scene().in_bounds(make_vector(1601.f, 0.f)));
+  EXPECT_TRUE(scene().in_bounds(make_vector(1600.f, 0.f)));
   // Upper-Right Corner
   EXPECT_FALSE(scene().in_bounds(make_vector(1601.f, 900.f)));
   EXPECT_FALSE(scene().in_bounds(make_vector(1600.f, 901.f)));
   EXPECT_TRUE(scene().in_bounds(make_vector(1600.f, 900.f)));
   // Upper-Left Corner
-  EXPECT_FALSE(scene().in_bounds(make_vector(   0.f, 901.f)));
-  EXPECT_FALSE(scene().in_bounds(make_vector(  -1.f, 900.f)));
-  EXPECT_TRUE(scene().in_bounds(make_vector(   0.f, 900.f)));
+  EXPECT_FALSE(scene().in_bounds(make_vector(0.f, 901.f)));
+  EXPECT_FALSE(scene().in_bounds(make_vector(-1.f, 900.f)));
+  EXPECT_TRUE(scene().in_bounds(make_vector(0.f, 900.f)));
 }
 
 TEST_P(BoundsTest, BoundsCheckOnCollidableIsAnyPointInBounds) {
   math::dim2::square bounds = {GetParam(), 2.f};
   engine::collidable collide{{{}, bounds, cast<graphics::material>(1), {}}};
-  
+
   EXPECT_TRUE(scene().in_bounds(&collide));
 }
 
 INSTANTIATE_TEST_CASE_P(Collidable, BoundsTest,
-                        ::testing::Values(make_vector(  -1.f,  -1.f),
-                                          make_vector(1599.f,  -1.f),
+                        ::testing::Values(make_vector(-1.f, -1.f),
+                                          make_vector(1599.f, -1.f),
                                           make_vector(1599.f, 899.f),
-                                          make_vector(  -1.f, 899.f)));
+                                          make_vector(-1.f, 899.f)));

+ 1 - 1
graphics/test/manager_test.cxx

@@ -21,6 +21,7 @@ namespace env { namespace detail {
 }}
 #endif
 
+using testing::_;
 using testing::AllOf;
 using testing::AnyNumber;
 using testing::Eq;
@@ -28,7 +29,6 @@ using testing::Ge;
 using testing::Le;
 using testing::Ne;
 using testing::SizeIs;
-using testing::_;
 
 struct mock_manager_impl : graphics::manager {
   using shader = graphics::shader;

+ 1 - 1
graphics/test/renderer_test.cxx

@@ -15,10 +15,10 @@
 #include "game/math/shape.hpp"
 #include "matrix/matrix.hpp"
 
+using testing::_;
 using testing::AnyNumber;
 using testing::IsEmpty;
 using testing::SizeIs;
-using testing::_;
 
 struct mock_renderer_impl : graphics::renderer_impl {
   MOCK_CONST_METHOD0(manager, std::shared_ptr<graphics::manager const>());

+ 1 - 1
math/src/common.cpp

@@ -129,7 +129,7 @@ namespace math {
 
   // TODO (sjaffe): This does not cause intersection when the edges brush
   //                against one another, is this good?
- bool intersects(dim2::quad const & lhs, dim2::quad const & rhs) {
+  bool intersects(dim2::quad const & lhs, dim2::quad const & rhs) {
     dim2::triangle l1{lhs.ll, lhs.lr, lhs.ul};
     dim2::triangle l2{lhs.ul, lhs.ur, lhs.ll};
     dim2::triangle r1{rhs.ll, rhs.lr, rhs.ul};

+ 4 - 6
math/test/common_test.cxx

@@ -254,9 +254,7 @@ TEST(TriangleTest, TriangleIntersectsSelf) {
 
 TEST(TriangleTest, DoesNotIntersectOffset) {
   triangle lhs{{{0, 0}}, {{0, 1}}, {{1, 0}}};
-  auto tri = [](math::dim2::point const & pt) {
-    return triangle{pt, pt, pt};
-  };
+  auto tri = [](math::dim2::point const & pt) { return triangle{pt, pt, pt}; };
   math::dim2::point const clock_ab{{1, 1}};
   math::dim2::point const clock_bc{{-1, -1}};
   math::dim2::point const clock_ca{{-1, 2}};
@@ -285,19 +283,19 @@ TEST(QuadTest, IntersectsContain) {
 
 TEST(QuadTest, NoIntersectionAtEdge) {
   quad const lhs = square{{{-0.5f, -0.5f}}, 1};
-  quad const rhs = square{{{ 0.0f,  0.5f}}, 1};
+  quad const rhs = square{{{0.0f, 0.5f}}, 1};
   EXPECT_FALSE(math::intersects(lhs, rhs));
 }
 
 TEST(QuadTest, NoIntersectionAtCorner) {
   quad const lhs = square{{{-0.5f, -0.5f}}, 1};
-  quad const rhs = square{{{ 0.5f,  0.5f}}, 1};
+  quad const rhs = square{{{0.5f, 0.5f}}, 1};
   EXPECT_FALSE(math::intersects(lhs, rhs));
 }
 
 TEST(QuadTest, NoIntersection) {
   quad const lhs = square{{{-1.0f, -0.5f}}, 1};
-  quad const rhs = square{{{ 0.5f,  0.5f}}, 1};
+  quad const rhs = square{{{0.5f, 0.5f}}, 1};
   EXPECT_FALSE(math::intersects(lhs, rhs));
 }
 

+ 0 - 1
math/test/shape_test.cxx

@@ -49,7 +49,6 @@ TEST(LineTest, UnitLineHasLengthOne) {
   EXPECT_THAT(unit.length(), Eq(1));
 }
 
-
 TEST(LineTest, ParallelLinesHaveSameSlope) {
   line const lhs{{{0, 0}}, {{1, 0}}};
   line const rhs{{{-1, 0}}, {{-2, 0}}};