Added more tests for the different primitive types
authorSam Lantinga <slouken@libsdl.org>
Sat, 19 Sep 2009 05:43:15 +0000
changeset 3265 8f534bf37bef
parent 3264 8fe0806637df
child 3266 7856dfe3a44f
Added more tests for the different primitive types
test/testsprite2.c
--- a/test/testsprite2.c	Sat Sep 19 05:12:26 2009 +0000
+++ b/test/testsprite2.c	Sat Sep 19 05:43:15 2009 +0000
@@ -100,6 +100,7 @@
 {
     int i, n;
     int window_w, window_h;
+    SDL_Rect temp;
     SDL_Rect *position, *velocity;
 
     SDL_SelectRenderer(window);
@@ -138,13 +139,52 @@
     SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
     SDL_RenderFill(NULL);
 
-    /* Draw two red points to make sure they show up correctly */
+    /* Test points */
     SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF);
     SDL_RenderPoint(0, 0);
     SDL_RenderPoint(window_w-1, 0);
     SDL_RenderPoint(0, window_h-1);
     SDL_RenderPoint(window_w-1, window_h-1);
 
+    /* Test horizontal and vertical lines */
+    SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF);
+    SDL_RenderLine(1, 0, window_w-2, 0);
+    SDL_RenderLine(1, window_h-1, window_w-2, window_h-1);
+    SDL_RenderLine(0, 1, 0, window_h-2);
+    SDL_RenderLine(window_w-1, 1, window_w-1, window_h-2);
+
+    /* Test fill */
+    SDL_SetRenderDrawColor(0xFF, 0xFF, 0xFF, 0xFF);
+    temp.x = window_w-sprite_w-1;
+    temp.y = 1;
+    temp.w = sprite_w;
+    temp.h = sprite_h;
+    SDL_RenderFill(&temp);
+    temp.x = 1;
+    temp.y = window_h-sprite_h-1;
+    temp.w = sprite_w;
+    temp.h = sprite_h;
+    SDL_RenderFill(&temp);
+
+    /* Test copy */
+    temp.x = 1;
+    temp.y = 1;
+    temp.w = sprite_w;
+    temp.h = sprite_h;
+    SDL_RenderCopy(sprite, NULL, &temp);
+    temp.x = window_w-sprite_w-1;
+    temp.y = window_h-sprite_h-1;
+    temp.w = sprite_w;
+    temp.h = sprite_h;
+    SDL_RenderCopy(sprite, NULL, &temp);
+
+    /* Test diagonal lines */
+    SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF);
+    SDL_RenderLine(sprite_w, sprite_h,
+                   window_w-sprite_w-2, window_h-sprite_h-2);
+    SDL_RenderLine(window_w-sprite_w-2, sprite_h,
+                   sprite_w, window_h-sprite_h-2);
+
     /* Move the sprite, bounce at the wall, and draw */
     n = 0;
     for (i = 0; i < num_sprites; ++i) {