Added file t/core_surface.t
Kartik Thakore [Fri, 16 Oct 2009 00:34:08 +0000 (20:34 -0400)]
src/Surface.xs
t/core_surface.t [new file with mode: 0644]

index 29e9427..f3805db 100644 (file)
@@ -144,7 +144,7 @@ IV
 surface_get_pixels(surface)
        SDL_Surface *surface
        CODE:
-         printf("Incomplete surface");
+         if(!surface->pixels) croak("Incomplete surface");
          RETVAL = PTR2IV(surface->pixels);
        OUTPUT:
          RETVAL
diff --git a/t/core_surface.t b/t/core_surface.t
new file mode 100644 (file)
index 0000000..143a791
--- /dev/null
@@ -0,0 +1,42 @@
+#!perl -w
+# Copyright (C) 2009 kthakore
+#
+# Spec tests for SDL::Surface
+#
+
+BEGIN {
+       unshift @INC, 'blib/lib','blib/arch';
+       }
+
+use strict;
+use SDL;
+use SDL::Config;
+use SDL::Surface;
+use SDL::App;
+use SDL::Rect;
+use SDL::Color;
+use Test::More;
+
+plan (tests => 2 );
+
+
+my $app  = SDL::App->new(-title => "Test", -width => 640, -height => 480, -init => SDL_INIT_VIDEO);
+
+pass 'did this pass';
+
+my $rect = SDL::Rect->new(0,0, $app->w, $app->h);
+
+
+       my $blue = SDL::Color->new(
+               0x00,
+               0x00,
+               0xff,
+       );
+
+$app->fill_rect($rect,$blue);
+
+
+print 'This is in surface : '.SDL::Surface::get_pixels($app);
+
+pass 'did this pass';
+