diff options
author | Jay Berkenbilt <ejb@ql.org> | 2017-08-19 01:52:53 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2017-08-21 23:44:02 +0200 |
commit | ae90d2c485318beb8b4b938d09ffaf5c6f0a5e21 (patch) | |
tree | 3d8bd3f2b0337693621b3ed97d1a906dbf3298b7 /libtests/qtest | |
parent | 39ab004336188e53022f5345062e61639744335d (diff) | |
download | qpdf-ae90d2c485318beb8b4b938d09ffaf5c6f0a5e21.tar.zst |
Implement Pl_DCT pipeline
Additional testing is added in later commits to be supported by
additional changes in the library.
Diffstat (limited to 'libtests/qtest')
-rw-r--r-- | libtests/qtest/dct.test | 66 | ||||
-rw-r--r-- | libtests/qtest/dct/rawdata | bin | 0 -> 102400 bytes |
2 files changed, 66 insertions, 0 deletions
diff --git a/libtests/qtest/dct.test b/libtests/qtest/dct.test new file mode 100644 index 00000000..f3b28581 --- /dev/null +++ b/libtests/qtest/dct.test @@ -0,0 +1,66 @@ +#!/usr/bin/env perl +require 5.008; +use warnings; +use strict; + +chdir("dct") or die "chdir testdir failed: $!\n"; + +require TestDriver; + +# This test suite does light verification of DCT by running some data +# through a round trip with one encoding system. The +# examples/pdf-create program also exercises DCT but does so more +# fully. + +my $td = new TestDriver('dct'); + +cleanup(); + +$td->runtest("compress", + {$td->COMMAND => "dct_compress rawdata a.jpg 400 256 gray"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}); +$td->runtest("decompress", + {$td->COMMAND => "dct_uncompress a.jpg out"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}); +# Compare +my @raw = get_data('rawdata'); +my @processed = get_data('out'); +my $checked_data = 0; +if ($td->runtest("bytes in data", + {$td->STRING => scalar(@processed)}, + {$td->STRING => scalar(@raw)})) +{ + my $mismatch = 0; + for (my $i = 0; $i < scalar(@raw); ++$i) + { + $checked_data = 1; + my $delta = abs(ord($raw[$i]) - ord($processed[$i])); + if ($delta > 10) + { + ++$mismatch; + } + } + $td->runtest("data is close enough", + {$td->STRING => $mismatch}, + {$td->STRING => '0'}); +} + +cleanup(); + +$td->report(3 + $checked_data); + +sub cleanup +{ + system("rm -f a.jpg out"); +} + +sub get_data +{ + my $file = shift; + local $/ = undef; + open(F, "<$file") || die; + binmode(F); + my $data = <F>; + close(F); + split('', $data); +} diff --git a/libtests/qtest/dct/rawdata b/libtests/qtest/dct/rawdata Binary files differnew file mode 100644 index 00000000..a3594098 --- /dev/null +++ b/libtests/qtest/dct/rawdata |