~ubuntu-branches/ubuntu/natty/libgraphics-colornames-perl/natty

« back to all changes in this revision

Viewing changes to t/06-obj.t

  • Committer: Bazaar Package Importer
  • Author(s): Manoj Srivastava
  • Date: 2004-10-01 12:49:42 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041001124942-3qlde82ir9850n0s
Tags: 1.05-1
* New upstream release. 
      - updates to POD
      - correction to Graphics::ColourNames
      - correction to README
      - a filehandle for a rgb.txt file can be specified
      - hooks to support CODE scheme types (as with module
        Graphics::ColorNames::GrayScale 2.00)
      - ColourNames.pm has same version of ColorNames.pm
      - added Graphics::ColourNames alias
      - minor changes to ColorNames.pm
      - corrected typo in REQUIREMENTS (wrong Perl version)
      - uses Module::Load for improved dynamic loading
      - EXISTS works across multiple color schemes
      - bug in FETCH that returned key has been fixed
      - corrected bad link in POD
      - rebuilt distribution with proper META.yml
      - added required rgb.txt for tests to MANIFEST and distro
      * now requires Perl 5.6.0
      - uses IO::File
      - option to parse an rgb.txt file
      - removed TODO from distribution
      - Netscape.pm, HTML.pm and Windows.pm warnings enabled
      - additions and corrections in POD
      - added Build.PL to distribution
      - added hex() and rgb() methods
      - created object-oriented interface
      - additions and corrections in POD

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
use strict;
 
3
use warnings;
 
4
 
 
5
use constant TEST_CASES => {
 
6
    "black"                 => 0x000000,
 
7
    "red"                   => 0xff0000,
 
8
    "green"                 => 0x00ff00,
 
9
    "blue"                  => 0x0000ff,
 
10
    "white"                 => 0xffffff,
 
11
};
 
12
 
 
13
use Test::More tests => 3 + (9 * 5);
 
14
 
 
15
use_ok('Graphics::ColorNames', (qw(tuple2hex)));
 
16
 
 
17
my $rgb = Graphics::ColorNames->new(qw( X ));
 
18
ok(defined $rgb);
 
19
ok($rgb->isa('Graphics::ColorNames'));
 
20
 
 
21
my $tests = TEST_CASES;
 
22
 
 
23
foreach my $name (keys %$tests) {
 
24
 
 
25
  my $a = $rgb->hex($name, '0x');
 
26
  ok( $a =~ /^0x[0-9a-f]{6}$/i );
 
27
  ok( eval($a) == $tests->{$name}, "Testing color $name" );
 
28
 
 
29
  my $b = $rgb->hex($name, '#');
 
30
  ok( $b =~ /^\x23[0-9a-f]{6}$/i );
 
31
 
 
32
  my $c = $rgb->hex($name, "");
 
33
  ok( $c =~ /^[0-9a-f]{6}$/i );  
 
34
 
 
35
     $c = $rgb->hex($name);
 
36
  ok( $c =~ /^[0-9a-f]{6}$/i );  
 
37
 
 
38
  my $d = $rgb->rgb($name, ',');
 
39
  ok( $d =~ /^\d{1,3}(\,\d{1,3}){2}$/ );
 
40
 
 
41
  my @v = $rgb->rgb($name);
 
42
  ok( @v == 3 );
 
43
 
 
44
  ok( join(',', @v) eq $d );
 
45
  ok( tuple2hex(@v) eq $c );
 
46
 
 
47
}