Applied Tels patch for faster Color.pm
[sdlgit/SDL_perl.git] / t / colorpm.t
CommitLineData
8fde61e3 1#!/usr/bin/perl -w
2#
789195af 3# Copyright (C) 2003,2006 Tels
8fde61e3 4# Copyright (C) 2004 David J. Goehrig
5#
6# basic testing of SDL::Color
7
8BEGIN {
9 unshift @INC, 'blib/lib','blib/arch';
10}
11
12use strict;
13
14use Test::More;
15
789195af 16plan ( tests => 15 );
8fde61e3 17
18use_ok( 'SDL::Color' );
19
20can_ok ('SDL::Color', qw/
21 new
22 r
23 g
24 b
789195af 25 rgb
8fde61e3 26 pixel /);
27
28# some basic tests:
29
30my $color = SDL::Color->new();
31is (ref($color), 'SDL::Color', 'new was ok');
32is ($color->r(),0, 'r is 0');
33is ($color->g(),0, 'g is 0');
34is ($color->b(),0, 'b is 0');
35
789195af 36is (join(":", $color->rgb()), '0:0:0', 'r, g and b are 0');
37
8fde61e3 38$color = SDL::Color->new( -r => 0xff, -g => 0xff, -b => 0xff);
39is (ref($color), 'SDL::Color', 'new was ok');
40is ($color->r(),255, 'r is 255');
41is ($color->g(),255, 'g is 255');
42is ($color->b(),255, 'b is 255');
43
789195af 44is (join(":", $color->rgb()), '255:255:255', 'r, g and b are 255');
45is (join(":", $color->rgb(128,0,80)), '128:0:80', 'r, g and b are set');
46is (join(":", $color->rgb()), '128:0:80', 'r, g and b still set');
47
48# test the new new($r,$g,$b) calling style
49$color = SDL::Color->new( 255,70,128);
50is (join(":", $color->rgb()), '255:70:128', 'r, g and b are set via new($r,$g,$b)');
51