Home | History | Annotate | Download | only in tests
      1 // This may look like C code, but it is really -*- C++ -*-
      2 //
      3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
      4 //
      5 // Tests for setting/getting Magick::Image attributes
      6 //
      7 
      8 #include <Magick++.h>
      9 #include <string>
     10 #include <iostream>
     11 
     12 using namespace std;
     13 
     14 using namespace Magick;
     15 
     16 int main( int /*argc*/, char ** argv)
     17 {
     18 
     19   // Initialize ImageMagick install location for Windows
     20   InitializeMagick(*argv);
     21 
     22   volatile int failures=0;
     23 
     24   try {
     25 
     26     size_t columns = 640;
     27     size_t rows = 480;
     28     Geometry geometry(columns,rows);
     29     Color canvasColor( "red" );
     30     Image image( geometry, canvasColor);
     31 
     32     //
     33     // antiAlias
     34     //
     35 
     36     // Test default value
     37     if ( image.textAntiAlias() != true )
     38       {
     39 	++failures;
     40 	cout << "Line: " << __LINE__ << ", textAntiAlias default not true" << endl;
     41       }
     42 
     43     // Test setting false
     44     image.textAntiAlias( false );
     45     if ( image.textAntiAlias() != false )
     46       {
     47 	++failures;
     48 	cout << "Line: " << __LINE__ << ", textAntiAlias not false" << endl;
     49       }
     50 
     51     // Test setting true
     52     image.textAntiAlias( true );
     53     if ( image.textAntiAlias() != true )
     54       {
     55 	++failures;
     56 	cout << "Line: " << __LINE__ << ", textAntiAlias not true" << endl;
     57       }
     58 
     59     //
     60     // adjoin
     61     //
     62 
     63     // Test default value
     64     if ( image.adjoin() != true )
     65       {
     66 	++failures;
     67 	cout << "Line: " << __LINE__
     68              << ", adjoin default not 'true' as expected" << endl;
     69       }
     70 
     71     // Test setting false
     72     image.adjoin( false );
     73     if ( image.adjoin() != false )
     74       {
     75 	++failures;
     76 	cout << "Line: " << __LINE__ << ", adjoin failed set to 'false'" << endl;
     77       }
     78 
     79     // Test setting true
     80     image.adjoin( true );
     81     if ( image.adjoin() != true )
     82       {
     83 	++failures;
     84 	cout << "Line: " << __LINE__ << ", adjoin failed set to 'true'" << endl;
     85       }
     86 
     87     //
     88     // animationDelay
     89     //
     90 
     91     // Test default value
     92     if ( image.animationDelay() != 0 )
     93       {
     94 	++failures;
     95 	cout << "Line: " << __LINE__ << ", animationDelay default ("
     96 	     << image.animationDelay()
     97 	     << ") not 0 as expected" << endl;
     98       }
     99 
    100     // Test setting to 0
    101     image.animationDelay( 0 );
    102     if ( image.animationDelay() != 0 )
    103       {
    104 	++failures;
    105 	cout << "Line: " << __LINE__
    106              << ", failed to set animationDelay to 0" << endl;
    107       }
    108 
    109     // Test setting to 100
    110     image.animationDelay( 100 );
    111     if ( image.animationDelay() != 100 )
    112       {
    113 	++failures;
    114 	cout << "Line: " << __LINE__
    115              << ", failed to set animationDelay to 100" << endl;
    116       }
    117     image.animationDelay(0);
    118 
    119     //
    120     // animationIterations
    121     //
    122 
    123     // Test default value
    124     if ( image.animationIterations() != 0 )
    125       {
    126 	++failures;
    127 	cout << "Line: " << __LINE__
    128              << ", animationIterations default ("
    129 	     << image.animationIterations()
    130 	     << ") not 0 as expected" << endl;
    131       }
    132 
    133     // Test setting to 0
    134     image.animationIterations( 0 );
    135     if ( image.animationIterations() != 0 )
    136       {
    137 	++failures;
    138 	cout << "Line: " << __LINE__
    139              << ", failed to set animationIterations to 0" << endl;
    140       }
    141 
    142     // Test setting to 100
    143     image.animationIterations( 100 );
    144     if ( image.animationIterations() != 100 )
    145       {
    146 	++failures;
    147 	cout << "Line: " << __LINE__
    148              << ", failed to set animationIterations to 100" << endl;
    149       }
    150     image.animationIterations( 0 );
    151 
    152     //
    153     // backgroundColor
    154     //
    155 
    156     // Test default value.
    157     if ( image.backgroundColor() != ColorRGB("white") )
    158       {
    159 	++failures;
    160 	cout << "Line: " << __LINE__ << ", backgroundColor default ("
    161 	     << string(image.backgroundColor())
    162 	     << ") is incorrect" << endl;
    163       }
    164 
    165     // Test setting to blue
    166     image.backgroundColor("blue");
    167     if ( !image.backgroundColor().isValid() )
    168       {
    169 	++failures;
    170 	cout << "Line: " << __LINE__ << ", backgroundColor ("
    171 	     << string(image.backgroundColor())
    172 	     << ") failed set to 'blue'" << endl;
    173       }
    174     else
    175       if ( string(image.backgroundColor()) != "#0000FF" &&
    176 	   string(image.backgroundColor()) != "#00000000FFFF" &&
    177 	   string(image.backgroundColor()) != "#0000000000000000FFFFFFFF" )
    178 	{
    179 	  ++failures;
    180 	  cout << "Line: " << __LINE__ << ", backgroundColor ("
    181 	       <<  string(image.backgroundColor()) << ") is incorrect"
    182 	       << endl;
    183 	}
    184 
    185     // Test setting using hex color
    186     image.backgroundColor("#00AAFF");
    187     if ( !image.backgroundColor().isValid() )
    188       {
    189 	++failures;
    190 	cout << "Line: " << __LINE__ << ", backgroundColor ("
    191 	     << string(image.backgroundColor())
    192 	     << ") is incorrectly invalid" << endl;
    193       }
    194     else
    195       if ( string(image.backgroundColor()) != "#00AAFF" &&
    196 	   string(image.backgroundColor()) != "#0000AAAAFFFF" &&
    197 	   string(image.backgroundColor()) != "#00000000AAAAAAAAFFFFFFFF" )
    198 	{
    199 	  ++failures;
    200 	  cout << "Line: " << __LINE__
    201 	       << ", backgroundColor ("
    202 	       << string(image.backgroundColor())
    203 	       << ") is incorrect"
    204 	       << endl;
    205 	}
    206 
    207     //
    208     // backgroundTexture
    209     //
    210 
    211     // Test default value
    212     if ( image.backgroundTexture() != "" )
    213       {
    214 	++failures;
    215 	cout << "Line: " << __LINE__ << ", backgroundTexture default ("
    216 	     << image.backgroundTexture()
    217 	     << ") is incorrect" << endl;
    218       }
    219 
    220     // Test setting/getting value
    221     image.backgroundTexture("afile.jpg");
    222     if ( image.backgroundTexture() != "afile.jpg" )
    223       {
    224 	++failures;
    225 	cout << "Line: " << __LINE__ << ", backgroundTexture ("
    226 	     << image.backgroundTexture()
    227 	     << ") is incorrect" << endl;
    228       }
    229 
    230     // Test setting back to default
    231     image.backgroundTexture("");
    232     if ( image.backgroundTexture() != "" )
    233       {
    234 	++failures;
    235 	cout << "Line: " << __LINE__
    236 	     << ", backgroundTexture ("
    237 	     << image.backgroundTexture()
    238 	     << ") failed to set to \"\"" << endl;
    239       }
    240 
    241     //
    242     // baseColumns
    243     //
    244     if ( image.baseColumns() != columns )
    245       {
    246 	++failures;
    247 	cout << "Line: " << __LINE__
    248 	     << ", baseColumns ("
    249 	     << image.baseColumns()
    250 	     << ") is not equal to "
    251 	     << columns
    252 	     << " as expected"
    253 	     << endl;
    254       }
    255 
    256 
    257     //
    258     // baseFilename
    259     //
    260     // Base filename is color for xc images
    261     if ( image.baseFilename() != "xc:#FF0000" &&
    262 	 image.baseFilename() != "xc:#FFFF00000000" &&
    263 	 image.baseFilename() != "xc:#FFFFFFFF0000000000000000")
    264       {
    265 	++failures;
    266 	cout << "Line: " << __LINE__
    267 	     << ", baseFilename ("
    268 	     << image.baseFilename()
    269 	     << ") is incorrect"
    270 	     << endl;
    271       }
    272 
    273     //
    274     // baseRows
    275     //
    276     if ( image.baseRows() != rows )
    277       {
    278 	++failures;
    279 	cout << "Line: " << __LINE__
    280 	     << ", baseRows ("
    281 	     << image.baseRows()
    282 	     << ") != rows ("
    283 	     << rows
    284 	     << ")"
    285 	     << endl;
    286       }
    287 
    288     //
    289     // borderColor
    290     //
    291     if ( image.borderColor() != ColorRGB("#dfdfdf") )
    292       {
    293 	++failures;
    294 	cout << "Line: " << __LINE__
    295 	     << ",  borderColor default ("
    296 	     << string(image.borderColor())
    297 	     << ") is incorrect" << endl;
    298       }
    299 
    300     image.borderColor("#FF0000");
    301     if ( image.borderColor() != Color("#FF0000") )
    302       {
    303 	++failures;
    304 	cout << "Line: " << __LINE__
    305 	     << ", failed to set borderColor ("
    306 	     << string(image.borderColor())
    307 	     << ")" << endl;
    308       }
    309 
    310     image.borderColor("black");
    311     if ( image.borderColor() != Color("#000000") )
    312       {
    313 	++failures;
    314 	cout << "Line: " << __LINE__
    315 	     << ", failed to set borderColor ("
    316 	     << string(image.borderColor())
    317 	     << ")"
    318 	     << endl;
    319       }
    320 
    321     //
    322     // boxColor
    323     //
    324     image.boxColor("#FF0000");
    325     if ( image.boxColor() != Color("#FF0000") )
    326       {
    327 	++failures;
    328 	cout << "Line: " << __LINE__
    329 	     << ", failed to set boxColor ("
    330 	     << string(image.boxColor())
    331 	     << ")"
    332 	     << endl;
    333       }
    334 
    335     image.boxColor("black");
    336     if ( image.boxColor() != Color("#000000") )
    337       {
    338 	++failures;
    339 	cout << "Line: " << __LINE__
    340 	     << ", failed to set boxColor ("
    341 	     << string(image.boxColor())
    342 	     << ") to #000000"
    343 	     << endl;
    344       }
    345 
    346     //
    347     // chromaBluePrimary
    348     //
    349     {
    350       // Test default setting
    351       double x, y, z;
    352       image.chromaBluePrimary(&x, &y, &z);
    353       if ( x == 0.0f || y == 0.0f )
    354 	{
    355 	  ++failures;
    356 	  cout << "Line: " << __LINE__
    357 	       << ",  chromaBluePrimary x/y defaults are zero"
    358 	       << endl;
    359 	}
    360 
    361       // Test set/get
    362       image.chromaBluePrimary(50, 100, 150 );
    363       image.chromaBluePrimary(&x, &y, &z);
    364       if ( x != 50 || y != 100 || z != 150 )
    365 	{
    366 	  ++failures;
    367 	  cout << "Line: " << __LINE__
    368                << ",  chromaBluePrimary x/y failed set/get" << endl;
    369 	}
    370     }
    371 
    372     //
    373     // chromaGreenPrimary
    374     //
    375     {
    376       // Test default setting
    377       double x, y, z;
    378       image.chromaGreenPrimary(&x, &y, &z);
    379       if ( x == 0.0f || y == 0.0f )
    380 	{
    381 	  ++failures;
    382 	  cout << "Line: " << __LINE__
    383                << ",  chromaGreenPrimary x/y defaults are zero" << endl;
    384 	}
    385 
    386       // Test set/get
    387       image.chromaGreenPrimary(50, 100, 150);
    388       image.chromaGreenPrimary(&x, &y, &z);
    389       if (x != 50 || y != 100 || z != 150)
    390 	{
    391 	  ++failures;
    392 	  cout << "Line: " << __LINE__
    393                << ",  chromaGreenPrimary x/y failed set/get" << endl;
    394 	}
    395     }
    396 
    397     //
    398     // chromaRedPrimary
    399     //
    400     {
    401       // Test default setting
    402       double x, y, z;
    403       image.chromaRedPrimary(&x, &y, &z);
    404       if ( x == 0.0f || y == 0.0f )
    405 	{
    406 	  ++failures;
    407 	  cout << "Line: " << __LINE__
    408                << ",  chromaRedPrimary x/y defaults are zero" << endl;
    409 	}
    410 
    411       // Test set/get
    412       image.chromaRedPrimary(50, 100, 150);
    413       image.chromaRedPrimary(&x, &y, &z);
    414       if (x != 50 || y != 100 || z != 150)
    415 	{
    416 	  ++failures;
    417 	  cout << "Line: " << __LINE__
    418                << ",  chromaRedPrimary x/y failed set/get" << endl;
    419 	}
    420     }
    421 
    422     //
    423     // chromaWhitePoint
    424     //
    425     {
    426       // Test default setting
    427       double x, y, z;
    428       image.chromaWhitePoint(&x, &y, &z);
    429       if ( x == 0.0f || y == 0.0f )
    430 	{
    431 	  ++failures;
    432 	  cout << "Line: " << __LINE__
    433                << ",  chromaWhitePoint x/y defaults are zero" << endl;
    434 	}
    435 
    436       // Test set/get
    437       image.chromaWhitePoint(50, 100, 150);
    438       image.chromaWhitePoint(&x, &y, &z);
    439       if (x != 50 || y != 100 || z != 150)
    440 	{
    441 	  ++failures;
    442 	  cout << "Line: " << __LINE__
    443                << ",  chromaWhitePoint x/y failed set/get" << endl;
    444 	}
    445     }
    446 
    447     //
    448     // classType
    449     //
    450     if ( image.classType() != DirectClass )
    451       {
    452 	++failures;
    453 	cout << "Line: " << __LINE__ << ", classType is not DirectClass" << endl;
    454       }
    455 
    456     //
    457     // colorFuzz
    458     //
    459 
    460     // Test default
    461     if ( image.colorFuzz() != 0 )
    462       {
    463 	++failures;
    464 	cout << "Line: " << __LINE__ << ",  colorFuzz default is non-zero" << endl;
    465       }
    466 
    467     // Test set/get
    468     image.colorFuzz( 2 );
    469     if ( image.colorFuzz() != 2 )
    470       {
    471 	++failures;
    472 	cout << "Line: " << __LINE__ << ",  colorFuzz failed to set/get" << endl;
    473       }
    474     image.colorFuzz( 0 );
    475 
    476     //
    477     // columns
    478     //
    479     if ( image.columns() != columns )
    480       {
    481 	++failures;
    482 	cout << "Line: " << __LINE__
    483              << ", columns is not equal to canvas image columns" << endl;
    484       }
    485 
    486     //
    487     // comment
    488     //
    489     // Test default
    490     if ( image.comment().length() != 0 )
    491       {
    492 	++failures;
    493 	cout << "Line: " << __LINE__
    494              << ", comment default non-zero length" << endl;
    495       }
    496 
    497     // Test set/get
    498     {
    499       std::string comment("This is a comment.");
    500       image.comment( comment );
    501       if ( image.comment() != comment )
    502 	{
    503 	  ++failures;
    504 	  cout << "Line: " << __LINE__ << ", comment set/get failed" << endl;
    505 	}
    506     }
    507 
    508     // Test resetting comment
    509     image.comment( string() );
    510     if ( image.comment().length() != 0 )
    511       {
    512 	++failures;
    513 	cout << "Line: " << __LINE__ << ", comment failed to reset" << endl;
    514       }
    515 
    516     //
    517     // compressType
    518     //
    519     // Test default
    520     if ( image.compressType() != UndefinedCompression )
    521       {
    522 	++failures;
    523 	cout << "Line: " << __LINE__
    524              << ", compressType default is incorrect" << endl;
    525       }
    526 
    527     // Test set/get
    528     image.compressType(RLECompression);
    529     if ( image.compressType() != RLECompression )
    530       {
    531 	++failures;
    532 	cout << "Line: " << __LINE__ << ", compressType set/get failed" << endl;
    533       }
    534     image.compressType(UndefinedCompression);
    535 
    536     //
    537     // density
    538     //
    539     {
    540       // Test defaults
    541       if ( image.density() != Point(72) )
    542 	{
    543 	  ++failures;
    544 	  cout << "Line: " << __LINE__
    545                << ", density default is not 72x72 as expected" << endl;
    546 	}
    547 
    548       // Test set/get
    549       Point density(150,75);
    550       image.density(density);
    551       if ( image.density() != density )
    552 	{
    553 	  ++failures;
    554 	  cout << "Line: " << __LINE__ << ", density set/get failed" << endl;
    555 	}
    556 
    557 
    558       if ( image.xResolution() != 150 ||
    559 	   image.yResolution() != 75 )
    560 	{
    561 	  ++failures;
    562 	  cout << "Line: " << __LINE__ << ", density set/get failed" << endl;
    563 	}
    564 
    565       image.density("72x72");
    566 
    567     }
    568 
    569     //
    570     // Format specific defines
    571     //
    572     if (image.defineSet("foo","bar"))
    573       {
    574         ++failures;
    575         cout << "Line: " << __LINE__
    576              << ", define for foo:bar incorrectly reports set."
    577              << endl;
    578       }
    579 
    580     image.defineSet("foo","bar",true);
    581     if (!image.defineSet("foo","bar"))
    582       {
    583         ++failures;
    584         cout << "Line: " << __LINE__
    585              << ", define for foo:bar incorrectly reports not set."
    586              << endl;
    587       }
    588 
    589     image.defineSet("foo","bar",false);
    590     if (image.defineSet("foo","bar"))
    591       {
    592         ++failures;
    593         cout << "Line: " << __LINE__
    594              << ", define for foo:bar incorrectly reports set."
    595              << endl;
    596       }
    597 
    598     image.defineValue("foo","bar","value");
    599     std::string value = image.defineValue("foo","bar");
    600     if (image.defineValue("foo","bar") != "value")
    601       {
    602         ++failures;
    603         cout << "Line: " << __LINE__
    604              << ", define for foo:bar incorrectly reports value \""
    605              << value << "\""
    606              << endl;
    607       }
    608 
    609     image.defineSet("foo","bar",false);
    610     if (image.defineSet("foo","bar"))
    611       {
    612         ++failures;
    613         cout << "Line: " << __LINE__
    614              << ", define for foo:bar incorrectly reports set."
    615              << endl;
    616       }
    617 
    618     //
    619     // depth
    620     //
    621     if ( image.depth() != MAGICKCORE_QUANTUM_DEPTH )
    622       {
    623 	++failures;
    624 	cout << "Line: " << __LINE__
    625              << ", depth ("
    626              << image.depth()
    627              << ") is not equal to " << MAGICKCORE_QUANTUM_DEPTH << endl;
    628       }
    629 
    630     //
    631     // Directory
    632     //
    633     {
    634       // Since this is not a montage image, simply verify error report
    635       bool caughtException = false;
    636       cout << "Testing throwing and catching exceptions. A program crash or a message" << endl
    637            << "that the exception was not caught indicates a test failure.  A properly" << endl
    638            << "formatted exception message indicates success:" << endl;
    639       try
    640 	{
    641 	  //image.directory();
    642           Magick::Image bad_image("foo");
    643 	}
    644       catch ( Exception &exception_)
    645 	{
    646           cout << "Caught exception, good!:" << endl
    647                << "  \"" << exception_.what() << "\"" << endl;
    648 	  caughtException = true;
    649 	}
    650       if ( caughtException != true )
    651 	{
    652 	  ++failures;
    653           cout << "failed to catch exception!" << endl;
    654 	}
    655     }
    656 
    657     //
    658     // fileName
    659     //
    660     // Test default
    661     if ( image.fileName() != string("xc:") + string(canvasColor) )
    662       {
    663 	++failures;
    664 	cout << "Line: "
    665 	     << __LINE__
    666 	     << ", fileName ("
    667 	     << image.fileName()
    668 	     << ") is not canvas color ("
    669 	     << string(canvasColor)
    670 	     <<") as expected" << endl;
    671       }
    672 
    673     // Set/get value
    674     image.fileName("filename.jpg");
    675     if ( image.fileName() != "filename.jpg" )
    676       {
    677 	++failures;
    678 	cout << "Line: "
    679 	     << __LINE__
    680 	     << ", fileName ("
    681 	     << image.fileName()
    682 	     << ") failed to set/get" << endl;
    683       }
    684     image.fileName(canvasColor);
    685 
    686     //
    687     // fileSize
    688     //
    689     // Test default
    690     if ( image.fileSize() != 0 )
    691       {
    692 	++failures;
    693 	cout << "Line: " << __LINE__ << ", fileSize ("
    694 	     << static_cast<ssize_t>(image.fileSize())
    695 	     << ") is not zero as expected" << endl;
    696       }
    697 
    698     //
    699     // filterType
    700     //
    701     // Test default
    702     if ( image.filterType() != UndefinedFilter )
    703       {
    704 	++failures;
    705 	cout << "Line: " << __LINE__
    706              << ", filterType default ("
    707              << (int)image.filterType()
    708              << ") is incorrect" << endl;
    709       }
    710 
    711     // Test set/get
    712     image.filterType( TriangleFilter );
    713     if ( image.filterType() != TriangleFilter )
    714       {
    715 	++failures;
    716 	cout << "Line: " << __LINE__ << ", filterType set/get failed"
    717              << endl;
    718       }
    719 
    720     //
    721     // font
    722     //
    723 
    724     // Test set/get
    725     image.font("helvetica");
    726     if ( image.font() != "helvetica" )
    727       {
    728 	++failures;
    729 	cout << "Line: " << __LINE__ << ", font set/get failed" << endl;
    730       }
    731     // Test set to null font
    732     image.font( string() );
    733     if ( image.font().length() != 0 )
    734       {
    735 	++failures;
    736 	cout << "Line: " << __LINE__ << ", font failed to unset" << endl;
    737       }
    738 
    739     //
    740     // fontPointsize
    741     //
    742     // Test default
    743     if ( image.fontPointsize() != 0 )
    744       {
    745 	++failures;
    746 	cout << "Line: " << __LINE__
    747              << ", fontPointsize ("
    748              << image.fontPointsize()
    749              << ") is not default of 0 as expected"
    750              << endl;
    751       }
    752 
    753     // Test set/get
    754     image.fontPointsize(10);
    755     if ( image.fontPointsize() != 10 )
    756       {
    757 	++failures;
    758 	cout << "Line: " << __LINE__
    759              << ", fontPointsize set/get failed" << endl;
    760       }
    761     image.fontPointsize(12);
    762 
    763     //
    764     // format
    765     //
    766     if ( image.format() != "Constant image uniform color" )
    767       {
    768 	++failures;
    769 	cout << "Line: " << __LINE__
    770              << ", format (" << image.format() << ") is not expected value" << endl;
    771       }
    772 
    773     //
    774     // gamma
    775     //
    776     if ( image.gamma() == 1.0f)
    777       {
    778 	++failures;
    779 	cout << "Line: " << __LINE__
    780              << ", gamma correction is unity as expected" << endl;
    781       }
    782 
    783     //
    784     // geometry
    785     //
    786     {
    787       bool caughtException = false;
    788       try
    789 	{
    790 	  image.geometry();
    791 	}
    792       catch ( Exception )
    793 	{
    794 	  caughtException = true;
    795 	}
    796       if ( caughtException != true )
    797 	{
    798 	  ++failures;
    799 	  cout << "Line: " << __LINE__
    800                << ", geometry failed to report missing image geometry";
    801 	}
    802     }
    803 
    804     //
    805     // gifDisposeMethod
    806     //
    807     // Test default
    808     if ( image.gifDisposeMethod() != 0 )
    809       {
    810 	++failures;
    811 	cout << "Line: " << __LINE__
    812              << ", gifDisposeMethod default is not zero as expected" << endl;
    813       }
    814 
    815     // Test set/get
    816     image.gifDisposeMethod(BackgroundDispose);
    817     if ( image.gifDisposeMethod() != BackgroundDispose )
    818       {
    819 	++failures;
    820 	cout << "Line: " << __LINE__
    821              << ", gifDisposeMethod set/get failed" << endl;
    822       }
    823     image.gifDisposeMethod(UndefinedDispose);
    824 
    825     //
    826     // interlaceType
    827     //
    828     // Test default
    829     if ( image.interlaceType() != NoInterlace )
    830       {
    831 	++failures;
    832 	cout << "Line: " << __LINE__
    833              << ", interlaceType default is not NoInterlace as expected" << endl;
    834       }
    835 
    836     // Test set/get
    837     image.interlaceType( PlaneInterlace );
    838     if ( image.interlaceType() != PlaneInterlace )
    839       {
    840 	++failures;
    841 	cout << "Line: " << __LINE__ << ", interlaceType set/get failed" << endl;
    842       }
    843     image.interlaceType(NoInterlace);
    844 
    845     //
    846     // label
    847     //
    848     // Test default
    849     if ( image.label().length() != 0 )
    850       {
    851 	++failures;
    852 	cout << "Line: " << __LINE__
    853              << ", label default is not empty string as expected" << endl;
    854       }
    855 
    856     // Test set/get
    857     image.label("How now brown cow?");
    858     if ( image.label() != "How now brown cow?" )
    859       {
    860 	++failures;
    861 	cout << "Line: " << __LINE__ << ", label set/get failed" << endl;
    862       }
    863     // Test set to default
    864     image.label( string() );
    865     if ( image.label().length() != 0 )
    866       {
    867 	++failures;
    868 	cout << "Line: " << __LINE__ << ", label failed to unset" << endl;
    869       }
    870 
    871     //
    872     // strokeWidth
    873     //
    874     // Test default
    875     if ( image.strokeWidth() != 1 )
    876       {
    877 	++failures;
    878 	cout << "Line: " << __LINE__
    879              << ", strokeWidth default is not 1 as expected" << endl;
    880       }
    881 
    882     // Test set/get
    883     image.strokeWidth(2);
    884     if ( image.strokeWidth() != 2 )
    885       {
    886 	++failures;
    887 	cout << "Line: " << __LINE__ << ", strokeWidth set/get failed" << endl;
    888       }
    889     image.strokeWidth(1);
    890 
    891     //
    892     // magick
    893     //
    894     // Test canvas default
    895     if ( image.magick() != "XC" )
    896       {
    897 	++failures;
    898 	cout << "Line: " << __LINE__
    899              << ", magick canvas default is not XC as expected" << endl;
    900       }
    901 
    902     // Test set/get
    903     image.magick("GIF");
    904     if ( image.magick() != "GIF" )
    905       {
    906 	++failures;
    907 	cout << "Line: " << __LINE__ << ", magick set/get failed" << endl;
    908       }
    909 
    910     image.magick("XC");
    911 
    912     //
    913     // alpha
    914     //
    915     // Test default
    916     if ( image.alpha() != false )
    917       {
    918 	++failures;
    919 	cout << "Line: " << __LINE__
    920              << ", alpha default is not false as expected" << endl;
    921       }
    922 
    923     // Test set/get
    924     image.alpha(true);
    925     if ( image.alpha() != true )
    926       {
    927 	++failures;
    928 	cout << "Line: " << __LINE__ << ", alpha set/get failed" << endl;
    929       }
    930     image.alpha(false);
    931 
    932     //
    933     // alphaColor
    934     //
    935     // Test default
    936     if ( image.alphaColor() != Color("#BDBDBD") )
    937       {
    938 	++failures;
    939 	cout << "Line: " << __LINE__
    940              << ", alphaColor default is not #BDBDBD as expected" << endl;
    941       }
    942 
    943     // Test set/get
    944     image.alphaColor(ColorRGB(0.5,0.5,1));
    945     if ( image.alphaColor() != ColorRGB(0.5,0.5,1) )
    946       {
    947 	++failures;
    948 	cout << "Line: " << __LINE__ << ", alphaColor set/get failed" << endl;
    949       }
    950 
    951     // Test unset
    952     image.alphaColor( Color() );
    953 
    954     image.alphaColor("#BDBDBD");
    955 
    956     //
    957     // meanErrorPerPixel
    958     //
    959     if ( image.meanErrorPerPixel() != 0 )
    960       {
    961 	++failures;
    962 	cout << "Line: " << __LINE__
    963              << ", meanErrorPerPixel is not zero as expected" << endl;
    964       }
    965 
    966     //
    967     // montageGeometry
    968     //
    969     {
    970       bool caughtException = false;
    971       try
    972 	{
    973 	  image.montageGeometry();
    974 	}
    975       catch ( Exception )
    976 	{
    977 	  caughtException = true;
    978 	}
    979       if ( caughtException != true )
    980 	{
    981 	  ++failures;
    982 	  cout << "Line: " << __LINE__
    983                << ", montageGeometry failed to report missing montage geometry";
    984 	}
    985     }
    986 
    987     //
    988     // monochrome
    989     //
    990     // Test default
    991     if ( image.monochrome() != false )
    992       {
    993 	++failures;
    994 	cout << "Line: " << __LINE__
    995              << ", monochrome is not false as expected" << endl;
    996       }
    997 
    998     // Test set/get
    999     image.monochrome(true);
   1000     if ( image.monochrome() != true )
   1001       {
   1002 	++failures;
   1003 	cout << "Line: " << __LINE__ << ", monochrome get/set failed" << endl;
   1004       }
   1005     image.monochrome(false);
   1006 
   1007     //
   1008     // normalizedMaxError
   1009     //
   1010     if ( image.normalizedMaxError() != 0 )
   1011       {
   1012 	++failures;
   1013 	cout << "Line: " << __LINE__
   1014              << ",normalizedMaxError is not zero as expected" << endl;
   1015       }
   1016 
   1017     //
   1018     // normalizedMeanError
   1019     //
   1020     if ( image.normalizedMeanError() != 0 )
   1021       {
   1022 	++failures;
   1023 	cout << "Line: " << __LINE__
   1024              << ", normalizedMeanError is not zero as expected" << endl;
   1025       }
   1026 
   1027     //
   1028     // strokeColor
   1029     //
   1030 
   1031     image.strokeColor(ColorRGB(0.5,0.5,1));
   1032     if ( image.strokeColor() != ColorRGB(0.5,0.5,1) )
   1033       {
   1034 	++failures;
   1035 	cout << "Line: " << __LINE__ << ", strokeColor ("
   1036 	     << string(image.strokeColor())
   1037 	     << ") set/get failed" << endl;
   1038       }
   1039 
   1040 
   1041     //
   1042     // fillColor
   1043     //
   1044 
   1045     image.fillColor(ColorRGB(0.5,0.5,1));
   1046     if ( image.fillColor() != ColorRGB(0.5,0.5,1) )
   1047       {
   1048 	++failures;
   1049 	cout << "Line: " << __LINE__ << ", fillColor ("
   1050 	     << string(image.fillColor())
   1051 	     << ") set/get failed" << endl;
   1052       }
   1053 
   1054     //
   1055     // pixelColor
   1056     //
   1057     // Test default
   1058     if ( image.pixelColor(40,60) != canvasColor )
   1059       {
   1060 	++failures;
   1061 	cout << "Line: " << __LINE__ << ", pixelColor default ("
   1062 	     << string(image.pixelColor(40,60))
   1063 	     << ") is not canvas color ("
   1064 	     << string(canvasColor)
   1065 	     << ") as expected" << endl;
   1066       }
   1067 
   1068     // Test set/get
   1069     image.pixelColor(40,60, ColorRGB(0.5,1,1));
   1070     if ( image.pixelColor(40,60) != ColorRGB(0.5,1,1) )
   1071       {
   1072 	++failures;
   1073 	cout << "Line: " << __LINE__ << ", pixelColor set/get failed" << endl;
   1074       }
   1075 
   1076     //
   1077     // page
   1078     //
   1079     // Test default
   1080     if ( image.page() != Geometry(640,480,0,0) )
   1081       {
   1082 	++failures;
   1083 	cout << "Line: " << __LINE__ << ", page default "
   1084 	     << "(" << string(image.page()) << ")"
   1085 	     << " is not 640x480 as expected" << endl;
   1086       }
   1087 
   1088     // Test set/get
   1089     image.page("letter+43+43>");
   1090     if ( image.page() != "612x792+43+43" )
   1091       {
   1092 	++failures;
   1093 	cout << "Line: " << __LINE__
   1094              << ", page set/get failed (" << string(image.page()) << ")" << endl;
   1095       }
   1096 
   1097     //
   1098     // quality
   1099     //
   1100     // Test default
   1101     if ( image.quality() != 0 )
   1102       {
   1103 	++failures;
   1104 	cout << "Line: " << __LINE__
   1105              << ", quality default is not 0 as expected" << endl;
   1106       }
   1107 
   1108     // Test set/get
   1109     image.quality(65);
   1110     if ( image.quality() != 65 )
   1111       {
   1112 	++failures;
   1113 	cout << "Line: " << __LINE__ << ", quality set/get failed" << endl;
   1114       }
   1115     image.quality(0);
   1116 
   1117     //
   1118     // quantizeColors
   1119     //
   1120     // Test default
   1121     if ( image.quantizeColors() != 256 )
   1122       {
   1123 	++failures;
   1124 	cout << "Line: " << __LINE__
   1125              << ", quantizeColors is not 256 as expected" << endl;
   1126       }
   1127 
   1128     // Test set/get
   1129     image.quantizeColors(200);
   1130     if ( image.quantizeColors() != 200 )
   1131       {
   1132 	++failures;
   1133 	cout << "Line: " << __LINE__ << ", quantizeColors set/get failed" << endl;
   1134       }
   1135     image.quantizeColors(0);
   1136 
   1137     //
   1138     // quantizeColorSpace
   1139     //
   1140     // Test default
   1141     if ( image.quantizeColorSpace() != UndefinedColorspace )
   1142       {
   1143 	++failures;
   1144 	cout << "Line: " << __LINE__
   1145              << ", quantizeColorSpace is not RGBColorspace as expected" << endl;
   1146       }
   1147 
   1148     // Test set/get
   1149     image.quantizeColorSpace(YIQColorspace);
   1150     if ( image.quantizeColorSpace() != YIQColorspace )
   1151       {
   1152 	++failures;
   1153 	cout << "Line: " << __LINE__
   1154              << ", quantizeColorSpace set/get failed" << endl;
   1155       }
   1156     image.quantizeColorSpace(RGBColorspace);
   1157 
   1158     //
   1159     // quantizeDither
   1160     //
   1161     // Test default
   1162     if ( image.quantizeDither() == false )
   1163       {
   1164 	++failures;
   1165 	cout << "Line: " << __LINE__
   1166              << ", quantizeDither is not false as expected" << endl;
   1167       }
   1168 
   1169     // Test set/get
   1170     image.quantizeDither(false);
   1171     if ( image.quantizeDither() != false )
   1172       {
   1173 	++failures;
   1174 	cout << "Line: " << __LINE__
   1175              << ", quantizeDither get/set failed" << endl;
   1176       }
   1177     image.quantizeDither(true);
   1178 
   1179     //
   1180     // quantizeTreeDepth
   1181     //
   1182     if ( image.quantizeTreeDepth() != 0 )
   1183       {
   1184 	++failures;
   1185 	cout << "Line: " << __LINE__ << ", quantizeTreeDepth default is "
   1186 	     << image.quantizeTreeDepth()
   1187 	     << " rather than zero as expected" << endl;
   1188       }
   1189 
   1190     image.quantizeTreeDepth(7);
   1191     if ( image.quantizeTreeDepth() != 7 )
   1192       {
   1193 	++failures;
   1194 	cout << "Line: " << __LINE__
   1195              << ", quantizeTreeDepth set/get failed" << endl;
   1196       }
   1197     image.quantizeTreeDepth(8);
   1198 
   1199     //
   1200     // renderingIntent
   1201     //
   1202     if ( image.renderingIntent() == UndefinedIntent )
   1203       {
   1204 	++failures;
   1205 	cout << "Line: " << __LINE__
   1206              << ", renderingIntent default is UndefinedIntent as expected"
   1207              << endl;
   1208       }
   1209 
   1210     image.renderingIntent(PerceptualIntent);
   1211     if ( image.renderingIntent() != PerceptualIntent )
   1212       {
   1213 	++failures;
   1214 	cout << "Line: " << __LINE__
   1215              << ", renderingIntent set/get failed" << endl;
   1216       }
   1217     image.renderingIntent(UndefinedIntent);
   1218 
   1219     //
   1220     // resolutionUnits
   1221     //
   1222     if ( image.resolutionUnits() != UndefinedResolution )
   1223       {
   1224 	++failures;
   1225 	cout << "Line: " << __LINE__
   1226              << ", resolutionUnits default is not UndefinedResolution as expected"
   1227              << endl;
   1228       }
   1229 
   1230     image.resolutionUnits(PixelsPerCentimeterResolution);
   1231     if ( image.resolutionUnits() != PixelsPerCentimeterResolution )
   1232       {
   1233 	++failures;
   1234 	cout << "Line: " << __LINE__
   1235              << ", resolutionUnits set/get failed" << endl;
   1236       }
   1237     image.resolutionUnits(UndefinedResolution);
   1238 
   1239     //
   1240     // rows
   1241     //
   1242     if ( image.rows() != rows )
   1243       {
   1244 	++failures;
   1245 	cout << "Line: " << __LINE__
   1246              << ", rows is canvas rows as expected" << endl;
   1247       }
   1248 
   1249     //
   1250     // scene
   1251     //
   1252     if ( image.scene() != 0 )
   1253       {
   1254 	++failures;
   1255 	cout << "Line: " << __LINE__
   1256              << ", scene default is not zero as expected" << endl;
   1257       }
   1258 
   1259     image.scene(5);
   1260     if ( image.scene() != 5 )
   1261       {
   1262 	++failures;
   1263 	cout << "Line: " << __LINE__
   1264              << ", scene set/get failed" << endl;
   1265       }
   1266     image.scene(0);
   1267 
   1268     //
   1269     // signature
   1270     //
   1271 
   1272     if ( image.signature() != "b89bff8473dd6fe2302bcfd365e7d20daf7bd97ad667fe42d1a87469fce0d138" &&
   1273 	 image.signature() != "5caa527c00cf9e59345de4aaef4f0c2312d1955c2f391ccafa98f8e11370e6e0" &&
   1274    image.signature() != "b891ddb1d32cd45c6329180e5bd733eebb8dd06c401a9c721841ec43e4a662f8")
   1275       {
   1276 	++failures;
   1277 	cout << "Line: " << __LINE__ << ", signature ("
   1278 	     << image.signature()
   1279 	     << ") is incorrect" << endl;
   1280 	image.display();
   1281       }
   1282 
   1283     //
   1284     // size
   1285     //
   1286     if ( image.size() != geometry )
   1287       {
   1288 	++failures;
   1289 	cout << "Line: " << __LINE__ << ", size ("
   1290 	     << string(image.size())
   1291 	     << ") is not equal to geometry ("
   1292 	     << string(geometry)
   1293 	     << ")"
   1294 	     << endl;
   1295       }
   1296 
   1297     image.size("800x600");
   1298     if ( image.size() != Geometry("800x600") )
   1299       {
   1300 	++failures;
   1301 	cout << "Line: " << __LINE__ << ", size set/get failed" << endl;
   1302       }
   1303     image.size( geometry );
   1304 
   1305     //
   1306     // subImage
   1307     //
   1308     if ( image.subImage() != 0 )
   1309       {
   1310 	++failures;
   1311 	cout << "Line: " << __LINE__
   1312              << ", subImage default is not zero as expected" << endl;
   1313       }
   1314 
   1315     image.subImage(5);
   1316     if ( image.subImage() != 5 )
   1317       {
   1318 	++failures;
   1319 	cout << "Line: " << __LINE__
   1320              << ", subImage set/get failed" << endl;
   1321       }
   1322     image.subImage(0);
   1323 
   1324     //
   1325     // subRange
   1326     //
   1327     if ( image.subRange() != 0 )
   1328       {
   1329 	++failures;
   1330 	cout << "Line: " << __LINE__
   1331              << ", subRange default is not zero as expected" << endl;
   1332       }
   1333 
   1334     image.subRange(5);
   1335     if ( image.subRange() != 5 )
   1336       {
   1337 	++failures;
   1338 	cout << "Line: " << __LINE__
   1339              << ", subRange set/get failed" << endl;
   1340       }
   1341     image.subRange(0);
   1342 
   1343     //
   1344     // totalColors
   1345     //
   1346     if ( image.totalColors() != 2 )
   1347       {
   1348 	++failures;
   1349 	cout << "Line: " << __LINE__ << ", totalColors is " << image.totalColors()
   1350 	     << " rather than 2 as expected" << endl;
   1351       }
   1352 
   1353     //
   1354     // type
   1355     //
   1356     image.type(PaletteType);
   1357     if ( image.type() != PaletteType )
   1358       {
   1359 	++failures;
   1360 	cout << "Line: " << __LINE__
   1361              << ", type is not PaletteType as expected. Reported type "
   1362              << (int) image.type() << endl;
   1363 
   1364       }
   1365 
   1366     //
   1367     // verbose
   1368     //
   1369     if ( image.verbose() != false )
   1370       {
   1371 	++failures;
   1372 	cout << "Line: " << __LINE__
   1373              << ", verbose is not false as expected" << endl;
   1374       }
   1375 
   1376     //
   1377     // x11Display
   1378     //
   1379     if ( image.x11Display().length() != 0 )
   1380       {
   1381 	++failures;
   1382 	cout << "Line: " << __LINE__
   1383              << ", x11Display default is not empty string as expected" << endl;
   1384       }
   1385 
   1386     image.x11Display(":0.0");
   1387     if ( image.x11Display() != ":0.0" )
   1388       {
   1389 	++failures;
   1390 	cout << "Line: " << __LINE__
   1391              << ", x11Display set/get failed" << endl;
   1392       }
   1393 
   1394     image.x11Display( string() );
   1395     if ( image.x11Display().length() != 0 )
   1396       {
   1397 	++failures;
   1398 	cout << "Line: " << __LINE__
   1399              << ", x11Display failed to unset" << endl;
   1400       }
   1401 
   1402     //
   1403     // xResolution
   1404     //
   1405     if ( image.xResolution() != 72 )
   1406       {
   1407 	++failures;
   1408 	cout << "Line: " << __LINE__
   1409              << ", xResolution default (" << image.xResolution()
   1410              << ") is not zero as expected" << endl;
   1411       }
   1412 
   1413     //
   1414     // yResolution
   1415     //
   1416     if ( image.yResolution() != 72 )
   1417       {
   1418 	++failures;
   1419 	cout << "Line: " << __LINE__
   1420              << ", yResolution default (" << image.yResolution()
   1421              << ") is not zero as expected" << endl;
   1422       }
   1423   }
   1424   catch( Exception &error_ )
   1425     {
   1426       cout << "Caught exception: " << error_.what() << endl;
   1427       return 1;
   1428     }
   1429   catch( exception &error_ )
   1430     {
   1431       cout << "Caught exception: " << error_.what() << endl;
   1432       return 1;
   1433     }
   1434 
   1435   if ( failures )
   1436     {
   1437       cout << failures << " failures" << endl;
   1438       return 1;
   1439     }
   1440 
   1441   return 0;
   1442 }
   1443