MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / rect_testHasIntersectionPoint

Function rect_testHasIntersectionPoint

deps/SDL2/test/testautomation_rect.c:832–870  ·  view source on GitHub ↗

! * \brief Tests SDL_HasIntersection() with 1x1 pixel sized rectangles * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection */

Source from the content-addressed store, hash-verified

830 * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection
831 */
832int rect_testHasIntersectionPoint (void *arg)
833{
834 SDL_Rect refRectA = { 0, 0, 1, 1 };
835 SDL_Rect refRectB = { 0, 0, 1, 1 };
836 SDL_Rect rectA;
837 SDL_Rect rectB;
838 SDL_bool intersection;
839 int offsetX, offsetY;
840
841 /* intersecting pixels */
842 refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
843 refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
844 refRectB.x = refRectA.x;
845 refRectB.y = refRectA.y;
846 rectA = refRectA;
847 rectB = refRectB;
848 intersection = SDL_HasIntersection(&rectA, &rectB);
849 _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB);
850
851 /* non-intersecting pixels cases */
852 for (offsetX = -1; offsetX <= 1; offsetX++) {
853 for (offsetY = -1; offsetY <= 1; offsetY++) {
854 if (offsetX != 0 || offsetY != 0) {
855 refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
856 refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
857 refRectB.x = refRectA.x;
858 refRectB.y = refRectA.y;
859 refRectB.x += offsetX;
860 refRectB.y += offsetY;
861 rectA = refRectA;
862 rectB = refRectB;
863 intersection = SDL_HasIntersection(&rectA, &rectB);
864 _validateHasIntersectionResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB);
865 }
866 }
867 }
868
869 return TEST_COMPLETED;
870}
871
872/* !
873 * \brief Tests SDL_HasIntersection() with empty rectangles

Callers

nothing calls this directly

Calls 3

SDL_HasIntersectionFunction · 0.85

Tested by

no test coverage detected