summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/P2.t30
-rw-r--r--t/data/P2.pgm52
2 files changed, 82 insertions, 0 deletions
diff --git a/t/P2.t b/t/P2.t
new file mode 100644
index 0000000..41c2d8e
--- /dev/null
+++ b/t/P2.t
@@ -0,0 +1,30 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Image::PNM;
+
+my $image = Image::PNM->new('t/data/P2.pgm');
+
+is($image->width, 6);
+is($image->height, 8);
+is($image->max_pixel_value, 255);
+is_deeply($image->raw_pixel(1, 2), [78, 78, 78]);
+is_deeply($image->pixel(0, 0), [1, 1, 1]);
+
+is($image->as_string('P2'), <<IMAGE);
+P2
+6 8
+255
+255 255 255 255 255 255
+255 255 78 78 255 255
+255 0 255 255 0 255
+0 255 255 255 255 0
+0 54 54 54 54 0
+0 255 255 255 255 0
+0 255 255 255 255 0
+255 255 255 255 255 255
+IMAGE
+
+done_testing;
diff --git a/t/data/P2.pgm b/t/data/P2.pgm
new file mode 100644
index 0000000..0dbad2e
--- /dev/null
+++ b/t/data/P2.pgm
@@ -0,0 +1,52 @@
+P2
+# CREATOR: GIMP PNM Filter Version 1.1
+6 8
+255
+255
+255
+255
+255
+255
+255
+255
+255
+78
+78
+255
+255
+255
+0
+255
+255
+0
+255
+0
+255
+255
+255
+255
+0
+0
+54
+54
+54
+54
+0
+0
+255
+255
+255
+255
+0
+0
+255
+255
+255
+255
+0
+255
+255
+255
+255
+255
+255