~ubuntu-branches/ubuntu/trusty/pdl/trusty-proposed

« back to all changes in this revision

Viewing changes to t/pic_16bit.t

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2009-12-05 12:37:41 UTC
  • mfrom: (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091205123741-ilqkc9s4zlk71z13
Tags: 1:2.4.5+dfsg-2ubuntu1
* Merge from debian testing (LP: #492898), remaining changes:
  - debian/perldl.conf: Enabled NAN support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Created on: Fri 14 Dec 2007 07:22:09 PM 
 
2
# Last saved: Fri 15 May 2009 09:40:50 AM 
 
3
#
 
4
# This tests the 16-bit image capabilities of the rpic() and wpic()
 
5
# commands.  The new code works with PNM output files and PNG format
 
6
# too.
 
7
 
 
8
# Our new default testing framework
 
9
use Test::More;
 
10
 
 
11
use PDL;
 
12
use PDL::NiceSlice;
 
13
 
 
14
BEGIN {
 
15
   eval "use PDL::IO::Pic;";
 
16
   if ( !$@ ) {
 
17
      $test_pnmtopng = 1;
 
18
      plan tests => 5;
 
19
      if($^O =~ /MSWin32/i) {
 
20
         $test_pnmtopng = `pnmtopng --help 2>&1`;
 
21
         $test_pnmtopng = $test_pnmtopng =~ /^pnmtopng:/ ? 1 : 0;
 
22
      } elsif ( !defined( scalar( qx(pnmtopng --help 2>&1) ) ) ) {
 
23
         $test_pnmtopng = 0;
 
24
      } 
 
25
   } else {
 
26
      plan skip_all => 'PDL::IO::Pic not available'
 
27
   }
 
28
   use_ok('PDL::IO::Pic');
 
29
};
 
30
 
 
31
$PDL::IO::Pic::debug=20;
 
32
 
 
33
# test save/restore of 8-bit image
 
34
my $a = sequence(16, 16);
 
35
$a->wpic('tbyte_a.pnm');
 
36
my $a_pnm = rpic('tbyte_a.pnm');
 
37
ok(sum(abs($a-$a_pnm)) == 0, 'pnm byte image save+restore');
 
38
unlink 'tbyte_a.pnm';
 
39
 
 
40
SKIP: {
 
41
  skip ": pnmtopng not found, is NetPBM installed?", 1 unless $test_pnmtopng; 
 
42
  $a->wpic('tbyte_a.png');
 
43
  my $a_png;
 
44
  unless($^O =~ /MSWin32/i) {$a_png = rpic('tbyte_a.png')}
 
45
  else {$a_png = rpic('tbyte_a.png', {FORMAT => 'PNG'})}
 
46
  ok(sum(abs($a-$a_png)) == 0, 'png byte image save+restore'); #test 3
 
47
  unlink 'tbyte_a.png';
 
48
};
 
49
 
 
50
# test save/restore of 16-bit image
 
51
my $a16 = sequence(256, 255)->ushort * 231;
 
52
$a16->wpic('tushort_a16.pnm');
 
53
my $a16_pnm = rpic('tushort_a16.pnm');
 
54
ok(sum(abs($a16-$a16_pnm)) == 0, 'pnm ushort image save+restore'); # test 4
 
55
unlink 'tushort_a16.pnm';
 
56
 
 
57
SKIP : {
 
58
  skip ": pnmtopng not found, is NetPBM installed?", 1 unless $test_pnmtopng;
 
59
  $a16->wpic('tushort_a16.png');
 
60
  my $a16_png;
 
61
  unless($^O =~ /MSWin32/i) {$a16_png = rpic('tushort_a16.png')}
 
62
  else {$a16_png = rpic('tushort_a16.png', {FORMAT => 'PNG'})} 
 
63
  ok(sum(abs($a16-$a16_png)) == 0, 'png ushort image save+restore'); # test 5 (fails on Win32 if not skipped)
 
64
  unlink 'tushort_a16.png';
 
65
  };
 
66
 
 
67
# end