2222
2323#include " gtest/gtest.h"
2424
25+ // Ensures that we don't waste any memory by having a vtable on Components; that is, tests that a Component has a size of 1 (the minimum)
26+ TEST (ComponentTypeTest, MinSizeComponents) {
27+ ASSERT_EQ (sizeof (ashley::Component), 1 );
28+ }
29+
2530// Ensures a valid type is returned when a call is made to the various getFor() functions, and that this type is the same in the various functions.
2631// Note that this covers both the validComponentType and sameComponentType tests in the Java version
2732TEST (ComponentTypeTest, ValidComponentTypes) {
2833 auto type1 = ashley::ComponentType::getFor (typeid (ashley::test::PositionComponent)); // std::type_info
29- auto type2 = ashley::ComponentType::getFor (
30- std::type_index (typeid (ashley::test::PositionComponent))); // std::type_index
34+ auto type2 = ashley::ComponentType::getFor (std::type_index (typeid (ashley::test::PositionComponent))); // std::type_index
3135 auto type3 = ashley::ComponentType::getFor<ashley::test::PositionComponent>(); // pass by template type
3236
3337 ASSERT_EQ (type1, type2);
@@ -37,8 +41,7 @@ TEST(ComponentTypeTest, ValidComponentTypes) {
3741// Ensures a valid and consistent index is returned when a call is made to the various getIndexFor() functions
3842TEST (ComponentTypeTest, ValidComponentIndexTypes) {
3943 auto id1 = ashley::ComponentType::getIndexFor (typeid (ashley::test::PositionComponent));
40- auto id2 = ashley::ComponentType::getIndexFor (
41- std::type_index (typeid (ashley::test::PositionComponent)));
44+ auto id2 = ashley::ComponentType::getIndexFor (std::type_index (typeid (ashley::test::PositionComponent)));
4245 auto id3 = ashley::ComponentType::getIndexFor<ashley::test::PositionComponent>();
4346
4447 ASSERT_EQ (id1, id2);
@@ -55,14 +58,12 @@ TEST(ComponentTypeTest, DifferentComponentType) {
5558}
5659
5760TEST (ComponentTypeTest, GetBitsFor) {
58- auto type1 = ashley::ComponentType::getBitsFor<ashley::test::PositionComponent,
59- ashley::test::VelocityComponent>();
61+ auto type1 = ashley::ComponentType::getBitsFor<ashley::test::PositionComponent, ashley::test::VelocityComponent>();
6062 auto type2 = ashley::ComponentType::getBitsFor ( { typeid (ashley::test::PositionComponent),
61- typeid (ashley::test::VelocityComponent) });
63+ typeid (ashley::test::VelocityComponent) });
6264
6365 auto type3 = ashley::ComponentType::getBitsFor ( { typeid (ashley::test::PositionComponent) });
64- auto type4 = ashley::ComponentType::getBitsFor (
65- { std::type_index (typeid (ashley::test::PositionComponent)) });
66+ auto type4 = ashley::ComponentType::getBitsFor ( { std::type_index (typeid (ashley::test::PositionComponent)) });
6667
6768 ASSERT_EQ (type1, type2);
6869 ASSERT_EQ (type3, type4);
0 commit comments