1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
5 // Tests for throwing exceptions
14 using namespace Magick;
16 int main( int /*argc*/, char ** argv)
18 // Initialize ImageMagick install location for Windows
19 InitializeMagick(*argv);
21 volatile int failures=0;
23 cout << "Checking for working exceptions (may crash) ... ";
27 // Basic exception test
33 catch ( int /*value_*/ )
38 // Throw a Magick++ exception class.
42 cout << "Throwing 'Magick::WarningResourceLimit' exception" << endl;
44 throw WarningResourceLimit("How now brown cow?");
46 catch( Exception & /*error_*/ )
48 cout << "Successfully caught 'Magick::WarningResourceLimit' exception" << endl;
53 // A more complex test
58 Geometry geometry(columns,rows);
59 Color canvasColor( "red" );
60 Image image( geometry, canvasColor);
66 cout << "Throwing library 'Magick::Exception' exception" << endl;
70 catch ( Exception& /*error_*/ )
72 cout << "Successfully caught library 'Magick::Exception' exception" << endl;
79 catch( Exception &error_ )
81 cout << "Bogus catch: Caught exception: " << error_.what() << endl;
85 catch( exception &error_ )
87 cout << "Bogus catch: Caught exception: " << error_.what() << endl;
94 cout << failures << " failures" << endl;
98 cout << "Exception testing passed!" << endl;