1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 2001, 2002, 2003
5 // Test Magick::CoderInfo class and Magick::coderInfoList
15 using namespace Magick;
17 int test( CoderInfo::MatchType isReadable_,
18 CoderInfo::MatchType isWritable_,
19 CoderInfo::MatchType isMultiFrame_ )
22 list<CoderInfo> coderList;
23 coderInfoList( &coderList, isReadable_, isWritable_, isMultiFrame_ );
24 list<CoderInfo>::iterator entry = coderList.begin();
25 while( entry != coderList.end() )
28 if ( isReadable_ != CoderInfo::AnyMatch &&
29 (( entry->isReadable() && isReadable_ != CoderInfo::TrueMatch ) ||
30 ( !entry->isReadable() && isReadable_ != CoderInfo::FalseMatch )) )
34 << "\" has unexpected readablity state ("
35 << static_cast<int>(entry->isReadable())
42 if ( isWritable_ != CoderInfo::AnyMatch &&
43 (( entry->isWritable() && isWritable_ != CoderInfo::TrueMatch ) ||
44 ( !entry->isWritable() && isWritable_ != CoderInfo::FalseMatch )) )
48 << "\" has unexpected writablity state ("
49 << static_cast<int>(entry->isWritable())
56 if ( isMultiFrame_ != CoderInfo::AnyMatch &&
57 (( entry->isMultiFrame() && isMultiFrame_ != CoderInfo::TrueMatch ) ||
58 ( !entry->isMultiFrame() && isMultiFrame_ != CoderInfo::FalseMatch )) )
62 << "\" has unexpected multiframe state ("
63 << static_cast<int>(entry->isMultiFrame())
75 int main( int /*argc*/, char **argv)
78 // Initialize ImageMagick install location for Windows
79 InitializeMagick(*argv);
85 CoderInfo coderInfo("GIF");
86 if ( coderInfo.name() != string("GIF") )
88 cout << "Unexpected coder name \""
95 if( coderInfo.description() != string("CompuServe graphics interchange format") )
97 cout << "Unexpected coder description \""
98 << coderInfo.description()
104 failures += test(CoderInfo::AnyMatch,CoderInfo::AnyMatch,CoderInfo::AnyMatch);
105 failures += test(CoderInfo::FalseMatch,CoderInfo::FalseMatch,CoderInfo::FalseMatch);
107 failures += test(CoderInfo::TrueMatch,CoderInfo::AnyMatch,CoderInfo::AnyMatch);
108 failures += test(CoderInfo::FalseMatch,CoderInfo::AnyMatch,CoderInfo::AnyMatch);
110 failures += test(CoderInfo::AnyMatch,CoderInfo::TrueMatch,CoderInfo::AnyMatch);
111 failures += test(CoderInfo::AnyMatch,CoderInfo::FalseMatch,CoderInfo::AnyMatch);
113 failures += test(CoderInfo::AnyMatch,CoderInfo::AnyMatch,CoderInfo::TrueMatch);
114 failures += test(CoderInfo::AnyMatch,CoderInfo::AnyMatch,CoderInfo::FalseMatch);
116 catch( Exception &error_ )
118 cout << "Caught exception: " << error_.what() << endl;
121 catch( exception &error_ )
123 cout << "Caught exception: " << error_.what() << endl;
129 cout << failures << " failures" << endl;