Commit 86f2d3449c651674b92b1249186375ad821f9017
1 parent
a1c0aaf0
windows fixes; okay for modern compilers
git-svn-id: svn+q:///qpdf/trunk@685 71b93d88-0707-0410-a8cf-f5a4172ac649
Showing
2 changed files
with
11 additions
and
28 deletions
libtests/qexc.cc
| ... | ... | @@ -4,20 +4,6 @@ |
| 4 | 4 | #include <errno.h> |
| 5 | 5 | #include <stdlib.h> |
| 6 | 6 | |
| 7 | -void do_terminate() | |
| 8 | -{ | |
| 9 | - try | |
| 10 | - { | |
| 11 | - throw; | |
| 12 | - } | |
| 13 | - catch (std::exception& e) | |
| 14 | - { | |
| 15 | - std::cerr << "uncaught exception: " << e.what() << std::endl; | |
| 16 | - exit(3); | |
| 17 | - } | |
| 18 | - exit(4); | |
| 19 | -} | |
| 20 | - | |
| 21 | 7 | void f(int n) |
| 22 | 8 | { |
| 23 | 9 | switch (n) |
| ... | ... | @@ -33,19 +19,11 @@ void f(int n) |
| 33 | 19 | case 2: |
| 34 | 20 | throw QEXC::System("doing something", EINVAL); |
| 35 | 21 | break; |
| 36 | - | |
| 37 | - case 3: | |
| 38 | - { | |
| 39 | - int a = -1; | |
| 40 | - new char[a]; | |
| 41 | - } | |
| 42 | - break; | |
| 43 | 22 | } |
| 44 | 23 | } |
| 45 | 24 | |
| 46 | 25 | int main(int argc, char* argv[]) |
| 47 | 26 | { |
| 48 | - std::set_terminate(do_terminate); | |
| 49 | 27 | if (argc != 2) |
| 50 | 28 | { |
| 51 | 29 | std::cerr << "usage: qexc n" << std::endl; |
| ... | ... | @@ -62,5 +40,14 @@ int main(int argc, char* argv[]) |
| 62 | 40 | std::cerr << "what: " << e.what() << std::endl; |
| 63 | 41 | exit(2); |
| 64 | 42 | } |
| 43 | + catch (std::exception& e) | |
| 44 | + { | |
| 45 | + std::cerr << "uncaught exception: " << e.what() << std::endl; | |
| 46 | + exit(3); | |
| 47 | + } | |
| 48 | + catch (...) | |
| 49 | + { | |
| 50 | + exit(4); | |
| 51 | + } | |
| 65 | 52 | return 0; |
| 66 | 53 | } | ... | ... |
libtests/qtest/qexc.test
| ... | ... | @@ -14,18 +14,14 @@ my @tests = |
| 14 | 14 | (['general exception', 2], |
| 15 | 15 | ['internal error', 3], |
| 16 | 16 | ['system exception', 2], |
| 17 | - ['library exception', 3, "uncaught exception: .+\n"], # fails on VC7? | |
| 18 | 17 | ); |
| 19 | 18 | |
| 20 | 19 | for (my $i = 0; $i < scalar(@tests); ++$i) |
| 21 | 20 | { |
| 22 | - my $output = +((-f "test$i.out") | |
| 23 | - ? {$td->FILE => "test$i.out"} | |
| 24 | - : {$td->REGEXP => $tests[$i]->[2]}); | |
| 25 | - $output->{$td->EXIT_STATUS} = $tests[$i]->[1]; | |
| 26 | 21 | $td->runtest($tests[$i]->[0], |
| 27 | 22 | {$td->COMMAND => "qexc $i"}, |
| 28 | - $output, | |
| 23 | + {$td->FILE => "test$i.out", | |
| 24 | + $td->EXIT_STATUS => $tests[$i]->[1]}, | |
| 29 | 25 | $td->NORMALIZE_NEWLINES); |
| 30 | 26 | } |
| 31 | 27 | ... | ... |