aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qtest/predictors.test
blob: 45b995e99884e8229989a8d7b40c52a63c1213df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env perl
require 5.008;
BEGIN { $^W = 1; }
use strict;
use File::Copy;
use Digest::MD5;

chdir("predictors") or die "chdir testdir failed: $!\n";

require TestDriver;

my $td = new TestDriver('predictors');

cleanup();

$td->runtest("decode columns = 4",
             {$td->COMMAND => "predictors png decode in1 4 1 8"},
             {$td->STRING => "done\n",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("check output",
             {$td->FILE => "out"},
             {$td->FILE => "out1"});

$td->runtest("decode columns = 5",
             {$td->COMMAND => "predictors png decode in2 5 1 8"},
             {$td->STRING => "done\n",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("check output",
             {$td->FILE => "out"},
             {$td->FILE => "out2"});

$td->runtest("encode columns = 4",
             {$td->COMMAND => "predictors png encode out1 4 1 8"},
             {$td->STRING => "done\n",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("check output",
             {$td->FILE => "out"},
             {$td->FILE => "in1"});

$td->runtest("encode columns = 5",
             {$td->COMMAND => "predictors png encode out2 5 1 8"},
             {$td->STRING => "done\n",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

$td->runtest("check output",
             {$td->FILE => "out"},
             {$td->FILE => "in2"});

my @other_png = (
    '01--32-3-16',
    '02--32-1-8',
    '03--32-3-8',
    '04--32-1-8',
    '05--32-3-8',
    '06--32-1-8',
    '07--32-3-8',
    '08--32-1-8',
    '09--32-3-8',
    '10--32-1-8',
    '11--32-3-8',
    '12--32-1-4',
    );

foreach my $i (@other_png)
{
    $i =~ m/^.*?--(\d+)-(\d+)-(\d+)$/ or die;
    my $columns = $1;
    my $samples_per_pixel = $2;
    my $bits_per_sample = $3;
    $td->runtest("decode $i",
                 {$td->COMMAND => "predictors png decode $i.data" .
                      " $columns $samples_per_pixel $bits_per_sample"},
                 {$td->STRING => "done\n",
                      $td->EXIT_STATUS => 0},
                 $td->NORMALIZE_NEWLINES);
    $td->runtest("check output for $i",
                 {$td->FILE => "out"},
                 {$td->FILE => "$i.decoded"});
}

my @tiff = (
    '01--16-1-8',
    '02--8-2-4',
    '03--4-1-16',
    );

foreach my $i (@tiff)
{
    $i =~ m/^.*?--(\d+)-(\d+)-(\d+)$/ or die;
    my $columns = $1;
    my $samples_per_pixel = $2;
    my $bits_per_sample = $3;
    $td->runtest("decode tiff $i",
                 {$td->COMMAND => "predictors tiff decode tiff-$i.data" .
                      " $columns $samples_per_pixel $bits_per_sample"},
                 {$td->STRING => "done\n",
                      $td->EXIT_STATUS => 0},
                 $td->NORMALIZE_NEWLINES);
    $td->runtest("check output for tiff-$i",
                 {$td->FILE => "out"},
                 {$td->FILE => "tiff-$i.decoded"});
    $td->runtest("encode tiff $i",
                 {$td->COMMAND => "predictors tiff encode tiff-$i.decoded" .
                      " $columns $samples_per_pixel $bits_per_sample"},
                 {$td->STRING => "done\n",
                      $td->EXIT_STATUS => 0},
                 $td->NORMALIZE_NEWLINES);
    $td->runtest("check output for tiff-$i",
                 {$td->FILE => "out"},
                 {$td->FILE => "tiff-$i.data"});
}

cleanup();

$td->report(8 + (2 * scalar(@other_png)) + (4 * scalar(@tiff)));

sub cleanup
{
    unlink "out";
}