Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SDLx::Surface::draw_rect tests

  • Loading branch information...
commit 564c0a9fcf1424e8469e6d3b68fb5eabd217081b 1 parent fbfe159
Jeffrey T. Palmer jtpalmer authored
Showing with 27 additions and 2 deletions.
  1. +27 −2 t/sdlx_surface.t
29 t/sdlx_surface.t
View
@@ -101,8 +101,33 @@ pass 'Single rect update';
$surfs[0]->update( [ SDL::Rect->new( 0, 1, 2, 3 ), SDL::Rect->new( 2, 4, 5, 6 ) ] );
pass 'SDL::Rect array update';
-$surfs[0]->draw_rect( [ 0, 0, 10, 20 ], 0xFF00FFFF );
-pass 'draw_rect works';
+my @colors = (
+ [ 255, 255, 255, 255 ],
+ [ 255, 255, 0, 255 ],
+ [ 255, 0, 255, 255 ],
+ [ 0, 255, 255, 255 ],
+ [ 255, 0, 0, 255 ],
+ [ 0, 255, 0, 255 ],
+ [ 0, 0, 255, 255 ],
+ [ 0, 0, 0, 255 ],
+ [ 32, 64, 128, 255 ],
+ [ 128, 32, 64, 255 ],
+ [ 64, 128, 32, 255 ],
+);
+
+foreach my $c (@colors) {
+ my $color = ( $c->[0] << 24 ) + ( $c->[1] << 16 ) + ( $c->[2] << 8 ) + $c->[3];
+ $surfs[0]->draw_rect( [ 0, 0, 10, 20 ], $color );
+
+ my $num = sprintf('0x%08x', $color);
+
+ my $rgba = SDL::Video::get_RGB( $app->format(), $surfs[0]->[0][0] );
+ is( $rgba->[0], $c->[0], "draw_rect uses correct red for $num" );
+ is( $rgba->[1], $c->[1], "draw_rect uses correct green for $num" );
+ is( $rgba->[2], $c->[2], "draw_rect uses correct blue for $num" );
+
+ #is($rgba->[3], $c->[3], "draw_rect uses correct alpha for $num");
+}
SKIP:
{
Please sign in to comment.
Something went wrong with that request. Please try again.