Skip to content

Commit

Permalink
SDLx::Surface::draw_rect tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpalmer committed Sep 3, 2010
1 parent fbfe159 commit 564c0a9
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions t/sdlx_surface.t
Expand Up @@ -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:
{
Expand Down

0 comments on commit 564c0a9

Please sign in to comment.