! * \brief Tests SDL_HasIntersection() with B partially intersecting A * * \sa * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection */
| 763 | * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection |
| 764 | */ |
| 765 | int rect_testHasIntersectionPartial (void *arg) |
| 766 | { |
| 767 | SDL_Rect refRectA = { 0, 0, 32, 32 }; |
| 768 | SDL_Rect refRectB; |
| 769 | SDL_Rect rectA; |
| 770 | SDL_Rect rectB; |
| 771 | SDL_bool intersection; |
| 772 | |
| 773 | /* rectB partially contained in rectA */ |
| 774 | refRectB.x = SDLTest_RandomIntegerInRange(refRectA.x + 1, refRectA.x + refRectA.w - 1); |
| 775 | refRectB.y = SDLTest_RandomIntegerInRange(refRectA.y + 1, refRectA.y + refRectA.h - 1); |
| 776 | refRectB.w = refRectA.w; |
| 777 | refRectB.h = refRectA.h; |
| 778 | rectA = refRectA; |
| 779 | rectB = refRectB; |
| 780 | intersection = SDL_HasIntersection(&rectA, &rectB); |
| 781 | _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); |
| 782 | |
| 783 | /* rectB right edge */ |
| 784 | refRectB.x = rectA.w - 1; |
| 785 | refRectB.y = rectA.y; |
| 786 | refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); |
| 787 | refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1); |
| 788 | rectA = refRectA; |
| 789 | rectB = refRectB; |
| 790 | intersection = SDL_HasIntersection(&rectA, &rectB); |
| 791 | _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); |
| 792 | |
| 793 | /* rectB left edge */ |
| 794 | refRectB.x = 1 - rectA.w; |
| 795 | refRectB.y = rectA.y; |
| 796 | refRectB.w = refRectA.w; |
| 797 | refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1); |
| 798 | rectA = refRectA; |
| 799 | rectB = refRectB; |
| 800 | intersection = SDL_HasIntersection(&rectA, &rectB); |
| 801 | _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); |
| 802 | |
| 803 | /* rectB bottom edge */ |
| 804 | refRectB.x = rectA.x; |
| 805 | refRectB.y = rectA.h - 1; |
| 806 | refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); |
| 807 | refRectB.h = SDLTest_RandomIntegerInRange(1, refRectA.h - 1); |
| 808 | rectA = refRectA; |
| 809 | rectB = refRectB; |
| 810 | intersection = SDL_HasIntersection(&rectA, &rectB); |
| 811 | _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); |
| 812 | |
| 813 | /* rectB top edge */ |
| 814 | refRectB.x = rectA.x; |
| 815 | refRectB.y = 1 - rectA.h; |
| 816 | refRectB.w = SDLTest_RandomIntegerInRange(1, refRectA.w - 1); |
| 817 | refRectB.h = rectA.h; |
| 818 | rectA = refRectA; |
| 819 | rectB = refRectB; |
| 820 | intersection = SDL_HasIntersection(&rectA, &rectB); |
| 821 | _validateHasIntersectionResults(intersection, SDL_TRUE, &rectA, &rectB, &refRectA, &refRectB); |
| 822 |
nothing calls this directly
no test coverage detected