/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
  2. use strict;
  3. use warnings;
  4. use Test::More tests => 15;
  5. use_ok('SDL::Color');
  6. # check empty: black
  7. my $black = SDL::Color->new( 0, 0, 0 );
  8. isa_ok( $black, 'SDL::Color' );
  9. is( $black->r(), 0, 'black r is 0' );
  10. is( $black->g(), 0, 'black g is 0' );
  11. is( $black->b(), 0, 'black b is 0' );
  12. # check full: white
  13. my $white = SDL::Color->new( 0xff, 0xff, 0xff );
  14. isa_ok( $white, 'SDL::Color' );
  15. is( $white->r(), 255, 'white r is 255' );
  16. is( $white->g(), 255, 'white g is 255' );
  17. is( $white->b(), 255, 'white b is 255' );
  18. # check setting a value
  19. my $orange = $white;
  20. $orange->r(254);
  21. $orange->g(153);
  22. $orange->b(0);
  23. is( $orange->r(), 254, 'orange_notcloned r is 254' );
  24. is( $orange->g(), 153, 'orange_notcloned g is 153' );
  25. is( $orange->b(), 0, 'orange_notcloned b is 0' );
  26. # check that copies also change
  27. is( $white->r(), 254, 'white (now orange) r is 254' );
  28. is( $white->g(), 153, 'white (now orange) g is 154' );
  29. is( $white->b(), 0, 'white (now orange) b is 0' );
  30. sleep(2);