File: colorpm.t

package info (click to toggle)
libsdl-perl 2.548-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,972 kB
  • sloc: perl: 13,985; ansic: 583; makefile: 35
file content (35 lines) | stat: -rw-r--r-- 981 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!perl
use strict;
use warnings;
use Test::More tests => 15;
use_ok('SDL::Color');

# check empty: black
my $black = SDL::Color->new( 0, 0, 0 );
isa_ok( $black, 'SDL::Color' );
is( $black->r(), 0, 'black r is 0' );
is( $black->g(), 0, 'black g is 0' );
is( $black->b(), 0, 'black b is 0' );

# check full: white
my $white = SDL::Color->new( 0xff, 0xff, 0xff );
isa_ok( $white, 'SDL::Color' );
is( $white->r(), 255, 'white r is 255' );
is( $white->g(), 255, 'white g is 255' );
is( $white->b(), 255, 'white b is 255' );

# check setting a value
my $orange = $white;
$orange->r(254);
$orange->g(153);
$orange->b(0);
is( $orange->r(), 254, 'orange_notcloned r is 254' );
is( $orange->g(), 153, 'orange_notcloned g is 153' );
is( $orange->b(), 0,   'orange_notcloned b is 0' );

# check that copies also change
is( $white->r(), 254, 'white (now orange) r is 254' );
is( $white->g(), 153, 'white (now orange) g is 154' );
is( $white->b(), 0,   'white (now orange) b is 0' );

sleep(2);