void Body_colliding_shouldWorkWithDisjointRectsE(CuTest* tc) { Body* b1 = Body_newRectangle(2, 2); Body* b2 = Body_newRectangle(2, 2); Body_setPosition(b1, 2, 2); Body_setPosition(b2, 4, 2); CuAssertTrue(tc, !Body_colliding(b1, b2)); Body_delete(b1); Body_delete(b2); }
void Body_colliding_shouldWorkWithJointRectsW(CuTest* tc) { Body* b1 = Body_newRectangle(4, 4); Body* b2 = Body_newRectangle(2, 2); Body_setPosition(b1, 1, 1); Body_setPosition(b2, 0, 2); CuAssertTrue(tc, Body_colliding(b1, b2)); Body_delete(b1); Body_delete(b2); }
void Body_newRectangle_shouldReturnBodyOfRightSize(CuTest* tc) { Body* b = Body_newRectangle(1, 2); CuAssertTrue(tc, Body_getWidth(b) == 1); CuAssertTrue(tc, Body_getHeight(b) == 2); Body_delete(b); }
void Body_setPosition_shouldSetRightPosition(CuTest* tc) { Body* b = Body_newRectangle(0, 0); Body_setPosition(b, 1, 2); CuAssertTrue(tc, Body_getX(b) == 1); CuAssertTrue(tc, Body_getY(b) == 2); Body_delete(b); }
void Body_delete( Body* body ) { if( body->next != NULL ) { Body_delete(body->next); } if( body->previous != NULL ) { body->previous->next = NULL; } free(body->position); free(body); }
void Body_newRectangle_returnsNonNull(CuTest* tc) { Body* b = Body_newRectangle(0, 0); CuAssertTrue(tc, b != NULL); Body_delete(b); }