2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-15 01:04:03 +00:00
qpdf/libtests/qtest/numrange.test

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

88 lines
2.5 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;
require TestDriver;
my $td = new TestDriver('numrange');
my @nrange_tests = (
[",5",
"error at * in numeric range *,5: invalid range syntax",
2],
["4,,5",
"error at * in numeric range 4,*,5: invalid range syntax",
2],
["4,5,",
"error at * in numeric range 4,5,*: trailing comma",
2],
["z1,",
"error at * in numeric range *z1,: invalid range syntax",
2],
["1z,",
"error at * in numeric range *1z,: invalid range syntax",
2],
["1-5?",
"error at * in numeric range *1-5?: invalid range syntax",
2],
["1-30",
"error at * in numeric range *1-30: number 30 out of range",
2],
["1-10,0,5",
"error at * in numeric range 1-10,*0,5: number 0 out of range",
2],
["1-10,1234,5",
"error at * in numeric range 1-10,*1234,5: number 1234 out of range",
2],
["1,r,3",
"error at * in numeric range 1,*r,3: invalid range syntax",
2],
["1,r16,3",
"error at * in numeric range 1,*r16,3: number 0 out of range",
2],
["1,3,5-10,z-13,13,9,z,2,r2-r4",
"numeric range 1,3,5-10,z-13,13,9,z,2,r2-r4" .
" -> 1 3 5 6 7 8 9 10 15 14 13 13 9 15 2 14 13 12",
0],
["r1-r15", # r\d+ at end
"numeric range r1-r15" .
" -> 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1",
0],
["1-10:quack",
"error at * in numeric range 1-10*:quack: expected :even or :odd",
2],
["1-10:",
"error at * in numeric range 1-10*:: expected :even or :odd",
2],
["1-10,r:",
"error at * in numeric range 1-10,r*:: expected :even or :odd",
2],
["1-10,:",
"error at * in numeric range 1-10,*:: expected :even or :odd",
2],
["1-6,8-12:odd",
"numeric range 1-6,8-12:odd -> 1 3 5 8 10 12",
0],
["1-6,8-12:even",
"numeric range 1-6,8-12:even -> 2 4 6 9 11",
0],
["x1",
"error at * in numeric range *x1: first range group may not be an exclusion",
2],
["4-10,x7-9,12-8,xr5",
"numeric range 4-10,x7-9,12-8,xr5 -> 4 5 6 10 12 10 9 8",
0],
);
foreach my $d (@nrange_tests)
{
my ($range, $output, $status) = @$d;
$td->runtest("numeric range $range",
{$td->COMMAND => ['numrange', $range],
$td->FILTER => "grep 'numeric range'"},
{$td->STRING => $output . "\n", $td->EXIT_STATUS => $status},
$td->NORMALIZE_NEWLINES);
}
$td->report(scalar(@nrange_tests));