PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/t/colorpm.t

http://github.com/PerlGameDev/SDL
Perl | 35 lines | 25 code | 5 blank | 5 comment | 0 complexity | a323cfc2c9f26b512a1654bbf7bc842f MD5 | raw file
 1#!perl
 2use strict;
 3use warnings;
 4use Test::More tests => 15;
 5use_ok('SDL::Color');
 6
 7# check empty: black
 8my $black = SDL::Color->new( 0, 0, 0 );
 9isa_ok( $black, 'SDL::Color' );
10is( $black->r(), 0, 'black r is 0' );
11is( $black->g(), 0, 'black g is 0' );
12is( $black->b(), 0, 'black b is 0' );
13
14# check full: white
15my $white = SDL::Color->new( 0xff, 0xff, 0xff );
16isa_ok( $white, 'SDL::Color' );
17is( $white->r(), 255, 'white r is 255' );
18is( $white->g(), 255, 'white g is 255' );
19is( $white->b(), 255, 'white b is 255' );
20
21# check setting a value
22my $orange = $white;
23$orange->r(254);
24$orange->g(153);
25$orange->b(0);
26is( $orange->r(), 254, 'orange_notcloned r is 254' );
27is( $orange->g(), 153, 'orange_notcloned g is 153' );
28is( $orange->b(), 0,   'orange_notcloned b is 0' );
29
30# check that copies also change
31is( $white->r(), 254, 'white (now orange) r is 254' );
32is( $white->g(), 153, 'white (now orange) g is 154' );
33is( $white->b(), 0,   'white (now orange) b is 0' );
34
35sleep(2);