summaryrefslogtreecommitdiffstats
path: root/libtests
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2009-07-13 00:52:13 +0200
committerJay Berkenbilt <ejb@ql.org>2009-07-13 00:52:13 +0200
commita9987ab57042ce755261492d93cb54d9ff10fc35 (patch)
treed764928987ee492a1051cff2df0236dbb4d2ed35 /libtests
parent0b87334a611878e354e1aea5d26f4cd407bafc73 (diff)
downloadqpdf-a9987ab57042ce755261492d93cb54d9ff10fc35.tar.zst
Fix a few compiler errors reported correctly my MSVC 9.0.
Fix libtests test suites to pass on Windows, mostly by dealing with ascii vs. binary and NL vs. CRNL change ($td->NORMALIZE_NEWLINES). Convert some test suites to use fread instead of read. PCRE.hh: define PCRE_STATIC if on Windows. Provide cross-platform function for getting current time instead of using time(0). git-svn-id: svn+q:///qpdf/trunk@678 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libtests')
-rw-r--r--libtests/ascii85.cc2
-rw-r--r--libtests/hex.cc2
-rw-r--r--libtests/lzw.cc24
-rw-r--r--libtests/qtest/ascii85.test3
-rw-r--r--libtests/qtest/bits.test3
-rw-r--r--libtests/qtest/buffer.test3
-rw-r--r--libtests/qtest/lzw.test4
-rw-r--r--libtests/qtest/md5.test3
-rw-r--r--libtests/qtest/pcre.test2
-rw-r--r--libtests/qtest/ph.test3
-rw-r--r--libtests/qtest/qutil.test3
11 files changed, 37 insertions, 15 deletions
diff --git a/libtests/ascii85.cc b/libtests/ascii85.cc
index 8be7175d..497df79a 100644
--- a/libtests/ascii85.cc
+++ b/libtests/ascii85.cc
@@ -15,7 +15,7 @@ int main()
bool done = false;
while (! done)
{
- int len = read(0, buf, sizeof(buf));
+ int len = fread(buf, 1, sizeof(buf), stdin);
if (len <= 0)
{
done = true;
diff --git a/libtests/hex.cc b/libtests/hex.cc
index 5278f95f..0a08fcb8 100644
--- a/libtests/hex.cc
+++ b/libtests/hex.cc
@@ -15,7 +15,7 @@ int main()
bool done = false;
while (! done)
{
- int len = read(0, buf, sizeof(buf));
+ int len = fread(buf, 1, sizeof(buf), stdin);
if (len <= 0)
{
done = true;
diff --git a/libtests/lzw.cc b/libtests/lzw.cc
index 034c0bb9..5bfdbbd5 100644
--- a/libtests/lzw.cc
+++ b/libtests/lzw.cc
@@ -1,6 +1,7 @@
#include <qpdf/Pl_LZWDecoder.hh>
#include <qpdf/Pl_StdioFile.hh>
+#include <qpdf/QUtil.hh>
#include <iostream>
#include <stdlib.h>
#include <string.h>
@@ -8,21 +9,36 @@
int main(int argc, char* argv[])
{
bool early_code_change = true;
- if ((argc == 2) && (strcmp(argv[1], "--no-early-code-change") == 0))
+ if ((argc == 4) && (strcmp(argv[3], "--no-early-code-change") == 0))
{
early_code_change = false;
}
- Pl_StdioFile out("stdout", stdout);
- Pl_LZWDecoder decode("decode", &out, early_code_change);
+ if (argc < 3)
+ {
+ std::cerr << "Usage: lzw infile outfile [ --no-early-code-change ]"
+ << std::endl;
+ exit(2);
+ }
try
{
+ char* infilename = argv[1];
+ char* outfilename = argv[2];
+
+ FILE* infile = QUtil::fopen_wrapper("open input file",
+ fopen(infilename, "rb"));
+ FILE* outfile = QUtil::fopen_wrapper("open output file",
+ fopen(outfilename, "wb"));
+
+ Pl_StdioFile out("output", outfile);
+ Pl_LZWDecoder decode("decode", &out, early_code_change);
+
unsigned char buf[10000];
bool done = false;
while (! done)
{
- int len = read(0, buf, sizeof(buf));
+ int len = fread(buf, 1, sizeof(buf), infile);
if (len <= 0)
{
done = true;
diff --git a/libtests/qtest/ascii85.test b/libtests/qtest/ascii85.test
index 07551bd1..7ea3ee42 100644
--- a/libtests/qtest/ascii85.test
+++ b/libtests/qtest/ascii85.test
@@ -17,6 +17,7 @@ $td->runtest("decode",
$td->runtest("partial decode",
{$td->COMMAND => "echo '\@<5skEHbu7\$3~>' | ascii85"},
{$td->STRING => "asdfqwer\n",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(2);
diff --git a/libtests/qtest/bits.test b/libtests/qtest/bits.test
index f5dac7b5..08bee707 100644
--- a/libtests/qtest/bits.test
+++ b/libtests/qtest/bits.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('bits');
$td->runtest("bits",
{$td->COMMAND => "bits"},
{$td->FILE => "bits.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/libtests/qtest/buffer.test b/libtests/qtest/buffer.test
index 83ce4643..38da9fc3 100644
--- a/libtests/qtest/buffer.test
+++ b/libtests/qtest/buffer.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('buffer');
$td->runtest("buffer",
{$td->COMMAND => "buffer"},
{$td->FILE => "buffer.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/libtests/qtest/lzw.test b/libtests/qtest/lzw.test
index 649cd330..e6142115 100644
--- a/libtests/qtest/lzw.test
+++ b/libtests/qtest/lzw.test
@@ -12,7 +12,7 @@ my $td = new TestDriver('lzw');
cleanup();
$td->runtest("decode: early code change",
- {$td->COMMAND => "lzw < lzw1.in > tmp"},
+ {$td->COMMAND => "lzw lzw1.in tmp"},
{$td->STRING => "",
$td->EXIT_STATUS => 0});
@@ -21,7 +21,7 @@ $td->runtest("check output",
{$td->FILE => "lzw1.out"});
$td->runtest("decode: no early code change",
- {$td->COMMAND => "lzw --no-early-code-change < lzw2.in > tmp"},
+ {$td->COMMAND => "lzw lzw2.in tmp --no-early-code-change"},
{$td->STRING => "",
$td->EXIT_STATUS => 0});
diff --git a/libtests/qtest/md5.test b/libtests/qtest/md5.test
index 4c0685cd..076a37ec 100644
--- a/libtests/qtest/md5.test
+++ b/libtests/qtest/md5.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('md5');
$td->runtest("md5",
{$td->COMMAND => "md5"},
{$td->FILE => "md5.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/libtests/qtest/pcre.test b/libtests/qtest/pcre.test
index cf0418da..89a1d83c 100644
--- a/libtests/qtest/pcre.test
+++ b/libtests/qtest/pcre.test
@@ -16,7 +16,7 @@ $td->runtest("PCRE",
$td->NORMALIZE_NEWLINES);
chop(my $supported = `pcre --unicode-classes-supported`);
-if ($supported)
+if ($supported =~ m/^1/)
{
$td->runtest("unicode character classes",
{$td->COMMAND => "pcre --unicode-classes"},
diff --git a/libtests/qtest/ph.test b/libtests/qtest/ph.test
index 8e70efd5..9c0ffb8e 100644
--- a/libtests/qtest/ph.test
+++ b/libtests/qtest/ph.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('ph');
$td->runtest("PointerHolder",
{$td->COMMAND => "pointer_holder"},
{$td->FILE => "ph.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);
diff --git a/libtests/qtest/qutil.test b/libtests/qtest/qutil.test
index e90692f8..9c0410e5 100644
--- a/libtests/qtest/qutil.test
+++ b/libtests/qtest/qutil.test
@@ -12,6 +12,7 @@ my $td = new TestDriver('qutil');
$td->runtest("QUtil",
{$td->COMMAND => "qutil"},
{$td->FILE => "qutil.out",
- $td->EXIT_STATUS => 0});
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->report(1);