]> git.imager.perl.org - imager.git/blobdiff - t/t15color.t
[rt.cpan.org #65385] Patch for Imager::Color->hsv
[imager.git] / t / t15color.t
index bed1a0174c5f0cacbfc4fc6464ba425b2e296457..7b03dc41e8d607935f13a6b82fb45aa8739a73a9 100644 (file)
@@ -7,7 +7,7 @@
 # Change 1..1 below to 1..last_test_to_print .
 # (It may become useful if the test is moved to ./t subdirectory.)
 
-use Test::More tests => 55;
+use Test::More tests => 70;
 
 use Imager;
 use Imager::Test qw(is_fcolor4);
@@ -156,6 +156,39 @@ color_ok('builtin black', 0, 0, 0, 255,
   ok(!$c->set("-unknown-"), "set to unknown");
 }
 
+{
+  # test ->hsv
+  my $c = Imager::Color->new(255, 0, 0);
+  my($h,$s,$v) = $c->hsv;
+  is($h,0,'red hue');
+  is($s,1,'red saturation');
+  is($v,1,'red value');
+
+  $c = Imager::Color->new(0, 255, 0);
+  ($h,$s,$v) = $c->hsv;
+  is($h,120,'green hue');
+  is($s,1,'green saturation');
+  is($v,1,'green value');
+
+  $c = Imager::Color->new(0, 0, 255);
+  ($h,$s,$v) = $c->hsv;
+  is($h,240,'blue hue');
+  is($s,1,'blue saturation');
+  is($v,1,'blue value');
+
+  $c = Imager::Color->new(255, 255, 255);
+  ($h,$s,$v) = $c->hsv;
+  is($h,0,'white hue');
+  is($s,0,'white saturation');
+  is($v,1,'white value');
+
+  $c = Imager::Color->new(0, 0, 0);
+  ($h,$s,$v) = $c->hsv;
+  is($h,0,'black hue');
+  is($s,0,'black saturation');
+  is($v,0,'black value');
+}
+
 sub test_col {
   my ($c, $r, $g, $b, $a) = @_;
   unless ($c) {