1 // This may look like C code, but it is really -*- C++ -*- 2 // 3 // Copyright Dirk Lemstra 2015 4 // 5 // Test Magick::Geometry class 6 // 7 8 #include <Magick++.h> 9 #include <string> 10 #include <iostream> 11 12 using namespace std; 13 14 using namespace Magick; 15 main(int,char ** argv)16int main(int, char **argv) 17 { 18 19 // Initialize ImageMagick install location for Windows 20 InitializeMagick(*argv); 21 22 int failures=0; 23 24 try 25 { 26 27 // 28 // Verify conversion from and to string 29 // 30 31 string input="100x50+10-5!"; 32 Geometry geometry(input); 33 34 if ((geometry.width() != 100) || (geometry.height() != 50) || 35 (geometry.xOff() != 10) || (geometry.yOff() != -5) || 36 (geometry.aspect() == false)) 37 { 38 ++failures; 39 cout << "Line: " << __LINE__ 40 << " Conversion from " << input << " failed" 41 << endl; 42 } 43 44 string output=geometry; 45 if (output != input) 46 { 47 ++failures; 48 cout << "Line: " << __LINE__ 49 << " Output " << output << " is not the same as " << input 50 << endl; 51 } 52 } 53 catch( Exception &error_ ) 54 { 55 cout << "Caught exception: " << error_.what() << endl; 56 return 1; 57 } 58 catch( exception &error_ ) 59 { 60 cout << "Caught exception: " << error_.what() << endl; 61 return 1; 62 } 63 64 if ( failures ) 65 { 66 cout << failures << " failures" << endl; 67 return 1; 68 } 69 70 return 0; 71 } 72