diff --git a/ChangeLog b/ChangeLog index 988059f1..70a25e5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ VERSION 0.7.2cvs ================ +2005-08-25 Vincent Richard + + * Tests: moved to CppUnit for unit tests framework. + 2005-08-23 Vincent Richard * All sources: renamed 'vmime::messaging' to 'vmime::net'. An alias has been diff --git a/SConstruct b/SConstruct index 156eb1c4..bbde1e99 100644 --- a/SConstruct +++ b/SConstruct @@ -290,66 +290,31 @@ libvmime_tests = [ 'tests/charset/test-suites/gnu.out.iso-8859-1', ] -libunitpp_common = [ - 'tests/lib/unit++/aclocal.m4', - 'tests/lib/unit++/COPYING', - 'tests/lib/unit++/guitester.cc', - 'tests/lib/unit++/main.h', - 'tests/lib/unit++/optmap-compat.h', - 'tests/lib/unit++/tester.h', - 'tests/lib/unit++/Test_unit++.cc', - 'tests/lib/unit++/unit++-compat.h', - 'tests/lib/unit++/Changelog', - 'tests/lib/unit++/guitester.h', - 'tests/lib/unit++/optmap.h', - 'tests/lib/unit++/unit++.1', - 'tests/lib/unit++/unit++.h', - 'tests/lib/unit++/gui.cc', - 'tests/lib/unit++/INSTALL', -# 'tests/lib/unit++/Makefile.in', - 'tests/lib/unit++/Test_gui.cc', - 'tests/lib/unit++/unit++.3', - 'tests/lib/unit++/configure.ac', - 'tests/lib/unit++/gui.h', -# 'tests/lib/unit++/main.cc', -# 'tests/lib/unit++/optmap.cc', -# 'tests/lib/unit++/tester.cc', - 'tests/lib/unit++/Test_optmap.cc', -# 'tests/lib/unit++/unit++.cc', - 'tests/lib/unit++/unitpp.m4' -] - -libunitpp_sources = [ - 'tests/lib/unit++/unit++.cc', - 'tests/lib/unit++/main.cc', - 'tests/lib/unit++/optmap.cc', - 'tests/lib/unit++/tester.cc' -] - libvmimetest_common = [ - 'tests/parser/testUtils.hpp' + 'tests/testUtils.hpp' ] libvmimetest_sources = [ - [ 'tests/parser/bodyPartTest', [ 'tests/parser/bodyPartTest.cpp' ] ], - [ 'tests/parser/datetimeTest', [ 'tests/parser/datetimeTest.cpp' ] ], - [ 'tests/parser/dispositionTest', [ 'tests/parser/dispositionTest.cpp' ] ], - [ 'tests/parser/encoderTest', [ 'tests/parser/encoderTest.cpp' ] ], - [ 'tests/parser/headerTest', [ 'tests/parser/headerTest.cpp' ] ], - [ 'tests/parser/mailboxTest', [ 'tests/parser/mailboxTest.cpp' ] ], - [ 'tests/parser/mediaTypeTest', [ 'tests/parser/mediaTypeTest.cpp' ] ], - [ 'tests/parser/messageIdTest', [ 'tests/parser/messageIdTest.cpp' ] ], - [ 'tests/parser/messageIdSequenceTest', [ 'tests/parser/messageIdSequenceTest.cpp' ] ], - [ 'tests/parser/pathTest', [ 'tests/parser/pathTest.cpp' ] ], - [ 'tests/parser/parameterTest', [ 'tests/parser/parameterTest.cpp' ] ], - [ 'tests/parser/textTest', [ 'tests/parser/textTest.cpp' ] ], - [ 'tests/utility/filteredStreamTest', [ 'tests/utility/filteredStreamTest.cpp' ] ], - [ 'tests/utility/md5Test', [ 'tests/utility/md5Test.cpp' ] ], - [ 'tests/utility/stringProxyTest', [ 'tests/utility/stringProxyTest.cpp' ] ], - [ 'tests/utility/stringUtilsTest', [ 'tests/utility/stringUtilsTest.cpp' ] ], - [ 'tests/utility/pathTest', [ 'tests/utility/pathTest.cpp' ] ], - [ 'tests/utility/urlTest', [ 'tests/utility/urlTest.cpp' ] ], - [ 'tests/utility/smartPtrTest', [ 'tests/utility/smartPtrTest.cpp' ] ] + 'tests/testRunner.cpp', + 'tests/parser/bodyPartTest.cpp', + 'tests/parser/datetimeTest.cpp', + 'tests/parser/dispositionTest.cpp', + 'tests/parser/encoderTest.cpp', + 'tests/parser/headerTest.cpp', + 'tests/parser/mailboxTest.cpp', + 'tests/parser/mediaTypeTest.cpp', + 'tests/parser/messageIdTest.cpp', + 'tests/parser/messageIdSequenceTest.cpp', + 'tests/parser/pathTest.cpp', + 'tests/parser/parameterTest.cpp', + 'tests/parser/textTest.cpp', + 'tests/utility/filteredStreamTest.cpp', + 'tests/utility/md5Test.cpp', + 'tests/utility/stringProxyTest.cpp', + 'tests/utility/stringUtilsTest.cpp', + 'tests/utility/pathTest.cpp', + 'tests/utility/urlTest.cpp', + 'tests/utility/smartPtrTest.cpp' ] libvmime_autotools = [ @@ -398,15 +363,10 @@ for p in libvmime_platforms_sources: libvmime_dist_files = libvmime_all_sources + libvmime_extra + libvmime_examples_sources libvmime_dist_files += libvmime_tests -libvmime_dist_files += libunitpp_common -libvmime_dist_files += libunitpp_sources +libvmime_dist_files += libvmimetest_sources libvmime_dist_files += libvmimetest_common libvmime_dist_files += libvmime_autotools -for t in libvmimetest_sources: - for f in t[1]: - libvmime_dist_files.append(f) - ################# # Set options # @@ -530,7 +490,7 @@ opts.AddOptions( ), EnumOption( 'build_tests', - 'Build unit tests (in "tests" directory)', + 'Build unit tests (run with "scons run-tests")', 'no', allowed_values = ('yes', 'no'), map = { }, @@ -872,22 +832,14 @@ Default(libVmime) # Tests if env['build_tests'] == 'yes': if env['debug'] == 'yes': - libUnitpp = env.StaticLibrary( - target = 'tests/unit++', - source = libunitpp_sources - ) - - Default(libUnitpp) - - for test in libvmimetest_sources: - Default( - env.Program( - target = test[0], - source = test[1], - LIBS=['unit++', packageVersionedGenericName + '-debug'], - LIBPATH=['.', './tests/'] - ) + Default( + env.Program( + target = 'run-tests', + source = libvmimetest_sources, + LIBS=['cppunit', 'dl', packageVersionedGenericName + '-debug'], + LIBPATH=['.'] ) + ) else: print 'Debug mode must be enabled to build tests!' Exit(1) @@ -2101,11 +2053,7 @@ env.Alias('doc', doxygenDocPath) ################ def runTests(target, source, env): - for t in libvmimetest_sources: - print "" - print t[0] + ':' # test name - os.system(t[0]) - + os.system("./run-tests") return None diff --git a/tests/lib/unit++/COPYING b/tests/lib/unit++/COPYING deleted file mode 100644 index 915951a1..00000000 --- a/tests/lib/unit++/COPYING +++ /dev/null @@ -1,359 +0,0 @@ -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 2 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. You should have received -a copy of the GNU General Public License along with this program; if not, -write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. - -The author can be contacted at azhrarn@users.sourceforge.net. - - - - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/tests/lib/unit++/Changelog b/tests/lib/unit++/Changelog deleted file mode 100644 index e3c4c02b..00000000 --- a/tests/lib/unit++/Changelog +++ /dev/null @@ -1,16 +0,0 @@ -1.2: -Added a couple of man pages. - -Incorporated some changes from Craig McGeachie to allow compilation on -MicroSoft Visual Studio. - -Added a Qt GUI - -Added Kenn Knowles' m4 automake configuration file for determining in an -automake file if unit++ is available - -Added some typename hints for compilers less large than g++ (thanks to Doug -Philips). Should get it to compile on AIX 4.3.3. - -1.1.1: -Before this list started... diff --git a/tests/lib/unit++/INSTALL b/tests/lib/unit++/INSTALL deleted file mode 100644 index 9ab3e978..00000000 --- a/tests/lib/unit++/INSTALL +++ /dev/null @@ -1,59 +0,0 @@ -The unit++ framework is meant to be very simple. - -To install it: - ./configure - make install - -This should take care of everything, and install in -/usr/local/{lib,include,man}. - -The all target (make all) will make the test for the test framework, unit++. -Try to run it to see that everything is fine. If you want to see a failing -test case, try `unit++ -f'. - -Graphics --------- - -My experience from junit are that a really great day ends with my test suite -producing that green bar... To gain that joy in C++ I have made a GUI for -unit++ based on Qt. However, it does take longer to run the unGUI version, and -I have therefore taken great care that this will still work without it. - -The install instructions for the GUI version is: - ./configure --with-qt - make install - -This will enable the gui, that is add the GUI classes to the unit++ library. -It still requires that the individual test programs enables the GUI. This is -done by adding the following lines to one of the test modules: - -#include -unitpp::gui_hook ghook; - -This will enable the -g (or --gui) option in the resulting executable. - -NOTE: -===== -The tests don't work properly on old C++ compilers, without the -header (stringstream classes). That includes the g++ 2.95.3 version found on -SunOS and OpenBSD. However, newer versions of libstd++3 works fine. - -This means that some things will not be tested in this case, and some -spurious output will result from running the unit++ program. The final count -of tests is correct, even though the output strongly suggests otherwise. -==== - -Doc. ----- -If you have doc++ available the API interface can be documented by `make -doc'. The DOCDIR variable in the Makefile controls where the files end up. - -If you want the documentation without having doc++, I try to keep it update -on the SourceForge page: http://unitpp.sourceforge.net/docs/index.html. - -It can be found as a file for download there as well. - -Man pages ---------- -I have added a man page for unit++(3). This documents the API to a level that -I deem sufficient for writing test cases. diff --git a/tests/lib/unit++/Makefile.in b/tests/lib/unit++/Makefile.in deleted file mode 100644 index 389df1f1..00000000 --- a/tests/lib/unit++/Makefile.in +++ /dev/null @@ -1,80 +0,0 @@ -# installation targets -prefix=@prefix@ -includedir=@includedir@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -mandir=@mandir@ -docdir=./html/unit++ -#various compilers. -CXX=@CXX@ -CXXFLAGS=@CXXFLAGS@ -# for those that have doc++, otherwise get it -DOC=doc++ -#Qt related stuff -QT_LIBDIR = @QT_LDFLAGS@ -QT_INCDIR = @QT_INCLUDES@ -MOC = @MOC@ -GUI_OBJS = @gui_vars@ -GUI_DOCSRC = @gui_docsrc@ - -# Below here should not need modification -TARGETLIB=libunit++.a -TARGETHEADERS=unit++.h optmap.h gui.h guitester.h main.h tester.h -# substituted into GUI_OBJS by autoconf, if GUI is enabled -gui_objs = gui.o guitester.o moc_gui.o moc_guitester.o -gui_docsrc = gui.h guitester.h -OBJS=unit++.o tester.o main.o optmap.o $(GUI_OBJS) -#the files with doc information -DOCSRC=$(TARGETHEADERS) main.h tester.h $(GUI_DOCSRC) -DOCOPTS=-d $(docdir) -TSTOBJS=Test_unit++.o Test_optmap.o Test_gui.o -TSTLIBS=-L. -lunit++ - -.SUFFIXES: .cc - -.cc.o: - $(CXX) -D__UNITPP -c $(CXXFLAGS) $(CPPFLAGS) @QT_INCLUDES@ @DEFS@ -o $@ $< - -all: $(TARGETLIB) unit++ - -$(TARGETLIB): $(OBJS) - ar r $@ $(OBJS) - -install: $(TARGETLIB) $(TARGETHEADERS) - [ -d $(libdir) ] || mkdir -p $(libdir) - [ -d $(includedir)/unit++ ] || mkdir -p $(includedir)/unit++ - [ -d $(mandir)/man1 ] || mkdir -p $(mandir)/man1 - [ -d $(mandir)/man3 ] || mkdir -p $(mandir)/man3 - cp $(TARGETLIB) $(libdir) - cp $(TARGETHEADERS) $(includedir)/unit++ - cp unit++-compat.h $(includedir)/unit++.h - cp optmap-compat.h $(includedir)/optmap.h - cp unit++.1 $(mandir)/man1 - cp unit++.3 $(mandir)/man3 - -doc: $(DOCSRC) - [ -d $(docdir) ] || mkdir -p $(docdir) - doc++ $(DOCOPTS) $(DOCSRC) - -unit++: $(TSTOBJS) $(TARGETLIB) - $(CXX) -o $@ $(TSTOBJS) $(TSTLIBS) @QT_LDFLAGS@ @qt_lib@ - -moc_gui.cc: gui.h - $(MOC) $< -o $@ -moc_guitester.cc: guitester.h - $(MOC) $< -o $@ -clean: - rm -f $(OBJS) $(TSTOBJS) - -clobber: clean - rm -f $(TARGETLIB) unit++ - -Test_optmap.o: Test_optmap.cc unit++.h optmap.h -Test_unit++.o: Test_unit++.cc unit++.h optmap.h tester.h main.h -Test_gui.o: Test_gui.cc -gui.o: gui.cc gui.h unit++.h optmap.h -guitester.o: guitester.cc -main.o: main.cc main.h tester.h unit++.h optmap.h -optmap.o: optmap.cc optmap.h -tester.o: tester.cc tester.h unit++.h optmap.h -unit++.o: unit++.cc unit++.h optmap.h diff --git a/tests/lib/unit++/Test_gui.cc b/tests/lib/unit++/Test_gui.cc deleted file mode 100644 index 4f9e47c2..00000000 --- a/tests/lib/unit++/Test_gui.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#ifdef GUI -#include "gui.h" -#include "unit++.h" -using namespace std; -using namespace unitpp; - -gui_hook ghook; // ensure linkage of the gui stuff - -namespace { -// The test suite for the gui components -class Test : public suite -{ - void dummy() - { - } -public: - Test() : suite("GUI test suite") - { - suite::main().add("gui", this); - add("dummy", testcase(this, "Test nothing", &Test::dummy)); - } -} * theTest = new Test(); - -} -#endif diff --git a/tests/lib/unit++/Test_optmap.cc b/tests/lib/unit++/Test_optmap.cc deleted file mode 100644 index 0d1d360e..00000000 --- a/tests/lib/unit++/Test_optmap.cc +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#include "unit++.h" -#include "optmap.h" -#include -#ifdef HAVE_SSTREAM -#include -#endif -using namespace std; -using namespace unitpp; -using namespace options_utils; -namespace { -const char* x[] = { "testing", "-i", "120", "-n100", "-t" }; -#ifdef HAVE_SSTREAM -class hijack { - ostream& os; - streambuf* sbp; - stringbuf sb; -public: - hijack(ostream& os) - : os(os), sbp(os.rdbuf()) - { - os.rdbuf(&sb); - } - ~hijack() { os.rdbuf(sbp); } - string str() { return sb.str(); } -}; -#endif -// The test suite for the optmap library -class Test : public suite -{ - const char** argv; - int argc; - void create() - { - optmap om; - } - void usage() - { - bool t_flg; - int i = 7; - int n = 0; - optmap om; - om.add("t", new opt_flag(t_flg)); - om.add("i", new opt_int(i)); - om.add("n", new opt_int(n)); - om.alias("number", "n"); -#ifdef HAVE_SSTREAM - string exp( - "usage: testing [ -t ] [ -i ] [( -n | --number) ]\n"); - { - hijack s(cerr); - om.parse(argc, argv); - om.usage(false); - assert_eq("usage", exp, s.str()); - } -#endif - } - void args() - { - bool t_flg = false; - int i = 7; - int n = 0; - optmap om; - om.add("t", new opt_flag(t_flg)); - om.add("i", new opt_int(i)); - om.add("n", new opt_int(n)); - assert_true("parse ok", om.parse(argc, argv)); - assert_eq("get -i", 120, i); - assert_eq("get -n", 100, n); - assert_eq("got -t", true, t_flg); - } - void tail() - { - const char* argv[] = { "xyzzy", "-abc", "-def", "hij" }; - size_t argc = sizeof(argv)/sizeof(argv[0]); - string s; - bool f_d, f_e, f_f; - optmap om; - om.add("a", new opt_string(s)); - om.add("d", new opt_flag(f_d)); - om.add("e", new opt_flag(f_e)); - om.add("f", new opt_flag(f_f)); - assert_true("parse", om.parse(static_cast(argc), argv)); - assert_eq("n", argc - 1, size_t(om.n())); - assert_eq("a", "bc", s); - } -public: - Test() : suite("optmap test suite") - { - argv = x; - argc = sizeof(x)/sizeof(char*); - suite::main().add("optmap", this); - add("create", testcase(this, "Create an optmap", &Test::create)); - add("usage", testcase(this, "Optmap usage", &Test::usage)); - add("args", testcase(this, "Optmap args", &Test::args)); - add("tail", testcase(this, "Optmap tail", &Test::tail)); - } -} * theTest = new Test(); - -} diff --git a/tests/lib/unit++/Test_unit++.cc b/tests/lib/unit++/Test_unit++.cc deleted file mode 100644 index e94c924d..00000000 --- a/tests/lib/unit++/Test_unit++.cc +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#include "unit++.h" -#include "tester.h" -#include "main.h" -#ifdef HAVE_SSTREAM -#include -#else -#include -#endif -using namespace std; -using namespace unitpp; -namespace { - -// a test case that can fail with any exception -class test_test : public test -{ -public: - enum result { succes, fail, error, exotic }; - test_test(string name, result res = succes) : test(name), res(res) {} - virtual void operator()() - { - switch (res) { - case succes: break; - case fail: ::fail("test_test"); - case error: throw out_of_range("ranged"); - case exotic: throw 4711; - } - } -private: - result res; -}; - -// The test suite for the unit++ library -class Test : public suite -{ - void create() - { - test_test a_loc_test("local"); - } - void assert_ok() - { - string s("ok"); - assert_true("assert_true(true)", true); - assert_eq("assert_eq(int)", 7, 7); - assert_eq("assert_eq(char*, string)", "ok", s); - } - void assert_fail() - { - string s("fejl"); - bool ok = true; - try { - assert_true("assert_true(false)", false); - ok = false; - } catch (assertion_error e) { -#ifdef HAVE_SSTREAM - ostringstream oss; - oss << e; - assert_eq("assert_true(false) output", - "assert_true(false) [assertion failed]", oss.str()); -#endif - } - if (!ok) - fail("no exception from assert_true(false)"); - try { - assert_eq("assert_eq(int)", 5, 7); - ok = false; - } catch (assert_value_error e) { -#ifdef HAVE_SSTREAM - ostringstream oss; - oss << e; - assert_eq("assert_eq(int) output", - "assert_eq(int) [expected: `5' got: `7']", oss.str()); -#endif - } - if (!ok) - fail("no exception from assert_eq(int)"); - try { - assert_eq("assert_eq(char*, string)", "ok", s); - ok = false; - } catch (assert_value_error e) { - } catch (assert_value_error e) { // MSVC++ bug - } - - if (!ok) - fail("no exception from assert_eq(const char*, string)"); - } - void tester_visit() - { - out_of_range oor("negative"); - assertion_error ae("test"); -#ifdef HAVE_SSTREAM - ostringstream os; - tester tst(os); -#else - tester tst(cerr); -#endif - root.visit(&tst); - assert_eq("tests ok", 3, tst.res_tests().n_ok()); - assert_eq("tests error", 2, tst.res_tests().n_err()); - assert_eq("tests fail", 1, tst.res_tests().n_fail()); - assert_eq("suites ok", 1, tst.res_suites().n_ok()); - assert_eq("suites error", 2, tst.res_suites().n_err()); - assert_eq("suites fail", 1, tst.res_suites().n_fail()); - } - void ex_test() - { - throw out_of_range("expected"); - } - void get_by_id() - { - test* p = root.get_child("s2"); - assert_true("found s2", p != 0); - suite* sp = dynamic_cast(p); - assert_true("s2 was suite", sp != 0); - assert_eq("right s2", "S2", sp->name()); - p = sp->get_child("t20"); - assert_true("found t20", p != 0); - assert_eq("not suite", static_cast(0),dynamic_cast(p)); - } - void vec() - { - string s = "three.blind.mice"; - vector v(vectorize(s,'.')); - assert_eq("v[0]", string("three"), v[0]); - assert_eq("v[1]", string("blind"), v[1]); - assert_eq("v[2]", string("mice"), v[2]); - assert_eq("size", size_t(3), v.size()); - v = vectorize(s,'-'); - assert_eq("no match", s, v[0]); - assert_eq("no match size", size_t(1), v.size()); - } - void empty_vec() - { - string s(""); - vector v(vectorize(s,'.')); - assert_eq("size", size_t(0), v.size()); - s = "one..three"; - v = vectorize(s,'.'); - assert_eq("v[0]", string("one"), v[0]); - assert_eq("v[1]", string(""), v[1]); - assert_eq("v[2]", string("three"), v[2]); - assert_eq("size", size_t(3), v.size()); - } - void find() - { - test* tp = root.find("s2.s21.t210"); - assert_eq("t210", t210, tp); - tp = root.find("s1.s21"); - assert_eq("bad mid", static_cast(0), tp); - } - suite root; - test* t210; - bool do_fail; - void fail_on_flag() - { - assert_true("Fail option not set", !do_fail); - } -public: - Test() : suite("Unit++ test suite"), root("The root") - { - do_fail = false; - options().add("f", new options_utils::opt_flag(do_fail)); - options().alias("fail", "f"); - suite* s1; - suite* s2; - suite* s21; - root.add("s1", s1 = new suite("S1")); - root.add("s2", s2 = new suite("S2")); - s2->add("s21", s21 = new suite("S21")); - s1->add("t10", new test_test("T10")); - s1->add("t11", new test_test("T11")); - s2->add("t20", new test_test("T20", test_test::error)); - s2->add("t22", new test_test("T22", test_test::exotic)); - s21->add("t210", t210 = new test_test("T210")); - s21->add("t211", new test_test("T211", test_test::fail)); - // - // Adding testcases - suite::main().add("unitpp", this); - add("create", testcase(this, "Create a test", &Test::create)); - add("assert_ok", testcase(this, "Assert ok", &Test::assert_ok)); - add("assert_fail", testcase(this, "Assert fail", &Test::assert_fail)); - add("tester_visit", testcase(this, "Visit", &Test::tester_visit)); - add("exception", testcase(new exception_test( - testcase(this, "gen ex", &Test::ex_test)))); - add("id_get", testcase(this, "Get by id", &Test::get_by_id)); - add("vec", testcase(this, "Vectorize", &Test::vec)); - add("empty_vec", testcase(this, "Vectorize empty", &Test::empty_vec)); - add("find", testcase(this, "find", &Test::find)); - add("fail", testcase(this, "fail on option", &Test::fail_on_flag)); - } -} * theTest = new Test(); - -} diff --git a/tests/lib/unit++/aclocal.m4 b/tests/lib/unit++/aclocal.m4 deleted file mode 100644 index 106908ba..00000000 --- a/tests/lib/unit++/aclocal.m4 +++ /dev/null @@ -1,314 +0,0 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4-p4 - -dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl This program is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without -dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A -dnl PARTICULAR PURPOSE. - - -dnl This file is part of QXi, the Qt XInput Extension. -dnl -dnl Copyright (C) 2000 Daniel Schmitt -dnl -dnl This file may be distributed under the terms of the Q Public License as -dnl appearing in the file COPYING.QPL included in the packaging of this file. -dnl -dnl The portions of this file that deal with the detection of Qt are -dnl stripped-down versions of macros used in KDE (http://www.kde.org/). -dnl -dnl The originals are copyrighted by -dnl Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu) -dnl (C) 1997,98,99 Stephan Kulow (coolo@kde.org) - -dnl ------------------------------------------------------------------------ -dnl Find a file (or one of more files in a list of dirs) -dnl ------------------------------------------------------------------------ -dnl -AC_DEFUN(AC_FIND_FILE, -[ -$3=NO -for i in $2; -do - for j in $1; - do - if test -r "$i/$j"; then - $3=$i - break 2 - fi - done -done -]) - -dnl ------------------------------------------------------------------------ -dnl Find the meta object compiler in the PATH, in $QTDIR/bin, and some -dnl more usual places -dnl ------------------------------------------------------------------------ -dnl -AC_DEFUN(AC_PATH_QT_MOC, -[ - AC_PATH_PROG(MOC, moc, "", $ac_qt_bindir:$QTDIR/bin:$QTDIR/src/moc:/usr/bin /usr/X11R6/bin:/usr/lib/qt/bin:/usr/lib/qt2/bin:/usr/local/qt/bin:$PATH) - - if test -z "$MOC"; then - if test -n "$ac_cv_path_moc"; then - output=`eval "$ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt"` - fi - echo "configure:__oline__: tried to call $ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt" >&AC_FD_CC - echo "configure:__oline__: moc output: $output" >&AC_FD_CC - - if test -z "$output"; then - AC_MSG_ERROR([No Qt meta object compiler (moc) found! -Please check whether you installed Qt correctly. -You need to have a running moc binary. -configure tried to run $ac_cv_path_moc and the test didn't -succeed. If configure shouldn't have tried this one, set -the environment variable MOC to the right one before running -configure. -]) - fi - fi - - AC_SUBST(MOC) -]) - -AC_DEFUN(AC_PRINT_QT_PROGRAM, -[ -cat > conftest.$ac_ext < -#include -#include - -int main() { - QStringList *t = new QStringList(); - - return 0; -} -EOF -]) - -dnl ------------------------------------------------------------------------ -dnl Try to find the Qt headers and libraries. -dnl $(QT_LDFLAGS) will be -Lqtliblocation (if needed) -dnl and $(QT_INCLUDES) will be -Iqthdrlocation (if needed) -dnl ------------------------------------------------------------------------ -dnl -AC_DEFUN(AC_PATH_QT, -[ -LIBQT="-lqt" -AC_MSG_CHECKING([for Qt]) - -ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO -qt_libraries="" -qt_includes="" -AC_ARG_WITH(qt-dir, - [ --with-qt-dir=DIR where the root of Qt is installed ], - [ ac_qt_includes="$withval"/include - ac_qt_libraries="$withval"/lib - ac_qt_bindir="$withval"/bin - ]) - -AC_ARG_WITH(qt-includes, - [ --with-qt-includes=DIR where the Qt includes are. ], - [ - ac_qt_includes="$withval" - ]) - -ac_qt_libs_given=no - -AC_ARG_WITH(qt-libraries, - [ --with-qt-libraries=DIR where the Qt library is installed.], - [ ac_qt_libraries="$withval" - ac_qt_libs_given=yes - ]) - -AC_CACHE_VAL(ac_cv_have_qt, -[#try to guess Qt locations - -qt_incdirs="$QTINC /usr/lib/qt/include /usr/local/qt/include /usr/include/qt3 /usr/include/qt /usr/include /usr/lib/qt2/include /usr/X11R6/include/X11/qt $x_includes" -test -n "$QTDIR" && qt_incdirs="$QTDIR/include $QTDIR $qt_incdirs" -qt_incdirs="$ac_qt_includes $qt_incdirs" -AC_FIND_FILE(qstyle.h, $qt_incdirs, qt_incdir) -ac_qt_includes="$qt_incdir" - -qt_libdirs="$QTLIB /usr/lib/qt/lib /usr/X11R6/lib /usr/lib /usr/local/qt/lib /usr/lib/qt /usr/lib/qt2/lib $x_libraries" -test -n "$QTDIR" && qt_libdirs="$QTDIR/lib $QTDIR $qt_libdirs" -if test ! "$ac_qt_libraries" = "NO"; then - qt_libdirs="$ac_qt_libraries $qt_libdirs" -fi - -test=NONE -qt_libdir=NONE -for dir in $qt_libdirs; do - try="ls -1 $dir/libqt*" - if test=`eval $try 2> /dev/null`; then qt_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi -done - -ac_qt_libraries="$qt_libdir" - -AC_LANG_SAVE -AC_LANG_CPLUSPLUS - -ac_cxxflags_safe="$CXXFLAGS" -ac_ldflags_safe="$LDFLAGS" -ac_libs_safe="$LIBS" - -CXXFLAGS="$CXXFLAGS -I$qt_incdir $all_includes" -LDFLAGS="-L$x_libraries -L$qt_libdir $all_libraries" -LIBS="$LIBS $LIBQT" - -AC_PRINT_QT_PROGRAM - -if AC_TRY_EVAL(ac_link) && test -s conftest; then - rm -f conftest* -else - echo "configure: failed program was:" >&AC_FD_CC - cat conftest.$ac_ext >&AC_FD_CC - ac_qt_libraries="NO" -fi -rm -f conftest* -CXXFLAGS="$ac_cxxflags_safe" -LDFLAGS="$ac_ldflags_safe" -LIBS="$ac_libs_safe" - -AC_LANG_RESTORE -if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then - ac_cv_have_qt="have_qt=no" - ac_qt_notfound="" - if test "$ac_qt_includes" = NO; then - if test "$ac_qt_libraries" = NO; then - ac_qt_notfound="(headers and libraries)"; - else - ac_qt_notfound="(headers)"; - fi - else - ac_qt_notfound="(libraries)"; - fi - - AC_MSG_ERROR([Qt 2 not found. Please check your installation! ]); -else - have_qt="yes" -fi -]) - -eval "$ac_cv_have_qt" - -if test "$have_qt" != yes; then - AC_MSG_RESULT([$have_qt]); -else - ac_cv_have_qt="have_qt=yes \ - ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries" - AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes]) - - qt_libraries="$ac_qt_libraries" - qt_includes="$ac_qt_includes" -fi - -AC_SUBST(qt_libraries) -AC_SUBST(qt_includes) - -if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then - QT_INCLUDES=""; -else - QT_INCLUDES="-I$qt_includes" - all_includes="$QT_INCLUDES $all_includes" -fi - -if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then - QT_LDFLAGS="" -else - QT_LDFLAGS="-L$qt_libraries" - all_libraries="$QT_LDFLAGS $all_libraries" -fi - -AC_SUBST(QT_INCLUDES) -AC_SUBST(QT_LDFLAGS) -AC_PATH_QT_MOC - -LIB_QT='-lqt' -AC_SUBST(LIB_QT) - -]) - -dnl ------------------------------------------------------------------------ -dnl Find libz (required by libpng) -dnl ------------------------------------------------------------------------ -dnl -AC_DEFUN(AC_FIND_ZLIB, -[ -AC_MSG_CHECKING([for libz]) -AC_CACHE_VAL(ac_cv_lib_z, -[ -AC_LANG_C -ac_save_LIBS="$LIBS" -LIBS="$all_libraries -lz $LIBSOCKET" -ac_save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $all_includes" -AC_TRY_LINK(dnl -[ -#include -], - [return (zlibVersion() == ZLIB_VERSION); ], - eval "ac_cv_lib_z='-lz'", - eval "ac_cv_lib_z=no") -LIBS="$ac_save_LIBS" -CFLAGS="$ac_save_CFLAGS" -])dnl -if eval "test ! \"`echo $ac_cv_lib_z`\" = no"; then - AC_DEFINE_UNQUOTED(HAVE_LIBZ, 1, [Define if you have libz]) - LIBZ="$ac_cv_lib_z" - AC_SUBST(LIBZ) - AC_MSG_RESULT($ac_cv_lib_z) -else - AC_MSG_RESULT(no) - LIBZ="" - AC_SUBST(LIBZ) -fi -]) - -dnl ------------------------------------------------------------------------ -dnl Find libpng (required by Qt 2) -dnl ------------------------------------------------------------------------ -dnl -AC_DEFUN(AC_FIND_PNG, -[ -AC_REQUIRE([AC_FIND_ZLIB]) -AC_MSG_CHECKING([for libpng]) -AC_CACHE_VAL(ac_cv_lib_png, -[ -ac_save_LIBS="$LIBS" -LIBS="$LIBS $all_libraries -lpng $LIBZ -lm -lX11 $LIBSOCKET" -ac_save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $all_includes" -AC_LANG_C -AC_TRY_LINK(dnl - [ - #include - ], - [ - png_structp png_ptr = png_create_read_struct( /* image ptr */ - PNG_LIBPNG_VER_STRING, 0, 0, 0 ); - return( png_ptr != 0 ); - ], - eval "ac_cv_lib_png='-lpng $LIBZ -lm'", - eval "ac_cv_lib_png=no" -) -LIBS="$ac_save_LIBS" -CFLAGS="$ac_save_CFLAGS" -])dnl -if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then - AC_DEFINE_UNQUOTED(HAVE_LIBPNG, 1, [Define if you have libpng]) - LIBPNG="$ac_cv_lib_png" - AC_SUBST(LIBPNG) - AC_MSG_RESULT($ac_cv_lib_png) -else - AC_MSG_RESULT(no) - LIBPNG="" - AC_SUBST(LIBPNG) -fi -]) - diff --git a/tests/lib/unit++/configure b/tests/lib/unit++/configure deleted file mode 100755 index 3a79072b..00000000 --- a/tests/lib/unit++/configure +++ /dev/null @@ -1,3599 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.57 for FULL-PACKAGE-NAME VERSION. -# -# Report bugs to . -# -# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 -# Free Software Foundation, Inc. -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi - -# Support unset when possible. -if (FOO=FOO; unset FOO) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - - -# Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -exec 6>&1 - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_config_libobj_dir=. -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} - -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} - -# Identity of this package. -PACKAGE_NAME='FULL-PACKAGE-NAME' -PACKAGE_TARNAME='full-package-name' -PACKAGE_VERSION='VERSION' -PACKAGE_STRING='FULL-PACKAGE-NAME VERSION' -PACKAGE_BUGREPORT='BUG-REPORT-ADDRESS' - -ac_unique_file="Test_optmap.cc" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#if HAVE_SYS_TYPES_H -# include -#endif -#if HAVE_SYS_STAT_H -# include -#endif -#if STDC_HEADERS -# include -# include -#else -# if HAVE_STDLIB_H -# include -# endif -#endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H -# include -# endif -# include -#endif -#if HAVE_STRINGS_H -# include -#endif -#if HAVE_INTTYPES_H -# include -#else -# if HAVE_STDINT_H -# include -# endif -#endif -#if HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT qt_libraries qt_includes QT_INCLUDES QT_LDFLAGS MOC LIB_QT gui_vars gui_docsrc qt_lib CXXCPP EGREP LIBOBJS LTLIBOBJS' -ac_subst_files='' - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -ac_prev= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_option in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; - - -enable-* | --enable-*) - ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid feature name: $ac_feature" >&2 - { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "enable_$ac_feature='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "with_$ac_package='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid package name: $ac_package" >&2 - { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) { echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } -fi - -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || -$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 - { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } - fi -fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 - { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CXX_set=${CXX+set} -ac_env_CXX_value=$CXX -ac_cv_env_CXX_set=${CXX+set} -ac_cv_env_CXX_value=$CXX -ac_env_CXXFLAGS_set=${CXXFLAGS+set} -ac_env_CXXFLAGS_value=$CXXFLAGS -ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} -ac_cv_env_CXXFLAGS_value=$CXXFLAGS -ac_env_LDFLAGS_set=${LDFLAGS+set} -ac_env_LDFLAGS_value=$LDFLAGS -ac_cv_env_LDFLAGS_set=${LDFLAGS+set} -ac_cv_env_LDFLAGS_value=$LDFLAGS -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS -ac_env_CXXCPP_set=${CXXCPP+set} -ac_env_CXXCPP_value=$CXXCPP -ac_cv_env_CXXCPP_set=${CXXCPP+set} -ac_cv_env_CXXCPP_value=$CXXCPP - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures FULL-PACKAGE-NAME VERSION to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -_ACEOF - - cat <<_ACEOF -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] -_ACEOF - - cat <<\_ACEOF -_ACEOF -fi - -if test -n "$ac_init_help"; then - case $ac_init_help in - short | recursive ) echo "Configuration of FULL-PACKAGE-NAME VERSION:";; - esac - cat <<\_ACEOF - -Optional Packages: - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-qt use Qt gui (default no) - --with-qt-dir=DIR where the root of Qt is installed - --with-qt-includes=DIR where the Qt includes are. - --with-qt-libraries=DIR where the Qt library is installed. - -Some influential environment variables: - CXX C++ compiler command - CXXFLAGS C++ compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory - CXXCPP C++ preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to . -_ACEOF -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - ac_popdir=`pwd` - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac -# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be -# absolute. -ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` -ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` -ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` - - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd "$ac_popdir" - done -fi - -test -n "$ac_init_help" && exit 0 -if $ac_init_version; then - cat <<\_ACEOF -FULL-PACKAGE-NAME configure VERSION -generated by GNU Autoconf 2.57 - -Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 -Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit 0 -fi -exec 5>config.log -cat >&5 <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by FULL-PACKAGE-NAME $as_me VERSION, which was -generated by GNU Autoconf 2.57. Invocation command line was - - $ $0 $@ - -_ACEOF -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - echo "PATH: $as_dir" -done - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_sep= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; - 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " - ;; - esac - done -done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - cat <<\_ASBOX -## ---------------- ## -## Cache variables. ## -## ---------------- ## -_ASBOX - echo - # The following way of writing the cache mishandles newlines in values, -{ - (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) - sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; - *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} - echo - - cat <<\_ASBOX -## ----------------- ## -## Output variables. ## -## ----------------- ## -_ASBOX - echo - for ac_var in $ac_subst_vars - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - - if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## -_ASBOX - echo - for ac_var in $ac_subst_files - do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" - done | sort - echo - fi - - if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## -## confdefs.h. ## -## ----------- ## -_ASBOX - echo - sed "/^$/d" confdefs.h | sort - echo - fi - test "$ac_signal" != 0 && - echo "$as_me: caught signal $ac_signal" - echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status - ' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 -echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { echo "$as_me:$LINENO: loading cache $cache_file" >&5 -echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; - esac - fi -else - { echo "$as_me:$LINENO: creating cache $cache_file" >&5 -echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" - case $ac_old_set,$ac_new_set in - set,) - { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 -echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 -echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 -echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 -echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 -echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - - - - - - - - - - - - - - - - - - - - - - - - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - -# Check whether --with-qt or --without-qt was given. -if test "${with_qt+set}" = set; then - withval="$with_qt" - ac_use_qt=yes -else - ac_use_qt=no -fi; - -# Checks for programs. -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -n "$ac_tool_prefix"; then - for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - echo "$as_me:$LINENO: result: $CXX" >&5 -echo "${ECHO_T}$CXX" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 -echo "${ECHO_T}$ac_ct_CXX" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - test -n "$ac_ct_CXX" && break -done -test -n "$ac_ct_CXX" || ac_ct_CXX="g++" - - CXX=$ac_ct_CXX -fi - - -# Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C++ compiler version" >&5 -ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - -cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -echo "$as_me:$LINENO: checking for C++ compiler default output" >&5 -echo $ECHO_N "checking for C++ compiler default output... $ECHO_C" >&6 -ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext - break;; - * ) - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: C++ compiler cannot create executables -See \`config.log' for more details." >&5 -echo "$as_me: error: C++ compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } -fi - -ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 - -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5 -echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6 -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { echo "$as_me:$LINENO: error: cannot run C++ compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C++ compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - fi - fi -fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - -rm -f a.out a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext - break;; - * ) break;; - esac -done -else - { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 -if test "${ac_cv_objext+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_compiler_gnu=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_compiler_gnu=no -fi -rm -f conftest.$ac_objext conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 -GXX=`test $ac_compiler_gnu = yes && echo yes` -ac_test_CXXFLAGS=${CXXFLAGS+set} -ac_save_CXXFLAGS=$CXXFLAGS -CXXFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 -echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 -if test "${ac_cv_prog_cxx_g+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cxx_g=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_prog_cxx_g=no -fi -rm -f conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 -if test "$ac_test_CXXFLAGS" = set; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -# AC_PROG_INSTALL - -# Checks for libraries. -if test "$ac_use_qt" = yes; then - -LIBQT="-lqt" -echo "$as_me:$LINENO: checking for Qt" >&5 -echo $ECHO_N "checking for Qt... $ECHO_C" >&6 - -ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO -qt_libraries="" -qt_includes="" - -# Check whether --with-qt-dir or --without-qt-dir was given. -if test "${with_qt_dir+set}" = set; then - withval="$with_qt_dir" - ac_qt_includes="$withval"/include - ac_qt_libraries="$withval"/lib - ac_qt_bindir="$withval"/bin - -fi; - - -# Check whether --with-qt-includes or --without-qt-includes was given. -if test "${with_qt_includes+set}" = set; then - withval="$with_qt_includes" - - ac_qt_includes="$withval" - -fi; - -ac_qt_libs_given=no - - -# Check whether --with-qt-libraries or --without-qt-libraries was given. -if test "${with_qt_libraries+set}" = set; then - withval="$with_qt_libraries" - ac_qt_libraries="$withval" - ac_qt_libs_given=yes - -fi; - -if test "${ac_cv_have_qt+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - #try to guess Qt locations - -qt_incdirs="$QTINC /usr/lib/qt/include /usr/local/qt/include /usr/include/qt3 /usr/include/qt /usr/include /usr/lib/qt2/include /usr/X11R6/include/X11/qt $x_includes" -test -n "$QTDIR" && qt_incdirs="$QTDIR/include $QTDIR $qt_incdirs" -qt_incdirs="$ac_qt_includes $qt_incdirs" - -qt_incdir=NO -for i in $qt_incdirs; -do - for j in qstyle.h; - do - if test -r "$i/$j"; then - qt_incdir=$i - break 2 - fi - done -done - -ac_qt_includes="$qt_incdir" - -qt_libdirs="$QTLIB /usr/lib/qt/lib /usr/X11R6/lib /usr/lib /usr/local/qt/lib /usr/lib/qt /usr/lib/qt2/lib $x_libraries" -test -n "$QTDIR" && qt_libdirs="$QTDIR/lib $QTDIR $qt_libdirs" -if test ! "$ac_qt_libraries" = "NO"; then - qt_libdirs="$ac_qt_libraries $qt_libdirs" -fi - -test=NONE -qt_libdir=NONE -for dir in $qt_libdirs; do - try="ls -1 $dir/libqt*" - if test=`eval $try 2> /dev/null`; then qt_libdir=$dir; break; else echo "tried $dir" >&5 ; fi -done - -ac_qt_libraries="$qt_libdir" - - - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -ac_cxxflags_safe="$CXXFLAGS" -ac_ldflags_safe="$LDFLAGS" -ac_libs_safe="$LIBS" - -CXXFLAGS="$CXXFLAGS -I$qt_incdir $all_includes" -LDFLAGS="-L$x_libraries -L$qt_libdir $all_libraries" -LIBS="$LIBS $LIBQT" - - -cat > conftest.$ac_ext < -#include -#include - -int main() { - QStringList *t = new QStringList(); - - return 0; -} -EOF - - -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && test -s conftest; then - rm -f conftest* -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_qt_libraries="NO" -fi -rm -f conftest* -CXXFLAGS="$ac_cxxflags_safe" -LDFLAGS="$ac_ldflags_safe" -LIBS="$ac_libs_safe" - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then - ac_cv_have_qt="have_qt=no" - ac_qt_notfound="" - if test "$ac_qt_includes" = NO; then - if test "$ac_qt_libraries" = NO; then - ac_qt_notfound="(headers and libraries)"; - else - ac_qt_notfound="(headers)"; - fi - else - ac_qt_notfound="(libraries)"; - fi - - { { echo "$as_me:$LINENO: error: Qt 2 not found. Please check your installation! " >&5 -echo "$as_me: error: Qt 2 not found. Please check your installation! " >&2;} - { (exit 1); exit 1; }; }; -else - have_qt="yes" -fi - -fi - - -eval "$ac_cv_have_qt" - -if test "$have_qt" != yes; then - echo "$as_me:$LINENO: result: $have_qt" >&5 -echo "${ECHO_T}$have_qt" >&6; -else - ac_cv_have_qt="have_qt=yes \ - ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries" - echo "$as_me:$LINENO: result: libraries $ac_qt_libraries, headers $ac_qt_includes" >&5 -echo "${ECHO_T}libraries $ac_qt_libraries, headers $ac_qt_includes" >&6 - - qt_libraries="$ac_qt_libraries" - qt_includes="$ac_qt_includes" -fi - - - - -if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then - QT_INCLUDES=""; -else - QT_INCLUDES="-I$qt_includes" - all_includes="$QT_INCLUDES $all_includes" -fi - -if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then - QT_LDFLAGS="" -else - QT_LDFLAGS="-L$qt_libraries" - all_libraries="$QT_LDFLAGS $all_libraries" -fi - - - - - # Extract the first word of "moc", so it can be a program name with args. -set dummy moc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_path_MOC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - case $MOC in - [\\/]* | ?:[\\/]*) - ac_cv_path_MOC="$MOC" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_dummy="$ac_qt_bindir:$QTDIR/bin:$QTDIR/src/moc:/usr/bin /usr/X11R6/bin:/usr/lib/qt/bin:/usr/lib/qt2/bin:/usr/local/qt/bin:$PATH" -for as_dir in $as_dummy -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_MOC="$as_dir/$ac_word$ac_exec_ext" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - - test -z "$ac_cv_path_MOC" && ac_cv_path_MOC="""" - ;; -esac -fi -MOC=$ac_cv_path_MOC - -if test -n "$MOC"; then - echo "$as_me:$LINENO: result: $MOC" >&5 -echo "${ECHO_T}$MOC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - - - if test -z "$MOC"; then - if test -n "$ac_cv_path_moc"; then - output=`eval "$ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt"` - fi - echo "configure:2054: tried to call $ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt" >&5 - echo "configure:2055: moc output: $output" >&5 - - if test -z "$output"; then - { { echo "$as_me:$LINENO: error: No Qt meta object compiler (moc) found! -Please check whether you installed Qt correctly. -You need to have a running moc binary. -configure tried to run $ac_cv_path_moc and the test didn't -succeed. If configure shouldn't have tried this one, set -the environment variable MOC to the right one before running -configure. -" >&5 -echo "$as_me: error: No Qt meta object compiler (moc) found! -Please check whether you installed Qt correctly. -You need to have a running moc binary. -configure tried to run $ac_cv_path_moc and the test didn't -succeed. If configure shouldn't have tried this one, set -the environment variable MOC to the right one before running -configure. -" >&2;} - { (exit 1); exit 1; }; } - fi - fi - - - - -LIB_QT='-lqt' - - - - cat >>confdefs.h <<\_ACEOF -#define GUI 1 -_ACEOF - - gui_vars='$(gui_objs)' - gui_docsrc='$(gui_docsrc)' - qt_lib='-lqt' -fi - - - - -# Checks for header files. - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 -echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 -if test -z "$CXXCPP"; then - if test "${ac_cv_prog_CXXCPP+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - # Double quotes because CXXCPP needs to be expanded - for CXXCPP in "$CXX -E" "/lib/cpp" - do - ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - break -fi - - done - ac_cv_prog_CXXCPP=$CXXCPP - -fi - CXXCPP=$ac_cv_prog_CXXCPP -else - ac_cv_prog_CXXCPP=$CXXCPP -fi -echo "$as_me:$LINENO: result: $CXXCPP" >&5 -echo "${ECHO_T}$CXXCPP" >&6 -ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.$ac_ext - - # OK, works on sane cases. Now check whether non-existent headers - # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - # Broken: success on invalid input. -continue -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : -else - { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." >&5 -echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi - -ac_ext=cc -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -echo "$as_me:$LINENO: checking for egrep" >&5 -echo $ECHO_N "checking for egrep... $ECHO_C" >&6 -if test "${ac_cv_prog_egrep+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' - fi -fi -echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 -echo "${ECHO_T}$ac_cv_prog_egrep" >&6 - EGREP=$ac_cv_prog_egrep - - -echo "$as_me:$LINENO: checking for ANSI C header files" >&5 -echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 -if test "${ac_cv_header_stdc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_header_stdc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_header_stdc=no -fi -rm -f conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then - : -else - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - exit(2); - exit (0); -} -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 -echo "${ECHO_T}$ac_cv_header_stdc" >&6 -if test $ac_cv_header_stdc = yes; then - -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - eval "$as_ac_Header=yes" -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -eval "$as_ac_Header=no" -fi -rm -f conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - -for ac_header in sstream -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_header_compiler=no -fi -rm -f conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_cxx_preproc_warn_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc in - yes:no ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------ ## -## Report this to bug-autoconf@gnu.org. ## -## ------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; - no:yes ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------ ## -## Report this to bug-autoconf@gnu.org. ## -## ------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -# Checks for typedefs, structures, and compiler characteristics. - -# Checks for library functions. - - ac_config_files="$ac_config_files Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -{ - (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" - ;; - esac; -} | - sed ' - t clear - : clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache -if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" - cat confcache >$cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/; -s/:*\${srcdir}:*/:/; -s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then we branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -cat >confdef2opt.sed <<\_ACEOF -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g -t quote -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g -t quote -d -: quote -s,[ `~#$^&*(){}\\|;'"<>?],\\&,g -s,\[,\\&,g -s,\],\\&,g -s,\$,$$,g -p -_ACEOF -# We use echo to avoid assuming a particular line-breaking character. -# The extra dot is to prevent the shell from consuming trailing -# line-breaks from the sub-command output. A line-break within -# single-quotes doesn't work because, if this script is created in a -# platform that uses two characters for line-breaks (e.g., DOS), tr -# would break. -ac_LF_and_DOT=`echo; echo .` -DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'` -rm -f confdef2opt.sed - - -ac_libobjs= -ac_ltlibobjs= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: ${CONFIG_STATUS=./config.status} -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 -echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - -# Be Bourne compatible -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix -fi - -# Support unset when possible. -if (FOO=FOO; unset FOO) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - - -# Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -for as_var in \ - LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ - LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ - LC_TELEPHONE LC_TIME -do - if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then - eval $as_var=C; export $as_var - else - $as_unset $as_var - fi -done - -# Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done - - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | - sed ' - N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, - t loop - s,-$,, - s,^['$as_cr_digits']*\n,, - ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno - # Exit status is that of the last command. - exit -} - - -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; -esac - -if expr a : '\(a\)' >/dev/null 2>&1; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -echo >conf$$.file -if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links - as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi -elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.file - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - as_mkdir_p=false -fi - -as_executable_p="test -f" - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" - - -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - -exec 6>&1 - -# Open the log real soon, to keep \$[0] and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - -This file was extended by FULL-PACKAGE-NAME $as_me VERSION, which was -generated by GNU Autoconf 2.57. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 -_ACEOF - -# Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi - -cat >>$CONFIG_STATUS <<\_ACEOF - -ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. - -Usage: $0 [OPTIONS] [FILE]... - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Report bugs to ." -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF -ac_cs_version="\\ -FULL-PACKAGE-NAME config.status VERSION -configured by $0, generated by GNU Autoconf 2.57, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" - -Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF -# If no file are specified by the user, then we need to provide default -# value. By we need to know if files were specified by the user. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` - ac_shift=: - ;; - -*) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; - esac - - case $ac_option in - # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - CONFIG_FILES="$CONFIG_FILES $ac_optarg" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" - ac_need_defaults=false;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; } ;; - - *) ac_config_targets="$ac_config_targets $1" ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF -if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion -fi - -_ACEOF - - - - - -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_config_target in $ac_config_targets -do - case "$ac_config_target" in - # Handling of arguments. - "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; - esac -done - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. -$debug || -{ - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 -} - -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" -} || -{ - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) -} || -{ - echo "$me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} - -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF - -# -# CONFIG_FILES section. -# - -# No need to generate the scripts if there are no CONFIG_FILES. -# This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s,@SHELL@,$SHELL,;t t -s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t -s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t -s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t -s,@program_transform_name@,$program_transform_name,;t t -s,@bindir@,$bindir,;t t -s,@sbindir@,$sbindir,;t t -s,@libexecdir@,$libexecdir,;t t -s,@datadir@,$datadir,;t t -s,@sysconfdir@,$sysconfdir,;t t -s,@sharedstatedir@,$sharedstatedir,;t t -s,@localstatedir@,$localstatedir,;t t -s,@libdir@,$libdir,;t t -s,@includedir@,$includedir,;t t -s,@oldincludedir@,$oldincludedir,;t t -s,@infodir@,$infodir,;t t -s,@mandir@,$mandir,;t t -s,@build_alias@,$build_alias,;t t -s,@host_alias@,$host_alias,;t t -s,@target_alias@,$target_alias,;t t -s,@DEFS@,$DEFS,;t t -s,@ECHO_C@,$ECHO_C,;t t -s,@ECHO_N@,$ECHO_N,;t t -s,@ECHO_T@,$ECHO_T,;t t -s,@LIBS@,$LIBS,;t t -s,@CXX@,$CXX,;t t -s,@CXXFLAGS@,$CXXFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CXX@,$ac_ct_CXX,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@qt_libraries@,$qt_libraries,;t t -s,@qt_includes@,$qt_includes,;t t -s,@QT_INCLUDES@,$QT_INCLUDES,;t t -s,@QT_LDFLAGS@,$QT_LDFLAGS,;t t -s,@MOC@,$MOC,;t t -s,@LIB_QT@,$LIB_QT,;t t -s,@gui_vars@,$gui_vars,;t t -s,@gui_docsrc@,$gui_docsrc,;t t -s,@qt_lib@,$qt_lib,;t t -s,@CXXCPP@,$CXXCPP,;t t -s,@EGREP@,$EGREP,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF - -_ACEOF - - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat - fi -fi # test -n "$CONFIG_FILES" - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; - esac - - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - - ac_builddir=. - -if test "$ac_dir" != .; then - ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi - -case $srcdir in - .) # No --srcdir option. We are building in place. - ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac -# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be -# absolute. -ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` -ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` -ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` - - - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo $f;; - *) # Relative - if test -f "$f"; then - # Build tree - echo $f - elif test -f "$srcdir/$f"; then - # Source tree - echo $srcdir/$f - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi - -done -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF - -{ (exit 0); exit 0; } -_ACEOF -chmod +x $CONFIG_STATUS -ac_clean_files=$ac_clean_files_save - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } -fi - diff --git a/tests/lib/unit++/configure.ac b/tests/lib/unit++/configure.ac deleted file mode 100644 index e08be85a..00000000 --- a/tests/lib/unit++/configure.ac +++ /dev/null @@ -1,32 +0,0 @@ -# Process this file with autoconf to produce a configure script. -AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) -AC_LANG(C++) -AC_CONFIG_SRCDIR([Test_optmap.cc]) -AC_ARG_WITH(qt, AC_HELP_STRING([--with-qt], [use Qt gui (default no)]), - [ac_use_qt=yes], [ac_use_qt=no]) - -# Checks for programs. -AC_PROG_CXX -# AC_PROG_INSTALL - -# Checks for libraries. -if test "$ac_use_qt" = yes; then - AC_PATH_QT - AC_DEFINE([GUI]) - gui_vars='$(gui_objs)' - gui_docsrc='$(gui_docsrc)' - qt_lib='-lqt' -fi -AC_SUBST(gui_vars) -AC_SUBST(gui_docsrc) -AC_SUBST(qt_lib) - -# Checks for header files. -AC_CHECK_HEADERS([sstream]) - -# Checks for typedefs, structures, and compiler characteristics. - -# Checks for library functions. - -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT diff --git a/tests/lib/unit++/gui.cc b/tests/lib/unit++/gui.cc deleted file mode 100644 index 6344b5e8..00000000 --- a/tests/lib/unit++/gui.cc +++ /dev/null @@ -1,313 +0,0 @@ -#include -#include "gui.h" -#include "unit++.h" -#ifdef HAVE_SSTREAM -#include -#endif -using namespace unitpp; -using namespace std; - -#ifdef GUI -static const char* const img_error[] = { -"14 14 2 1", -". c #ff0000", -"# c #ffffff", -"...########...", -"....######....", -".....####.....", -"#.....##.....#", -"##..........##", -"###........###", -"####......####", -"####......####", -"###........###", -"##..........##", -"#.....##.....#", -".....####.....", -"....######....", -"...########..."}; - -static const char* const img_fail[] = { -"14 14 2 1", -"# c #ff0000", -". c #ffffff", -"..............", -".##........##.", -".###......###.", -"..###....###..", -"...###..###...", -"....######....", -".....####.....", -".....####.....", -"....######....", -"...###..###...", -"..###....###..", -".###......###.", -".##........##.", -".............."}; - -static const char* const img_ok[] = { -"14 14 3 1", -"# c #00ff00", -"a c #00ff6a", -". c #ffffff", -"..........###.", -".........###..", -"........#a#...", -"........aa#...", -".......#aa....", -".......#a.....", -"......#aa.....", -"#.....aa#.....", -"###..#a#......", -".##.##a.......", -"..#aaa#.......", -"...#aa#.......", -"....##........", -".....#........"}; - -static const char* const img_empty[] = { -"14 14 2 1", -". c #f0f0f0", -"# c #ffffff", -"..............", -".############.", -".############.", -".############.", -".############.", -".############.", -".############.", -".############.", -".############.", -".############.", -".############.", -".############.", -".############.", -".............."}; - - -cnt_item::cnt_item(QWidget* par, const QString& txt, const QColor& col, - const char* name) - : QHBox(par, name), v(0) -{ - setSpacing(3); - setMargin(5); - val = new QLabel("0", this); - val->setAlignment(QLabel::AlignVCenter | QLabel::AlignRight); - QPalette pal(val->palette()); - QColorGroup cg(pal.active()); - cg.setColor(QColorGroup::Foreground, col); - pal.setActive(cg); - val->setPalette(pal); - label = new QLabel(txt, this); -} -void cnt_item::value(int iv) -{ - v = iv; - val->setNum(v); -} -void cnt_item::inc() -{ - value(v+1); -} - -cnt_line::cnt_line(const QString& txt, QWidget* par, const char* name) - : QHBox(par, name) -{ - label = new QLabel(txt, this); - QFont font(label->font()); - font.setBold(true); - label->setFont(font); - cnts[0] = new cnt_item(this, "Total"); - cnts[1] = new cnt_item(this, "OK", green); - cnts[2] = new cnt_item(this, "Fail", red); - cnts[3] = new cnt_item(this, "Error", red); - setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); -} - -void cnt_line::max(int m) { cnts[id_max]->value(m); } -void cnt_line::inc_ok() { cnts[id_ok]->inc(); } -void cnt_line::inc_fail() { cnts[id_fail]->inc(); } -void cnt_line::inc_error() { cnts[id_error]->inc(); } -void cnt_line::reset() -{ - for (int i = id_ok; i < n_id; ++i) - cnts[i]->value(0); -} - -res_stack::res_stack(const QString& txt, QWidget* par, const char* name) - : QVBox(par, name) -{ - cnts = new cnt_line(txt, this, name); - bar = new QProgressBar(this); - setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); -} -void res_stack::max(int v) -{ - cnts->max(v); - bar->setTotalSteps(v); -} -void res_stack::inc_progress(bool err) -{ - QPalette pal(bar->palette()); - QColorGroup cg(pal.active()); - QColor red(255,0,0); - QColor green(0,244,0); - cg.setColor(QColorGroup::Highlight, err ? red : green); - cg.setColor(QColorGroup::HighlightedText, black); - pal.setActive(cg); - pal.setInactive(cg); - pal.setDisabled(cg); - bar->setPalette(pal); - bar->setProgress(bar->progress()+1); -} -void res_stack::reset() { - cnts->reset(); - bar->setProgress(0); -} -void res_stack::inc_ok() { cnts->inc_ok(); inc_progress(false); } -void res_stack::inc_fail() { cnts->inc_fail(); inc_progress(true); } -void res_stack::inc_error() { cnts->inc_error(); inc_progress(true); } - -QHBox* behave(QHBox* box, bool x_expand, bool y_expand) -{ - box->setSizePolicy(QSizePolicy( - x_expand ? QSizePolicy::Preferred : QSizePolicy::Maximum, - y_expand ? QSizePolicy::Preferred : QSizePolicy::Maximum)); - box->setFrameShape(QFrame::StyledPanel); - box->setFrameShadow(QFrame::Raised); - box->setMargin(11); - box->setSpacing(6); - return box; -} - -void node::setImg() -{ - static QPixmap i_emp((const char**)img_empty); - static QPixmap i_ok((const char**)img_ok); - static QPixmap i_fail((const char**)img_fail); - static QPixmap i_err((const char**)img_error); - static QPixmap* imgs[] = { &i_emp, &i_ok, &i_fail, &i_err }; - item->setPixmap(0, *(imgs[st])); - if (st > is_ok) - for (QListViewItem* ip = item; ip != 0; ip = ip->parent()) - ip->setOpen(true); -}; - -node::node(suite_node* par, test& t) - : item(new QListViewItem(par->lvi(), t.name().c_str())), t(t), st(none) -{ - par->add_child(this); - setImg(); -} -node::node(gui* gp, test& t) - : item(new QListViewItem(gp->test_tree(), t.name().c_str())), t(t), st(none) -{ - setImg(); - item->setOpen(true); -} -void node::run() -{ - for (QListViewItem* ip=item->firstChild(); ip != 0; ip=item->firstChild()) - delete ip; - try { - t(); - status(is_ok); - emit ok(); - } catch (assertion_error& e) { - status(is_fail); - show_error(e); - emit fail(); - } catch (exception& e) { - status(is_error); - show_error(e.what()); - emit error(); - } catch (...) { - status(is_error); - show_error("unknown ... exception"); - emit error(); - } -} -void node::show_error(assertion_error& e) -{ -#ifdef HAVE_SSTREAM - ostringstream oss; - oss << e; - show_error(oss.str().c_str()); -#else - show_error(e.what()); // not well, but some sign -#endif -} -void node::show_error(const char* msg) -{ - QListViewItem* elvi = new QListViewItem(item, msg); - elvi->setSelectable(false); -} -suite_node::suite_node(suite_node* par, suite& t) : node(par, t) { } -suite_node::suite_node(gui* par, suite& t) : node(par, t) { } -void suite_node::run() -{ - status(is_ok); - for (cctyp::iterator p = cc.begin(); p != cc.end(); ++p) { - (*p)->run(); - status(max(status(), (*p)->status())); - } - switch (status()) { - case is_ok: emit ok(); break; - case is_fail: emit fail(); break; - case is_error: emit error(); break; - } -} -gui::gui(QApplication& app, QWidget* par, const char* name) - : QVBox(par, name), app(app) -{ - setMargin(6); - setSpacing(3); - tree = new QListView(behave(new QVBox(this), true, true), "tree"); - tree->addColumn("Test"); - tree->setFrameShadow(QListView::Sunken); - tree->setResizePolicy(QScrollView::Manual); - tree->setRootIsDecorated(true); - QVBox* f_cnts = new QVBox(this); - behave(f_cnts, true, false); - suites = new res_stack("Suites", f_cnts); - tests = new res_stack("Tests", f_cnts); - QHBox* hbox = behave(new QHBox(this), true, false); - b_run = new QPushButton("Run", hbox, "run"); - b_stop = new QPushButton("Stop", hbox, "stop"); - b_quit = new QPushButton("Quit", hbox, "quit"); - connect(b_quit, SIGNAL(clicked()), &app, SLOT(quit())); - connect(b_run, SIGNAL(clicked()), this, SLOT(run_pressed())); - connect(b_stop, SIGNAL(clicked()), this, SLOT(stop_pressed())); -} - -gui::~gui() { } - -void gui::processEvents(int t) -{ - app.processEvents(t); -} -void gui::reset() -{ - tests->reset(); - suites->reset(); -} -void gui::nconnect(node* n, res_stack* rs) -{ - connect(n, SIGNAL(ok()), rs, SLOT(inc_ok())); - connect(n, SIGNAL(fail()), rs, SLOT(inc_fail())); - connect(n, SIGNAL(error()), rs, SLOT(inc_error())); -} -void gui::add_test(node* n) -{ - nconnect(n, tests); -} -void gui::add_suite(node* n) -{ - nconnect(n, suites); -} - -void gui::totSuites(int v) { suites->max(v); } -void gui::totTests(int v) { tests->max(v); } - -#endif diff --git a/tests/lib/unit++/gui.h b/tests/lib/unit++/gui.h deleted file mode 100644 index 5a90ca38..00000000 --- a/tests/lib/unit++/gui.h +++ /dev/null @@ -1,166 +0,0 @@ -#ifndef __UNITPP_GUI_H -#define __UNITPP_GUI_H -#ifdef GUI -#include "tester.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/// \name unitpp -namespace unitpp { -/// A colored count with a unit. -class cnt_item : public QHBox -{ - Q_OBJECT -private: - int v; - QLabel* val; - QLabel* label; -public: - cnt_item(QWidget* par, const QString& txt, const QColor& col = black, - const char* nam = 0); -public slots: - void value(int v); - void inc(); -}; - -/// A line with total, ok, fail, and error counts. -class cnt_line : public QHBox -{ - Q_OBJECT -private: - enum fields { id_max, id_ok, id_fail, id_error, n_id }; - QLabel* label; - cnt_item* cnts[n_id]; -public slots: - void max(int v); - void reset(); - void inc_ok(); - void inc_fail(); - void inc_error(); -public: - cnt_line(const QString& txt, QWidget* par = 0, const char* name = 0); -}; - -/// A cnt_line stacked with a progress bar. -class res_stack : public QVBox -{ - Q_OBJECT -private: - cnt_line* cnts; - QProgressBar* bar; - void inc_progress(bool red); -public slots: - void max(int max); - void reset(); - void inc_ok(); - void inc_fail(); - void inc_error(); -public: - res_stack(const QString& txt, QWidget* par=0, const char* name=0); -}; -class node; -/// The whole GUI box with test tree, results, and buttons. -class gui : public QVBox -{ - Q_OBJECT -public: - gui(QApplication& app, QWidget* par = 0, const char* name = 0); - virtual ~gui(); - QListView* test_tree() { return tree; } - void add_test(node* n); - void add_suite(node* n); - void processEvents(int t); -signals: - void run(); - void stop(); -public slots: - void totSuites(int v); - void totTests(int v); - void reset(); -private slots: - void run_pressed() { emit run(); } - void stop_pressed() { emit stop(); } -private: - void nconnect(node* node, res_stack*); - QApplication& app; - QListView* tree; - res_stack* suites; - res_stack* tests; - QPushButton* b_run; - QPushButton* b_stop; - QPushButton* b_quit; -}; -class suite_node; -// a Qt error prevents this from being a ListViewItem... -/** - * A node in the test tree. An error in Qt prevents this to be derived from - * QListViewItem, hence the separation. - */ -class node : public QObject -{ - Q_OBJECT -public: - enum state { none, is_ok, is_fail, is_error }; - /// Create this node under par. - node(suite_node* par, test&); - /// Get the associated QListViewItem. - QListViewItem* lvi() { return item; } - /// - state status() { return st; } -signals: - /// [signal] emitted when the test succedes - void ok(); - /// [signal] emitted when the test fails - void fail(); - /// [signal] emitted when the test throws an exception - void error(); -public slots: - /// [slot] Make the test run, and emit appropriate signals. - virtual void run(); -protected: - /// Make a top level test, directly under the gui. - node(gui* par, test&); - /// Set the status of the node, including update of the displayed icon. - void status(state s) { - st = s; - setImg(); - } -private: - void show_error(assertion_error& e); - void show_error(const char*); - QListViewItem* item; - test& t; - state st; - void setImg(); -}; -/** - * A specialized node representing a test suite. - */ -class suite_node : public node -{ - typedef std::vector cctyp; - cctyp cc; // child container -public: - /// Inner suite creation. - suite_node(suite_node* par, suite&); - /// Top level suite_node. - suite_node(gui* par, suite&); - /// Test. - virtual void run(); - /// Register a node below this. - void add_child(node* n) { cc.push_back(n); } -}; -} -#endif -#endif diff --git a/tests/lib/unit++/guitester.cc b/tests/lib/unit++/guitester.cc deleted file mode 100644 index 34269af2..00000000 --- a/tests/lib/unit++/guitester.cc +++ /dev/null @@ -1,100 +0,0 @@ -#ifdef GUI -#include "optmap.h" -#include "main.h" -#include "guitester.h" -#include - -using namespace unitpp; -using namespace std; - -class gui_test_runner : public test_runner { - virtual bool run_tests(int argc, const char** argv) - { - QApplication a(argc, const_cast(argv)); - gui g(a); - g_setup setup(&g); - suite::main().visit(&setup); - a.setMainWidget(&g); - g.show(); - return a.exec(); - } -}; -class gui_flag : public options_utils::optmap::cmd { - bool do_cmd(options_utils::optmap* om) - { - static gui_test_runner gtr; - set_tester(>r); - return true; - } -}; -gui_hook::gui_hook() -{ - options().add("g", new gui_flag()); - options().alias("gui", "g"); -} - - -g_setup::g_setup(gui* gp) : gp(gp), running(false), n_suites(0), n_tests(0) -{ - connect(gp, SIGNAL(run()), this, SLOT(run())); -} -void g_setup::add_node(node* np) -{ - nodes.push_back(np); - rev[np->lvi()] = np; -} -void g_setup::visit(test& t) -{ - ++n_tests; - node* np = new node(branch.top(), t); - add_node(np); - gp->add_test(np); -} -void g_setup::visit(suite& t) -{ - ++n_suites; - suite_node* np = branch.size() ? new suite_node(branch.top(), t) - : new suite_node(gp, t); - branch.push(np); - add_node(np); - gp->add_suite(np); -} -void g_setup::visit(suite& t, int) -{ - branch.pop(); - if (!branch.size()) { - gp->totSuites(n_suites); - gp->totTests(n_tests); - } -} - -void g_setup::run() -{ - if (running) - return; - running = true; - selected.clear(); - find_selected(gp->test_tree()->firstChild()); - if (!selected.size()) - selected.push_back(rev[gp->test_tree()->firstChild()]); - gp->reset(); - for (vector::iterator p = selected.begin(); p!=selected.end(); ++p) { - (*p)->run(); - gp->processEvents(20); - if (!running) - break; - } - running = false; -} - -void g_setup::find_selected(QListViewItem* lvi) -{ - if (!lvi) - return; - if (lvi->isSelected()) - selected.push_back(rev[lvi]); - else - find_selected(lvi->firstChild()); - find_selected(lvi->nextSibling()); -} -#endif diff --git a/tests/lib/unit++/guitester.h b/tests/lib/unit++/guitester.h deleted file mode 100644 index aa241db4..00000000 --- a/tests/lib/unit++/guitester.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __UNITPP__GUITESTER_H -#define __UNITPP__GUITESTER_H -#ifdef GUI -#include "tester.h" -#include "gui.h" -#include -#include -#include - -/// \name unitpp -namespace unitpp { -/** - * The class for setting up the GUI. It visites all the tests, and create - * nodes for them in the test tree, count them and adjust all the GUI - * elements appropriately. - */ -class g_setup : public QObject, public visitor { - Q_OBJECT -private: - gui* gp; - bool running; - int n_suites; - int n_tests; - std::stack branch; - std::vector nodes, selected; - std::map rev; - void find_selected(QListViewItem*); - void add_node(node* np); -public: - g_setup(gui* gp); - virtual void visit(test&); - virtual void visit(suite&); - virtual void visit(suite&, int); -public slots: - /// - void run(); -}; -} -#endif -#endif diff --git a/tests/lib/unit++/main.cc b/tests/lib/unit++/main.cc deleted file mode 100644 index 262e0553..00000000 --- a/tests/lib/unit++/main.cc +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#include "main.h" -#include -using namespace std; -using namespace unitpp; - -bool unitpp::verbose = false; - -test_runner* runner = 0; - -test_runner::~test_runner() -{ -} - -void unitpp::set_tester(test_runner* tr) -{ - runner = tr; -} - -int main(int argc, const char* argv[]) -{ - options().add("v", new options_utils::opt_flag(verbose)); - options().alias("verbose", "v"); - if (!options().parse(argc, argv)) - options().usage(); - plain_runner plain; - if (!runner) - runner = &plain; - return runner->run_tests(argc, argv) ? 0 : 1; -} - -namespace unitpp { -options_utils::optmap& options() -{ - static options_utils::optmap opts("[ testids... ]"); - return opts; -} - -bool plain_runner::run_tests(int argc, const char** argv) -{ - bool res = true; - if (options().n() < argc) - for (int i = options().n(); i < argc; ++i) - res = res && run_test(argv[i]); - else - res = run_test(); - return res; -} - -bool plain_runner::run_test(const string& id) -{ - test* tp = suite::main().find(id); - if (!tp) { - return false; - } - return run_test(tp); -} -bool plain_runner::run_test(test* tp) -{ - tester tst(cout, verbose); - tp->visit(&tst); - tst.summary(); - res_cnt res(tst.res_tests()); - return res.n_err() == 0 && res.n_fail() == 0; -} - -} - diff --git a/tests/lib/unit++/main.h b/tests/lib/unit++/main.h deleted file mode 100644 index 3a871c52..00000000 --- a/tests/lib/unit++/main.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#include -#include "tester.h" -#include "optmap.h" - -/** - * The main of a test program that executes the main test suite and then - * reports the summary. - * - * A #-v# or #--verbose# will turn on verbose, that reports succesful test - * cases; the default behaviour is to report only those that fails. - */ -int main(int argc, const char* argv[]); - -/// @name{unitpp} -namespace unitpp { - -/** - * The verbose flag, in case somebody wants to piggyback it with more - * meaning. - */ -extern bool verbose; - -/** - * A runner is the base class for the objects that actually processes the - * tests from main. Main simply invokes the run_tests method of the current - * test runner. - * \Ref{main} - */ -class test_runner { -public: - virtual ~test_runner(); - /** - * run all the tests with arguments in the argc, argv set - */ - virtual bool run_tests(int argc, const char** argv) = 0; -}; -/** - * Sets the test_runner to be used in testing. This hook allows another - * tester to hook into the main function and replace the traditional tester. - */ -void set_tester(test_runner*); - -/// A plain test runner for the ordinary text version. -class plain_runner : public test_runner { -public: - /// Run the tests specified in argv, starting at i. - virtual bool run_tests(int argc, const char** argv); -private: -/** - * Run a test found in the suite::main() test by id. If id is empty run the - * main test. - * @name run_test-id - * @return true, if the test was totally succesful. - */ -bool run_test(const std::string& id = ""); -/// Run the test and return true if succesful. @see{run_test-id} -bool run_test(test*); -/// find the test with the given id -test* find_test(const std::string& id); -}; -} diff --git a/tests/lib/unit++/optmap-compat.h b/tests/lib/unit++/optmap-compat.h deleted file mode 100644 index 13d98fcf..00000000 --- a/tests/lib/unit++/optmap-compat.h +++ /dev/null @@ -1,4 +0,0 @@ -// This header preserves compatibility with old unit++ versions. -// -// Use of this is deprecated, use unit++/optmap.h directly -#include diff --git a/tests/lib/unit++/optmap.cc b/tests/lib/unit++/optmap.cc deleted file mode 100644 index 9e65d849..00000000 --- a/tests/lib/unit++/optmap.cc +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#include -#include -#include "optmap.h" - -using namespace std; -using namespace options_utils; - -optmap::optmap(const char* usage) -: i(1), prog("program"), tail(usage) -{ -} - -optmap::~optmap() -{ - for (group_t::iterator p = group.begin(); p != group.end(); ++p) - delete p->first; -} -optmap& optmap::add(const char* c, cmd* h) -{ - if (cmds.find(c) != cmds.end()) - throw invalid_argument(string("duplicated option: ")+c); - cmds[c] = h; - if (group[h].size() == 0) - gvec.push_back(h); - group[h].push_back(c); - return *this; -} - -optmap& optmap::alias(const char* new_opt, const char* old_opt) -{ - cmd* h = cmds[old_opt]; - if (!h) - throw invalid_argument(string("no alias: ")+old_opt); - return add(new_opt, h); -} -bool optmap::parse(int c, const char** v) -{ - argc = c; - argv = v; - prog = argv[0]; - for (; i < argc; ++i) { - multichar = false; - const char* s = argv[i]; - size_t l = strlen(s); - if (*s != '-' || l == 1) - return true; - if (s[1] == '-') { - if (l == 2) { // end of options marker `--' - ++i; - return true; - } - if (!do_cmd(s+2)) - return false; - } else { - char cmd[2]; - cmd[1] = '\0'; - multichar = l > 2; - first_multi = true; - for (const char* p = s+1; *p; ++p) { - cmd[0] = *p; - if (!do_cmd(cmd)) - return false;; - first_multi = false; - if (!multichar) // get_arg used it - break; - } - } - } - return true; -} - -const char* optmap::get_arg() -{ - if (multichar) { - if (!first_multi) { - cerr << "internal option requires argument " << argv[i] << endl; - return 0; - } - multichar = false; - return argv[i]+2; - } - return i < argc - 1 ? argv[++i] : 0; -} - -void optmap::usage(bool abort) -{ - cerr << "usage: " << prog; - for (gvec_t::iterator p = gvec.begin(); p != gvec.end(); ++p) { - cmd* h = *p; - vector& v(group[h]); - string arg = h->arg(); - bool need_par = arg.size() > 0 && v.size() > 1; - bool first = true; - cerr << " ["; - if (need_par) - cerr << "("; - for (vector::iterator s = v.begin(); s != v.end(); ++s) { - cerr << (first ? " " : " | ") << (s->size() != 1 ? "--":"-") << *s; - first = false; - } - if (need_par) - cerr << ")"; - if (arg.size()) - cerr << ' ' << arg; - cerr << " ]"; - } - cerr << (tail.size() ? " " : "") << tail << endl; - if (abort) - exit(1); -} - -bool optmap::do_cmd(const string& opt) -{ - cmd* c = cmds[opt]; - if (!c) { - cerr << "unknown option: " << opt << endl; - return false; - } - return c->do_cmd(this); -} - -bool opt_int::do_cmd(optmap* om) -{ - const char* arg = om->get_arg(); - if (!arg) - return false; - char* end; - int v = strtol(arg, &end, 10); - if (*end) { - cerr << "failed to parse int argument: " << arg << endl; - return false; - } - val = v; - return true; -} -bool opt_string::do_cmd(optmap* om) -{ - const char* arg = om->get_arg(); - if (!arg) - return false; - val = arg; - return true; -} diff --git a/tests/lib/unit++/optmap.h b/tests/lib/unit++/optmap.h deleted file mode 100644 index 52122797..00000000 --- a/tests/lib/unit++/optmap.h +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#ifndef __UNITPP__OPTMAP_H -#define __UNITPP__OPTMAP_H -#include -#include -#include -#include -/** - * The home of \Ref{optmap}. This is a unified way of handling commang line - * arguments, and suitable usage replies when things goes badly. - */ -namespace options_utils { -/** - * A argument option handler, based on the Command pattern. Each option is - * associated with a handling command object. - * - * The map keeps the reverse association as well, to allow printing of a - * using line. - */ -class optmap { -public: - /** - * The base for all option handlers. - * - * To handle a new kind of commands, just derive a class from this an - * overload the methods to do the work. - */ - struct cmd { - /** - * Performing the work associated with the option. - * - * To obtain an argument see \Ref{get_arg} - * @return true if the parsing was succesfull - */ - virtual bool do_cmd(optmap* om) = 0; - /// return the name of the argument needed by \Ref{usage} - virtual std::string arg() { return std::string(); } - virtual ~cmd() {} - }; - /** - * The very simple constructor for an optmap object. Please note that - * copying of optmaps are not supported. - * @param usage The tail of the usage string to follow the options - */ - optmap(const char* usage = ""); - ~optmap(); - /** - * Adds an option that invokes the command handler. - * - * This is the low level work horse for all the add methods. All the - * other adds works by adding appropriate cmd objects for doing the work. - * - * @param o - * The option name. If the length of the option is 1 it will be an old - * fashion option, otherwise it will be a GNU stype long option - * (--long-opt). - * @param h - * The pointer to the handler. The optmap assumes ownership of the - * pointer and delete it in the destructor. - * - * @return *this - */ - optmap& add(const char* o, cmd* h); - /// Adds an alias for an option. - optmap& alias(const char* new_opt, const char* old_opt); - /** - * Parse the command line. - * @return true if the parse is valid, false otherwise. - */ - bool parse(int argc, const char** argv); - /// Gets the index for the first non option argument - int n() { return i; } - /// display a usage string and abort() - void usage(bool abort = true); - /// get the argument of an option; mainly for cmd implementations. - const char* get_arg(); -private: - int i; - const char* prog; - int argc; - const char** argv; - bool multichar; // doing a multichar, -pdf --> -p -d -f - bool first_multi; - optmap(const optmap& o); - optmap& operator=(const optmap&); - bool do_cmd(const std::string& opt); - std::string tail; - typedef std::map cmds_t; - cmds_t cmds; - typedef std::vector gvec_t; - gvec_t gvec; - typedef std::map > group_t; - group_t group; -}; - -/// A cmd handler that can set a boolean flag. -class opt_flag : public optmap::cmd { - bool& flg; -public: - /// Just give it the bool you want set if the flag is present. - opt_flag(bool& flg) : flg(flg) {} - virtual bool do_cmd(optmap*) { flg = true; return true; } -}; - -/// A cmd handler that can get an integer value. -class opt_int : public optmap::cmd { - int& val; -public: - /// just give it an int variable that the flag argument can be assigned to. - opt_int(int& val) : val(val) {} - virtual bool do_cmd(optmap* om); - virtual std::string arg() { return std::string(""); } -}; -/// A cmd handler for a string -class opt_string : public optmap::cmd { - std::string& val; -public: - /// Give it a string that the flag arg should be assigned to. - opt_string(std::string& val) : val(val) {} - virtual bool do_cmd(optmap* om); - virtual std::string arg() { return std::string(""); } -}; -} -#endif diff --git a/tests/lib/unit++/tester.cc b/tests/lib/unit++/tester.cc deleted file mode 100644 index f4b65acd..00000000 --- a/tests/lib/unit++/tester.cc +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#include -#include -#include "tester.h" -using namespace std; - -using namespace unitpp; - -void tester::summary() -{ - os << "Tests [Ok-Fail-Error]: [" << n_test.n_ok() << '-' - << n_test.n_fail() << '-' << n_test.n_err() << "]\n"; -} -void tester::visit(test& t) -{ - try { - t(); - n_test.add_ok(); - write(t); - } catch (assertion_error& e) { - n_test.add_fail(); - write(t, e); - } catch (exception& e) { - n_test.add_err(); - write(t, e); - } catch (...) { - n_test.add_err(); - write(t, 0); - } -} - -void tester::visit(suite& t) -{ - if (verbose) - os << "****** " << t.name() << " ******" << endl; - accu.push(n_test); -} - -void tester::visit(suite& , int) -{ - res_cnt r(accu.top()); - accu.pop(); - if (n_test.n_err() != r.n_err()) - n_suite.add_err(); - else if (n_test.n_fail() != r.n_fail()) - n_suite.add_fail(); - else - n_suite.add_ok(); -} -void tester::write(test& t) -{ - if (verbose) - disp(t, "OK"); -} -void tester::disp(test& t, const string& status) -{ - os << status << ": " << t.name() << endl; -} -void tester::write(test& t, assertion_error& e) -{ - disp(t, "FAIL"); - os << e << '\n'; -} -void tester::write(test& t, std::exception& e) -{ - disp(t, "ERROR"); - os << " : [" << typeid(e).name() << "] " << e.what() << '\n'; -} -void tester::write(test& t, int ) -{ - disp(t, "ERROR"); - os << " : " << "unknown exception" << '\n'; -} diff --git a/tests/lib/unit++/tester.h b/tests/lib/unit++/tester.h deleted file mode 100644 index 673ea559..00000000 --- a/tests/lib/unit++/tester.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#ifndef _UNITPP_TESTER_H -#define _UNITPP_TESTER_H -#include -#ifdef __UNITPP -#include "unit++.h" -#else -#include -#endif -namespace unitpp { -/// A mostly internal class for keeping score. -class res_cnt { - int ok, fail, err; -public: - /// Create a 0 count. - res_cnt() : ok(0), fail(0), err(0) {} - /// Count one ok. - void add_ok() { ++ok; } - /// Count one fail. - void add_fail() { ++fail; } - /// Count one error. - void add_err() { ++err; } - /// get ok count. - int n_ok() { return ok; } - /// get fail count. - int n_fail() { return fail; } - /// get error count. - int n_err() { return err; } - /// get total count. - int n() { return ok+fail+err; } -}; -/** - * The standard text based tester. It implements the visitor pattern for the - * test and suite classes, and executes each test case in a depth first - * traversal, toting the score of test cases. - * - * The class might be used for test executers aimed at other environments, - * e.g. a GUI based version. - * - * Please note that this class is automagically instantiated by the main - * method supplied in the library. This means that you might very well do all - * your testing without directly laying hans on this fellow. - */ -class tester : public visitor { - std::ostream& os; - bool verbose; // list succeded tests - std::stack accu; - res_cnt n_suite, n_test; - void disp(test& t, const std::string&); - void write(test& t); - void write(test& t, assertion_error& e); - void write(test& t, std::exception& e); - void write(test& t, int dummy); -public: - /** - * Create a text tester. - * \param os the stream to write results to. - * \param verbose whether to report on succesful tests - */ - tester(std::ostream& os, bool verbose = false) : os(os), verbose(verbose) {} - /// Get the score for tests - res_cnt res_tests() { return n_test; } - /// Get the score for suites - res_cnt res_suites() { return n_suite; } - /// Write the summary - virtual void summary(); - /// Part of the visitor pattern. - virtual void visit(test&); - /// Part of the visitor pattern. - virtual void visit(suite&); - /// Part of the visitor pattern; visit to suite after children. - virtual void visit(suite& t, int); -}; - -} -#endif diff --git a/tests/lib/unit++/unit++-compat.h b/tests/lib/unit++/unit++-compat.h deleted file mode 100644 index 7e91558b..00000000 --- a/tests/lib/unit++/unit++-compat.h +++ /dev/null @@ -1,4 +0,0 @@ -// This header preserves compatibility with old unit++ versions. -// -// Use of this is deprecated, use unit++/unit++.h directly -#include diff --git a/tests/lib/unit++/unit++.1 b/tests/lib/unit++/unit++.1 deleted file mode 100644 index d5895000..00000000 --- a/tests/lib/unit++/unit++.1 +++ /dev/null @@ -1,27 +0,0 @@ -.hy 0 -.if n .na -.TH UNIT++ 1 2002-02-23 "Unit++ 1.2" -.UC -.SH NAME -\fBunit++\fB \- run a set of tests -.SH SYNOPSIS -.BI "unit++ [-v|--verbose] [-g|--gui] [testid...] -.SH DESCRIPTION -.B unit++ -(the usual name) is the resulting program from compiling a set of unit++ -tests, and linking them with the -.B unit++(3) -library supplied main function to obtain an executable test suite. - -Each test in the test tree has an id, and it is possible to start only some -of the tests by naming them in the form id1.id2.id3. - -The GUI option is only available if the library was compiled with GUI -support, and the tests has actually linked the GUI stuff as well. Otherwise -the -g option will provoke an error. Otherwise it will give a Qt based GUI -that allows running of individual tests, with a nice green (or less nice red) -bar that shows success (or failure). -.SH AUTHOR -Claus Dręby -.SH SEE ALSO -.BR unit++ (3). diff --git a/tests/lib/unit++/unit++.3 b/tests/lib/unit++/unit++.3 deleted file mode 100644 index 518a14df..00000000 --- a/tests/lib/unit++/unit++.3 +++ /dev/null @@ -1,130 +0,0 @@ -.hy 0 -.if n .na -.TH UNIT++ 3 2002-02-23 "Unit++ 1.2" -.UC -.SH NAME -\fBunit++\fB: \fBtest\fB, \fBsuite\fb, \fBtestcase\fB \- test framework for C++. -.SH SYNOPSIS -.B #include -.br -.B using namespace unitpp; -.br -.B using namespace std; -.sp -.BI "test::test(string " name ); -.sp -.B virtual void test::operator()(); -.sp -.B class suite : public test -.sp -.BI "suite::suite(string " name ); -.sp -.BI "static suite& suite::main();" -.sp -.BI "void suite::add(const string& " id ", const testcase& " t ); -.sp -.BI "template " -.br -.BI " testcase::testcase(" C "* " par ", const string& " name ", " -.br -.BI " typename test_mfun<" C ">::mfp " fp ");" -.sp -.BI "testcase::testcase(test* " t ); -.sp -.BI "fail(const string& " msg ); -.sp -.BI "template " -.br -.BI " void assert_true(const string& " msg ", " A " " assertion ); -.sp -.BI "template " -.br -.BI " void assert_eq(const string& " msg ", " T1 " " exp ", " T2 " " got ); -.sp -.BI "gui_hook::gui_hook();" -.SH LIBRARIES -.B -lunit++ -.SH DESCRIPTION -.B unit++ -is a fremework that allows creation and execution of C++ unit tests. Each -test is an instance of the -.B test -class, and is managed by an instance of the -.B testcase -class. The actual takes place by invoking each test as function, that is -calling the virtual operator(). However, the usual way of making tests is by -using a class derived from the -.B suite -class to wrap a number of releated tests, Each test then -becomes a member function in the class, and the testcase instance is -constructed by using the -.B member function template constructor. - -Each test suite class is usually placed in an anonymous namespace to allow -the all to be named Test, as in the example below. Since the -.B main -method of the library runs a global test suite each suite must add itself to -this global tree. This is done by invoking -.B add -on the test suite object obtained by -.B suite::main(). - -The assert templates allows the tests to check conditions; -.B assert_true -checks a truth value, that is it fails if ! -.I assertion -evaluates to true; -.B assert_eq asserts equality by use of == between two objects, both of which -must be of types that can be written to a stream by use of <<. -.B fail -simply fails a test. - -The -.B gui_hook -class is the hook for allowing a test to use the Qt gui for the test program. -A test program must have exactly one global object of type gui_hook in order -to enable the gui, Even when compiled without gui support, creating a -gui_hook is ok, but it will only have effect if gui support was enabled when -the library was compiled. -.SH EXAMPLES -.nf -#include -using namespace std; -using namespace unitpp; -namespace { - class Test : public suite - { - char* p = "Hej"; - string s("mor"); - void t1() - { - assert_true("pointer is not 0", p); - } - void t2() - { - assert_eq("Texts match", string("Mor"), s); - } - public: - Test() : suite("Yet another test suite") - { - suite::main().add("demo", this); - add("t1", testcase(this, "T1", &Test::t1)); - add("t2", testcase(this, "T2", &Test::t2)); - } - } * theTest = new Test(); -} -.fi -.SH NOTE -Each test suite runs all its tests in the same instance. That means that the -above example will invoke first t1 and then t2 in the same object. Hence any -side effects on the Test object that a test function has survives to the -subsequent tests in the same object. This behaviour is directly opposite to -how the original unit test framework junit treats test suites. There are -however compelling C++ reasons why it must be so, and once known it might -even be used to an advantage from time to time. -.SH AUTHOR - -Claus Dręby - -.SH SEE ALSO -.BR unit++ (1). diff --git a/tests/lib/unit++/unit++.cc b/tests/lib/unit++/unit++.cc deleted file mode 100644 index c7c13372..00000000 --- a/tests/lib/unit++/unit++.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#include -#include -#include "unit++.h" - -using namespace unitpp; -using namespace std; - -#ifndef GUI -gui_hook::gui_hook() { } -#endif -void test::visit(visitor* v) -{ - v->visit(*this); -} -testcase::testcase(test* t) -: cnt(new size_t(1)), tst(t) -{ -} -testcase::testcase(const testcase& t) -: cnt(t.cnt), tst(t.tst) -{ - (*cnt)++; -} -void testcase::dec_cnt() -{ - if (--(*cnt) == 0) { - delete cnt; - delete tst; - } -} -testcase::~testcase() -{ - dec_cnt(); -} -testcase& testcase::operator=(const testcase& t) -{ - ++*(t.cnt); - dec_cnt(); - cnt = t.cnt; - tst = t.tst; - return *this; -} -suite& suite::main() -{ - static suite instance("top"); - return instance; -} -test* suite::get_child(const string& id) -{ - vector::iterator p = std::find(ids.begin(), ids.end(), id); - if (p != ids.end()) - return &(static_cast(tests[p - ids.begin()])); - return 0; -} -vector unitpp::vectorize(const string& str, char c) -{ - vector res; - string::const_iterator s, p; - for (s = str.begin(); s != str.end(); ) { - p = find(s, str.end(), c); - res.push_back(string(s, p)); - s = (p == str.end()) ? p : p + 1; - } - return res; -} -test* suite::find(const string& id) -{ - vector ss(vectorize(id, '.')); - test* tp = this; - for (vector::iterator p = ss.begin(); p != ss.end(); ++p) - if (!(tp = tp->get_child(*p))) - break; - return tp; -} -void suite::add(const string& id, const testcase& t) -{ - ids.push_back(id); - tests.push_back(t); -} -void suite::visit(visitor* v) -{ - v->visit(*this); - for_each(tests.begin(), tests.end(), - bind2nd(mem_fun_ref(&testcase::visit), v)); - v->visit(*this, 0); -} - -void unitpp::assertion_error::out(ostream& os) const -{ - os << msg << string(" [assertion failed]"); -} diff --git a/tests/lib/unit++/unit++.h b/tests/lib/unit++/unit++.h deleted file mode 100644 index 68483e78..00000000 --- a/tests/lib/unit++/unit++.h +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright (C) 2001 Claus Dręby -// Terms of use are in the file COPYING -#ifndef __TEST_FW_H_ -#define __TEST_FW_H_ -#include -#include -#include -#include -#include "optmap.h" -/** - * The unitpp name space holds all the stuff needed to use the unit++ testing - * framework. - * - * The normal way to make a test is like this: - * -\begin{verbatim} -#include -using namespace unitpp; -// use anonymous namespace so all test classes can be named Test -namespace { -class Test : public suite { - void test1() - { - // do test stuff - assert_true("message", exp1); // exp1 should be true - assert_eq("another msg", 123456, exp2); // exp2 should be 123456 - // ... - } - void test2() - { - // do something that provokes exception out_of_range - } -public: - Test() : suite("appropriate name for test suite") - { - // any setup you need - add("id1", testcase(this, "Test 1", &Test::test1)); - // make a testcase from the method - testcase tc(this, "Test 2", &Test::test2); - // add a testcase that expects the exception - add("id2", exception_case(tc)); - // add the suite to the global test suite - suite::main().add("id", this); - } -} * theTest = new Test(); // by new, since testcase claims ownership -} -\end{verbatim} - * - * In order to make an executable test, simply link the above code against - * libunit++, something like - * - * #g++ -o test++ mytest.cc -L -lunit++# - * - * This will generate a test called #test++# and the standard behaviour for a - * test. Note that most shells have #test# defined as a shell builtin which - * makes it a moderately bad name for a program, since it is rather hard to - * get executed, hence #test++#. - * @see main - */ -namespace unitpp { - -class visitor; -/** - * The heart of a test system: A test. The test is meant as a base class for - * the tests that a client want performed. This means that all tests are to - * be pointers dynamically allocated. However, the test system takes - * responsibilities for freeing them again. - * - * The function call overload mechanism is used for the executable part of - * the test. - */ -class test { - std::string nam; -public: - /// A test just needs a name - test(const std::string& name) : nam(name) {} - virtual ~test() {} - /// The execution of the test - virtual void operator()() = 0; - virtual void visit(visitor*); - virtual test* get_child(const std::string&) { return 0; } - std::string name() const { return nam; } -}; - -/** - * A test that is implemented by a member function. - */ -template -class test_mfun : public test { -public: - typedef void (C::*mfp)(); - /// An object, a name, and a pointer to a member function. - test_mfun(C* par, const std::string& name, mfp fp) - : test(name), par(par), fp(fp) - {} - /// Executed by invoking the function in the object. - virtual void operator()() - { - (par->*fp)(); - } -private: - C* par; - mfp fp; -}; - -/** - * A ref counted reference to a test. This is what test suites are composed - * of, and what ensures destruction. - */ -class testcase { - size_t* cnt; - test* tst; - void dec_cnt(); -public: - /// Simply wrap -- and own -- a test. - testcase(test* t); - /// Keep the ref count - testcase(const testcase& tr); - /** - * Make a testcase from a class and a member function. - * - * The normal usage is inside some test suite class Test: - * - * #add("id", testcase(this, "Testing this and that", &Test::test))# - * - * to make a test that invokes the test method on the instance of the - * suite class. - * \Ref{test_mfun} - */ - template - testcase(C* par, const std::string& name, typename test_mfun::mfp fp) - : cnt(new size_t(1)), tst(new test_mfun(par, name, fp)) - { } - ~testcase(); - /// Assignment that maintains reference count. - testcase& operator=(const testcase&); - void visit(visitor* vp) const { tst->visit(vp); } - operator test& () { return *tst; } - operator const test& () const { return *tst; } -}; - -/** - * A wrapper class for the testcase class that succedes if the correct - * exception is generated. - */ -template -class exception_test : public test { -public: - /** - * The constructor needs a testcase to wrap. This exception_test will - * fail unless the wrapped testcase generates the exception. - * - * The name of the exception_test is copied from the wrapped test. - */ - exception_test(const testcase& tc) - : test(static_cast(tc).name()), tc(tc) {} - ~exception_test() {} - /// Runs the wrapped test, and fails unless the correct exception is thrown. - virtual void operator()(); -private: - testcase tc; -}; -/** - * Generate a testcase that expects a specific exception from the testcase it - * wraps. It can be used something like - * - * #testcase tc(this, "Test name", &Test::test);# - * - * #add("ex", exception_case(tc));# - * - * The name of the exception_case is copied from the wrapped testcase, and - * the exception_case will execute the tc test case and report a failure - * unless the #out_of_range# exception is generated. - */ -template -testcase exception_case(const testcase& tc) -{ - return testcase(new exception_test(tc)); -} - -/** - * Splits the string by char c. Each c will generate a new element in the - * vector, including leading and trailing c. - */ -extern std::vector vectorize(const std::string& str, char c); - -/** - * A suite is a test that happens to be a collection of tests. This is an - * implementation of the Composite pattern. - */ -class suite : public test { - std::vector ids; - std::vector tests; -public: - /// Make an empty test suite. - suite(const std::string& name) : test(name) {} - virtual ~suite() {}; - /// Add a testcase to the suite. - void add(const std::string& id, const testcase& t); - /** - * Get a child with the specified id. - * @return 0 if not found. - */ - virtual test* get_child(const std::string& id); - /// An empty implementation. - virtual void operator()() {} - /// Allow a visitor to visit a suite node of the test tree. - void visit(visitor*); - /// Get a reference to the main test suite that the main program will run. - static suite& main(); - // Splits the string by dots, and use each id to find a suite or test. - test* find(const std::string& id); -}; - -/** - * The visitor class is a base class for classes that wants to participate in - * the visitor pattern with the test hierarchi. - * - * This is a slightly extended visitor pattern implementation, intended for - * collaboration with the Composite pattern. The aggregate node (here the - * suite node) is visited twice, before and after the children are visited. - * This allows different algorithms to be implemented. - */ -class visitor { -public: - virtual ~visitor() {} - /// Visit a test case, that is not a suite. - virtual void visit(test&) = 0; - /// Visit a suite node before the children are visited. - virtual void visit(suite&) {}; - /** - * Visit a suite after the children are visited - */ - virtual void visit(suite&, int dummy) = 0; // post childs -}; - -/// The basic for all failed assert statements. -class assertion_error : public std::exception -{ - std::string msg; -public: - /// An assertion error with the given message. - assertion_error(const std::string& msg) : msg(msg) {} - /// - std::string message() const { return msg; } - virtual ~assertion_error() throw () {} - /** - * The virtual method used for operator<<. - */ - virtual void out(std::ostream& os) const; -}; -/** - * This exception represents a failed comparison between two values of types - * T1 and T2. Both the expected and the actually value are kept. - */ -template -class assert_value_error : public assertion_error -{ - T1 exp; - T2 got; -public: - /// Construct by message, expected and gotten. - assert_value_error(const std::string& msg, T1& exp, T2& got) - : assertion_error(msg), exp(exp), got(got) - { - } - virtual ~assert_value_error() throw () {} - /** - * Specialized version that requires both T1 and T2 to support - * operator<<(ostream&, Tn). - */ - virtual void out(std::ostream& os) const - { - os << message() << " [expected: `" << exp << "' got: `" << got << "']"; - } -}; -/// The test was not succesful. -inline void fail(const std::string& msg) -{ - throw assertion_error(msg); -} -template -void exception_test::operator()() -{ - try { - (static_cast(tc))(); - fail("unexpected lack of exception"); - } catch (E& ) { - // fine! - } -} -/// Assert that the assertion is true, that is fail #if (!assertion) ...# -template inline void assert_true(const std::string& msg, A assertion) -{ - if (!assertion) - throw assertion_error(msg); -} -/// Assert that the two arguments are equal in the #==# sense. -template - inline void assert_eq(const std::string& msg, T1 exp, T2 got) -{ - if (!(exp == got)) - throw assert_value_error(msg, exp, got); -} -/* - * Put an assertion error to a stream, using the out method. The out method - * is virtual. - */ -inline std::ostream& operator<<(std::ostream& os, const unitpp::assertion_error& a) -{ - a.out(os); - return os; -} - -/** - * The singleton instance of the option handler of main. - * - * This allows a test to add its own flags to the resulting test program, in - * the following way. - * - * #bool x_flg = false;# - * #unitpp::options().add("x", new options_utils::opt_flag(x_flg));# - * - * If a -x is now given to the resulting test it will set the #x_flg# - * variable; - */ -options_utils::optmap& options(); - -/** - * An instance of this class hooks the GUI code into the test executable. - * Hence, make a global variable of class gui_hook to allow the -g option to - * a test. - * - * If the library is compiled without GUI support, it is still legal to - * create an instance of gui_hook, but it will not add the -g option. - */ -class gui_hook { -public: - gui_hook(); -}; - -} - -#endif diff --git a/tests/lib/unit++/unitpp.m4 b/tests/lib/unit++/unitpp.m4 deleted file mode 100644 index b9c5a07e..00000000 --- a/tests/lib/unit++/unitpp.m4 +++ /dev/null @@ -1,59 +0,0 @@ -dnl AM_PATH_UNITPP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl note to self - reference vars with $1, $2 etc - -AC_DEFUN(AM_PATH_UNITPP, -[ - AC_LANG_PUSH(C++) - - AC_ARG_ENABLE(unitpp, - AC_HELP_STRING([--enable-unitpp-test], - [enable unit tests (default is YES if you have libunit++, else NO)]), - , - [enable_unitpp="yes"] ) - - AC_ARG_WITH(unitpp-prefix, - AC_HELP_STRING([--with-unitpp-prefix=DIR], - [specify the location of unit++ for unit tests]) ) - - if test "x$with_unitpp_prefix"="x"; then - UNITPP_CXXFLAGS="-I$with_unitpp_prefix/include" - UNITPP_LIBS="-L$with_unitpp_prefix/lib -lunit++" - else -# UNITPP_CXXFLAGS="-I/usr/local/include" - UNITPP_LIBS="-lunit++" - fi - CXXFLAGS="$CXXFLAGS $UNITPP_CXXFLAGS" - LIBS="$LIBS $UNITPP_LIBS" - - if test $enable_unitpp="yes"; then - AC_CHECK_HEADER(unit++/unit++.h, - [ac_check_unitpp="yes"], - [ac_check_unitpp="no"] ) - - if test $ac_check_unitpp="yes"; then - AC_MSG_CHECKING(if unit++ test program compiles) - AC_TRY_LINK( - [ #include ], - [ unitpp::test* test_test = new unitpp::suite("Test Suite"); ], - [ac_check_unitpp="yes" - AC_MSG_RESULT(yes) ], - [ac_check_unitpp="no" - AC_MSG_RESULT(no) ] ) - fi - else - ac_check_unitpp="yes" - fi - - if test $ac_check_unitpp="yes"; then - ifelse([$1], , :, [$1]) - else - UNITPP_CXXFLAGS="" - UNITPP_LIBS="" - ifelse([$2], , :, [$2]) - fi - - AC_LANG_POP(C++) - - AC_SUBST(UNITPP_CXXFLAGS) - AC_SUBST(UNITPP_LIBS) -]) diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp index ffbdefda..0591e4d1 100644 --- a/tests/parser/bodyPartTest.cpp +++ b/tests/parser/bodyPartTest.cpp @@ -17,77 +17,61 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class bodyPartTest : public suite +#define VMIME_TEST_SUITE bodyPartTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testParse) + VMIME_TEST(testGenerate) + VMIME_TEST_LIST_END + + + static const vmime::string extractComponentString + (const vmime::string& buffer, const vmime::component& c) { - static const vmime::string extractComponentString - (const vmime::string& buffer, const vmime::component& c) - { - return vmime::string(buffer.begin() + c.getParsedOffset(), - buffer.begin() + c.getParsedOffset() + c.getParsedLength()); - } + return vmime::string(buffer.begin() + c.getParsedOffset(), + buffer.begin() + c.getParsedOffset() + c.getParsedLength()); + } - void testParse() - { - vmime::string str1 = "HEADER\r\n\r\nBODY"; - vmime::bodyPart p1; - p1.parse(str1); + void testParse() + { + vmime::string str1 = "HEADER\r\n\r\nBODY"; + vmime::bodyPart p1; + p1.parse(str1); - assert_eq("1", "HEADER\r\n\r\n", extractComponentString(str1, *p1.getHeader())); - assert_eq("2", "BODY", extractComponentString(str1, *p1.getBody())); + VASSERT_EQ("1", "HEADER\r\n\r\n", extractComponentString(str1, *p1.getHeader())); + VASSERT_EQ("2", "BODY", extractComponentString(str1, *p1.getBody())); - vmime::string str2 = "HEADER\n\nBODY"; - vmime::bodyPart p2; - p2.parse(str2); + vmime::string str2 = "HEADER\n\nBODY"; + vmime::bodyPart p2; + p2.parse(str2); - assert_eq("3", "HEADER\n\n", extractComponentString(str2, *p2.getHeader())); - assert_eq("4", "BODY", extractComponentString(str2, *p2.getBody())); + VASSERT_EQ("3", "HEADER\n\n", extractComponentString(str2, *p2.getHeader())); + VASSERT_EQ("4", "BODY", extractComponentString(str2, *p2.getBody())); - vmime::string str3 = "HEADER\r\n\nBODY"; - vmime::bodyPart p3; - p3.parse(str3); + vmime::string str3 = "HEADER\r\n\nBODY"; + vmime::bodyPart p3; + p3.parse(str3); - assert_eq("5", "HEADER\r\n\n", extractComponentString(str3, *p3.getHeader())); - assert_eq("6", "BODY", extractComponentString(str3, *p3.getBody())); - } + VASSERT_EQ("5", "HEADER\r\n\n", extractComponentString(str3, *p3.getHeader())); + VASSERT_EQ("6", "BODY", extractComponentString(str3, *p3.getBody())); + } - void testGenerate() - { - vmime::bodyPart p1; - p1.getHeader()->getField("Foo")->setValue(vmime::string("bar")); - p1.getBody()->setContents(vmime::create ("Baz")); + void testGenerate() + { + vmime::bodyPart p1; + p1.getHeader()->getField("Foo")->setValue(vmime::string("bar")); + p1.getBody()->setContents(vmime::create ("Baz")); - assert_eq("1", "Foo: bar\r\n\r\nBaz", p1.generate()); - } + VASSERT_EQ("1", "Foo: bar\r\n\r\nBaz", p1.generate()); + } - public: +VMIME_TEST_SUITE_END - bodyPartTest() : suite("vmime::bodyPart") - { - // VMime initialization - vmime::platformDependant::setHandler(); - - add("Parse", testcase(this, "Parse", &bodyPartTest::testParse)); - - add("Generate", testcase(this, "Generate", &bodyPartTest::testGenerate)); - - suite::main().add("vmime::bodyPart", this); - } - - }; - - bodyPartTest* theTest = new bodyPartTest(); -} diff --git a/tests/parser/datetimeTest.cpp b/tests/parser/datetimeTest.cpp index d372d685..12bf3dd4 100644 --- a/tests/parser/datetimeTest.cpp +++ b/tests/parser/datetimeTest.cpp @@ -17,126 +17,109 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -#include "tests/parser/testUtils.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class datetimeTest : public suite +#define VMIME_TEST_SUITE datetimeTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testParse) + VMIME_TEST(testGenerate) + VMIME_TEST(testCompare) + VMIME_TEST_LIST_END + + + void testParse() { - void testParse() + struct datetimePair { - struct datetimePair - { - vmime::string parseBuffer; - vmime::datetime result; - }; + vmime::string parseBuffer; + vmime::datetime result; + }; - // Here, we can't test all the possible structures for date/time, - // so we test some cases. Don't forget to add a new test case - // each time you encounter a bug in date/time parsing (after - // you have fixed it). - datetimePair pairs[] = - { - { /* 1 */ "Mon, 8 Nov 2004 13:42:56 +0000 (GMT)", - vmime::datetime(2004, 11, 8, 13, 42, 56, vmime::datetime::GMT) }, - - { /* 2 */ "Sun, 7 Nov 2004 00:43:22 -0500 (EST)", - vmime::datetime(2004, 11, 7, 0, 43, 22, vmime::datetime::GMT_5) }, - - { /* 3 */ "Thu Nov 18 12:11:16 2004", - vmime::datetime(vmime::datetime::now().getYear(), 11, 18, 12, 11, 16, vmime::datetime::GMT) }, - - { /* 4 */ "Sat, 18, 2004 22:36:32 -0400", - vmime::datetime(2004, 1, 18, 22, 36, 32, vmime::datetime::GMT_4) }, - - { /* 5 */ "Mon Dec 13 21:57:18 2004", - vmime::datetime(vmime::datetime::now().getYear(), 12, 13, 21, 57, 18, vmime::datetime::GMT) }, - - { /* 6 */ "18 Nov 2004 21:44:54 +0300", - vmime::datetime(2004, 11, 18, 21, 44, 54, vmime::datetime::GMT3) } - }; - - for (unsigned int i = 0 ; i < sizeof(pairs) / sizeof(pairs[0]) ; ++i) - { - vmime::datetime d; - d.parse(pairs[i].parseBuffer); - - std::ostringstream oss; - oss << (i + 1); - - assert_eq(oss.str(), pairs[i].result, d); - } - } - - void testGenerate() + // Here, we can't test all the possible structures for date/time, + // so we test some cases. Don't forget to add a new test case + // each time you encounter a bug in date/time parsing (after + // you have fixed it). + datetimePair pairs[] = { - vmime::datetime d1(2005, 7, 8, 4, 5, 6, 1 * 60 + 23); + { /* 1 */ "Mon, 8 Nov 2004 13:42:56 +0000 (GMT)", + vmime::datetime(2004, 11, 8, 13, 42, 56, vmime::datetime::GMT) }, - assert_eq("1", "Fri, 8 Jul 2005 04:05:06 +0123", d1.generate()); - } + { /* 2 */ "Sun, 7 Nov 2004 00:43:22 -0500 (EST)", + vmime::datetime(2004, 11, 7, 0, 43, 22, vmime::datetime::GMT_5) }, - void testCompare() + { /* 3 */ "Thu Nov 18 12:11:16 2004", + vmime::datetime(vmime::datetime::now().getYear(), 11, 18, 12, 11, 16, vmime::datetime::GMT) }, + + { /* 4 */ "Sat, 18, 2004 22:36:32 -0400", + vmime::datetime(2004, 1, 18, 22, 36, 32, vmime::datetime::GMT_4) }, + + { /* 5 */ "Mon Dec 13 21:57:18 2004", + vmime::datetime(vmime::datetime::now().getYear(), 12, 13, 21, 57, 18, vmime::datetime::GMT) }, + + { /* 6 */ "18 Nov 2004 21:44:54 +0300", + vmime::datetime(2004, 11, 18, 21, 44, 54, vmime::datetime::GMT3) } + }; + + for (unsigned int i = 0 ; i < sizeof(pairs) / sizeof(pairs[0]) ; ++i) { - // Date1 = Date2 - vmime::datetime d1(2005, 4, 22, 14, 6, 0, vmime::datetime::GMT2); - vmime::datetime d2(2005, 4, 22, 10, 6, 0, vmime::datetime::GMT_2); + vmime::datetime d; + d.parse(pairs[i].parseBuffer); - assert_eq("1.1", true, d1 == d2); - assert_eq("1.2", false, d1 != d2); - assert_eq("1.3", true, d1 <= d2); - assert_eq("1.4", false, d1 < d2); - assert_eq("1.5", true, d1 >= d2); - assert_eq("1.6", false, d1 > d2); + std::ostringstream oss; + oss << (i + 1); - // Date1 < Date2 - vmime::datetime d3(2005, 4, 22, 14, 6, 0); - vmime::datetime d4(2005, 4, 22, 15, 6, 0); - - assert_eq("2.1", false, d3 == d4); - assert_eq("2.2", true, d3 != d4); - assert_eq("2.3", true, d3 <= d4); - assert_eq("2.4", true, d3 < d4); - assert_eq("2.5", false, d3 >= d4); - assert_eq("2.6", false, d3 > d4); - - // Date1 > Date2 - vmime::datetime d5(2005, 4, 22, 15, 6, 0); - vmime::datetime d6(2005, 4, 22, 14, 6, 0); - - assert_eq("3.1", false, d5 == d6); - assert_eq("3.2", true, d5 != d6); - assert_eq("3.3", false, d5 <= d6); - assert_eq("3.4", false, d5 < d6); - assert_eq("3.5", true, d5 >= d6); - assert_eq("3.6", true, d5 > d6); + VASSERT_EQ(oss.str(), pairs[i].result, d); } + } - public: + void testGenerate() + { + vmime::datetime d1(2005, 7, 8, 4, 5, 6, 1 * 60 + 23); - datetimeTest() : suite("vmime::datetime") - { - // VMime initialization - vmime::platformDependant::setHandler(); + VASSERT_EQ("1", "Fri, 8 Jul 2005 04:05:06 +0123", d1.generate()); + } - add("Parse", testcase(this, "Parse", &datetimeTest::testParse)); - add("Generate", testcase(this, "Generate", &datetimeTest::testGenerate)); - add("Compare", testcase(this, "Compare", &datetimeTest::testCompare)); + void testCompare() + { + // Date1 = Date2 + vmime::datetime d1(2005, 4, 22, 14, 6, 0, vmime::datetime::GMT2); + vmime::datetime d2(2005, 4, 22, 10, 6, 0, vmime::datetime::GMT_2); - suite::main().add("vmime::datetime", this); - } + VASSERT_EQ("1.1", true, d1 == d2); + VASSERT_EQ("1.2", false, d1 != d2); + VASSERT_EQ("1.3", true, d1 <= d2); + VASSERT_EQ("1.4", false, d1 < d2); + VASSERT_EQ("1.5", true, d1 >= d2); + VASSERT_EQ("1.6", false, d1 > d2); - }; + // Date1 < Date2 + vmime::datetime d3(2005, 4, 22, 14, 6, 0); + vmime::datetime d4(2005, 4, 22, 15, 6, 0); + + VASSERT_EQ("2.1", false, d3 == d4); + VASSERT_EQ("2.2", true, d3 != d4); + VASSERT_EQ("2.3", true, d3 <= d4); + VASSERT_EQ("2.4", true, d3 < d4); + VASSERT_EQ("2.5", false, d3 >= d4); + VASSERT_EQ("2.6", false, d3 > d4); + + // Date1 > Date2 + vmime::datetime d5(2005, 4, 22, 15, 6, 0); + vmime::datetime d6(2005, 4, 22, 14, 6, 0); + + VASSERT_EQ("3.1", false, d5 == d6); + VASSERT_EQ("3.2", true, d5 != d6); + VASSERT_EQ("3.3", false, d5 <= d6); + VASSERT_EQ("3.4", false, d5 < d6); + VASSERT_EQ("3.5", true, d5 >= d6); + VASSERT_EQ("3.6", true, d5 > d6); + } + +VMIME_TEST_SUITE_END - datetimeTest* theTest = new datetimeTest(); -} diff --git a/tests/parser/dispositionTest.cpp b/tests/parser/dispositionTest.cpp index e0c269f7..bad63a63 100644 --- a/tests/parser/dispositionTest.cpp +++ b/tests/parser/dispositionTest.cpp @@ -17,152 +17,135 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -#include "tests/parser/testUtils.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class dispositionTest : public suite +#define VMIME_TEST_SUITE dispositionTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testParse) + VMIME_TEST(testGenerate) + VMIME_TEST(testModifiers) + VMIME_TEST_LIST_END + + + void testParse() { - void testParse() - { - // disposition-mode ";" disposition-type - // [ "/" disposition-modifier *( "," disposition-modifier ) ] - // - // disposition-mode = action-mode "/" sending-mode + // disposition-mode ";" disposition-type + // [ "/" disposition-modifier *( "," disposition-modifier ) ] + // + // disposition-mode = action-mode "/" sending-mode - vmime::disposition disp1; - disp1.parse("mode"); + vmime::disposition disp1; + disp1.parse("mode"); - assert_eq("1.1", "mode", disp1.getActionMode()); - assert_eq("1.2", "", disp1.getSendingMode()); - assert_eq("1.3", "", disp1.getType()); - assert_eq("1.4", 0, static_cast (disp1.getModifierList().size())); + VASSERT_EQ("1.1", "mode", disp1.getActionMode()); + VASSERT_EQ("1.2", "", disp1.getSendingMode()); + VASSERT_EQ("1.3", "", disp1.getType()); + VASSERT_EQ("1.4", 0, static_cast (disp1.getModifierList().size())); - vmime::disposition disp2; - disp2.parse("amode/smode"); + vmime::disposition disp2; + disp2.parse("amode/smode"); - assert_eq("2.1", "amode", disp2.getActionMode()); - assert_eq("2.2", "smode", disp2.getSendingMode()); - assert_eq("2.3", "", disp2.getType()); - assert_eq("2.4", 0, static_cast (disp2.getModifierList().size())); + VASSERT_EQ("2.1", "amode", disp2.getActionMode()); + VASSERT_EQ("2.2", "smode", disp2.getSendingMode()); + VASSERT_EQ("2.3", "", disp2.getType()); + VASSERT_EQ("2.4", 0, static_cast (disp2.getModifierList().size())); - vmime::disposition disp3; - disp3.parse("amode/smode;type"); + vmime::disposition disp3; + disp3.parse("amode/smode;type"); - assert_eq("3.1", "amode", disp3.getActionMode()); - assert_eq("3.2", "smode", disp3.getSendingMode()); - assert_eq("3.3", "type", disp3.getType()); - assert_eq("3.4", 0, static_cast (disp3.getModifierList().size())); + VASSERT_EQ("3.1", "amode", disp3.getActionMode()); + VASSERT_EQ("3.2", "smode", disp3.getSendingMode()); + VASSERT_EQ("3.3", "type", disp3.getType()); + VASSERT_EQ("3.4", 0, static_cast (disp3.getModifierList().size())); - vmime::disposition disp4; - disp4.parse("amode/smode;type/modif"); + vmime::disposition disp4; + disp4.parse("amode/smode;type/modif"); - assert_eq("4.1", "amode", disp4.getActionMode()); - assert_eq("4.2", "smode", disp4.getSendingMode()); - assert_eq("4.3", "type", disp4.getType()); - assert_eq("4.4", 1, static_cast (disp4.getModifierList().size())); - assert_eq("4.5", "modif", disp4.getModifierList()[0]); + VASSERT_EQ("4.1", "amode", disp4.getActionMode()); + VASSERT_EQ("4.2", "smode", disp4.getSendingMode()); + VASSERT_EQ("4.3", "type", disp4.getType()); + VASSERT_EQ("4.4", 1, static_cast (disp4.getModifierList().size())); + VASSERT_EQ("4.5", "modif", disp4.getModifierList()[0]); - vmime::disposition disp5; - disp5.parse("amode/smode;type/modif1,modif2"); + vmime::disposition disp5; + disp5.parse("amode/smode;type/modif1,modif2"); - assert_eq("5.1", "amode", disp5.getActionMode()); - assert_eq("5.2", "smode", disp5.getSendingMode()); - assert_eq("5.3", "type", disp5.getType()); - assert_eq("5.4", 2, static_cast (disp5.getModifierList().size())); - assert_eq("5.5", "modif1", disp5.getModifierList()[0]); - assert_eq("5.6", "modif2", disp5.getModifierList()[1]); - } + VASSERT_EQ("5.1", "amode", disp5.getActionMode()); + VASSERT_EQ("5.2", "smode", disp5.getSendingMode()); + VASSERT_EQ("5.3", "type", disp5.getType()); + VASSERT_EQ("5.4", 2, static_cast (disp5.getModifierList().size())); + VASSERT_EQ("5.5", "modif1", disp5.getModifierList()[0]); + VASSERT_EQ("5.6", "modif2", disp5.getModifierList()[1]); + } - void testGenerate() - { - vmime::disposition disp; + void testGenerate() + { + vmime::disposition disp; - assert_eq("1", "automatic-action/MDN-sent-automatically;displayed", disp.generate()); + VASSERT_EQ("1", "automatic-action/MDN-sent-automatically;displayed", disp.generate()); - disp.setActionMode("amode"); + disp.setActionMode("amode"); - assert_eq("2", "amode/MDN-sent-automatically;displayed", disp.generate()); + VASSERT_EQ("2", "amode/MDN-sent-automatically;displayed", disp.generate()); - disp.setActionMode("amode"); - disp.setSendingMode("smode"); + disp.setActionMode("amode"); + disp.setSendingMode("smode"); - assert_eq("3", "amode/smode;displayed", disp.generate()); + VASSERT_EQ("3", "amode/smode;displayed", disp.generate()); - disp.setType("type"); + disp.setType("type"); - assert_eq("4", "amode/smode;type", disp.generate()); + VASSERT_EQ("4", "amode/smode;type", disp.generate()); - disp.addModifier("modif1"); + disp.addModifier("modif1"); - assert_eq("5", "amode/smode;type/modif1", disp.generate()); + VASSERT_EQ("5", "amode/smode;type/modif1", disp.generate()); - disp.addModifier("modif2"); + disp.addModifier("modif2"); - assert_eq("6", "amode/smode;type/modif1,modif2", disp.generate()); - } + VASSERT_EQ("6", "amode/smode;type/modif1,modif2", disp.generate()); + } - void testModifiers() - { - vmime::disposition disp1; + void testModifiers() + { + vmime::disposition disp1; - assert_eq("1", false, disp1.hasModifier("foo")); - assert_eq("2", 0, static_cast (disp1.getModifierList().size())); + VASSERT_EQ("1", false, disp1.hasModifier("foo")); + VASSERT_EQ("2", 0, static_cast (disp1.getModifierList().size())); - disp1.addModifier("bar"); + disp1.addModifier("bar"); - assert_eq("3", false, disp1.hasModifier("foo")); - assert_eq("4", true, disp1.hasModifier("bar")); - assert_eq("5", 1, static_cast (disp1.getModifierList().size())); + VASSERT_EQ("3", false, disp1.hasModifier("foo")); + VASSERT_EQ("4", true, disp1.hasModifier("bar")); + VASSERT_EQ("5", 1, static_cast (disp1.getModifierList().size())); - disp1.addModifier("plop"); + disp1.addModifier("plop"); - assert_eq("6", false, disp1.hasModifier("foo")); - assert_eq("7", true, disp1.hasModifier("bar")); - assert_eq("8", true, disp1.hasModifier("plop")); - assert_eq("9", 2, static_cast (disp1.getModifierList().size())); + VASSERT_EQ("6", false, disp1.hasModifier("foo")); + VASSERT_EQ("7", true, disp1.hasModifier("bar")); + VASSERT_EQ("8", true, disp1.hasModifier("plop")); + VASSERT_EQ("9", 2, static_cast (disp1.getModifierList().size())); - disp1.removeModifier("bar"); + disp1.removeModifier("bar"); - assert_eq("10", false, disp1.hasModifier("foo")); - assert_eq("11", false, disp1.hasModifier("bar")); - assert_eq("12", true, disp1.hasModifier("plop")); - assert_eq("13", 1, static_cast (disp1.getModifierList().size())); + VASSERT_EQ("10", false, disp1.hasModifier("foo")); + VASSERT_EQ("11", false, disp1.hasModifier("bar")); + VASSERT_EQ("12", true, disp1.hasModifier("plop")); + VASSERT_EQ("13", 1, static_cast (disp1.getModifierList().size())); - disp1.removeModifier("PlOp"); + disp1.removeModifier("PlOp"); - assert_eq("14", false, disp1.hasModifier("foo")); - assert_eq("15", false, disp1.hasModifier("bar")); - assert_eq("16", false, disp1.hasModifier("plop")); - assert_eq("17", 0, static_cast (disp1.getModifierList().size())); - } + VASSERT_EQ("14", false, disp1.hasModifier("foo")); + VASSERT_EQ("15", false, disp1.hasModifier("bar")); + VASSERT_EQ("16", false, disp1.hasModifier("plop")); + VASSERT_EQ("17", 0, static_cast (disp1.getModifierList().size())); + } - public: +VMIME_TEST_SUITE_END - dispositionTest() : suite("vmime::disposition") - { - vmime::platformDependant::setHandler(); - - add("Parse", testcase(this, "Parse", &dispositionTest::testParse)); - add("Generate", testcase(this, "Generate", &dispositionTest::testGenerate)); - - add("Modifiers", testcase(this, "Modifiers", &dispositionTest::testModifiers)); - - suite::main().add("vmime::disposition", this); - } - - }; - - dispositionTest* theTest = new dispositionTest(); -} diff --git a/tests/parser/encoderTest.cpp b/tests/parser/encoderTest.cpp index 55c83f83..38e4ff4e 100644 --- a/tests/parser/encoderTest.cpp +++ b/tests/parser/encoderTest.cpp @@ -17,282 +17,268 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class encoderTest : public suite +#define VMIME_TEST_SUITE encoderTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testBase64) + VMIME_TEST(testQuotedPrintable) + VMIME_TEST_LIST_END + + + // Encoding helper function + static const vmime::string encode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0) { - // Encoding helper function - static const vmime::string encode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0) + vmime::ref enc = vmime::encoderFactory::getInstance()->create(name); + + if (maxLineLength != 0) + enc->getProperties()["maxlinelength"] = maxLineLength; + + vmime::utility::inputStreamStringAdapter vin(in); + + std::ostringstream out; + vmime::utility::outputStreamAdapter vout(out); + + enc->encode(vin, vout); + + return (out.str()); + } + + // Decoding helper function + static const vmime::string decode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0) + { + vmime::ref enc = vmime::encoderFactory::getInstance()->create(name); + + if (maxLineLength != 0) + enc->getProperties()["maxlinelength"] = maxLineLength; + + vmime::utility::inputStreamStringAdapter vin(in); + + std::ostringstream out; + vmime::utility::outputStreamAdapter vout(out); + + enc->decode(vin, vout); + + return (out.str()); + } + + + void testBase64() + { + static const vmime::string testSuites[] = { - vmime::ref enc = vmime::encoderFactory::getInstance()->create(name); + // Test 1 + "", - if (maxLineLength != 0) - enc->getProperties()["maxlinelength"] = maxLineLength; + "", - vmime::utility::inputStreamStringAdapter vin(in); + // Test 2 + "A", - std::ostringstream out; - vmime::utility::outputStreamAdapter vout(out); + "QQ==", - enc->encode(vin, vout); + // Test 3 + "AB", - return (out.str()); - } + "QUI=", - // Decoding helper function - static const vmime::string decode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0) + // Test 4 + "ABC", + + "QUJD", + + // Test 5 + "foo", + + "Zm9v", + + // Test 6 + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + + "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAx" + "MjM0NTY3ODk=", + + // Test 7 + vmime::string( + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" + "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" + "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" + "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" + "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" + "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" + "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" + "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" + "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" + "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" + "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" + "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" + "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" + "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", + 256), + + "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1" + "Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWpr" + "bG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6Ch" + "oqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX" + "2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" + }; + + + for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) { - vmime::ref enc = vmime::encoderFactory::getInstance()->create(name); + const vmime::string decoded = testSuites[i * 2]; + const vmime::string encoded = testSuites[i * 2 + 1]; - if (maxLineLength != 0) - enc->getProperties()["maxlinelength"] = maxLineLength; + std::ostringstream oss; + oss << "[Base64] Test " << (i + 1) << ": "; - vmime::utility::inputStreamStringAdapter vin(in); + // Encoding + VASSERT_EQ(oss.str() + "encoding", encoded, encode("base64", decoded)); - std::ostringstream out; - vmime::utility::outputStreamAdapter vout(out); + // Decoding + VASSERT_EQ(oss.str() + "decoding", decoded, decode("base64", encoded)); - enc->decode(vin, vout); + // Multiple and successive encoding/decoding + VASSERT_EQ(oss.str() + "multiple1", decoded, + decode("base64", + encode("base64", decoded))); - return (out.str()); - } - - - void testBase64() - { - static const vmime::string testSuites[] = - { - // Test 1 - "", - - "", - - // Test 2 - "A", - - "QQ==", - - // Test 3 - "AB", - - "QUI=", - - // Test 4 - "ABC", - - "QUJD", - - // Test 5 - "foo", - - "Zm9v", - - // Test 6 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - - "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAx" - "MjM0NTY3ODk=", - - // Test 7 - vmime::string( - "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" - "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" - "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" - "\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" - "\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" - "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" - "\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" - "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" - "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" - "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf" - "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" - "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" - "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" - "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", - 256), - - "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1" - "Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWpr" - "bG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6Ch" - "oqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX" - "2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==" - }; - - - for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) - { - const vmime::string decoded = testSuites[i * 2]; - const vmime::string encoded = testSuites[i * 2 + 1]; - - std::ostringstream oss; - oss << "[Base64] Test " << (i + 1) << ": "; - - // Encoding - assert_eq(oss.str() + "encoding", encoded, encode("base64", decoded)); - - // Decoding - assert_eq(oss.str() + "decoding", decoded, decode("base64", encoded)); - - // Multiple and successive encoding/decoding - assert_eq(oss.str() + "multiple1", decoded, + VASSERT_EQ(oss.str() + "multiple2", decoded, + decode("base64", decode("base64", - encode("base64", decoded))); + encode("base64", + encode("base64", decoded))))); - assert_eq(oss.str() + "multiple2", decoded, + VASSERT_EQ(oss.str() + "multiple3", decoded, + decode("base64", decode("base64", decode("base64", encode("base64", - encode("base64", decoded))))); + encode("base64", + encode("base64", decoded))))))); - assert_eq(oss.str() + "multiple3", decoded, + VASSERT_EQ(oss.str() + "multiple4", decoded, + decode("base64", decode("base64", decode("base64", decode("base64", encode("base64", - encode("base64", - encode("base64", decoded))))))); - - assert_eq(oss.str() + "multiple4", decoded, - decode("base64", - decode("base64", - decode("base64", - decode("base64", encode("base64", encode("base64", - encode("base64", - encode("base64", decoded))))))))); - } + encode("base64", decoded))))))))); } + } - void testQuotedPrintable() + void testQuotedPrintable() + { + static const vmime::string testSuites[] = { - static const vmime::string testSuites[] = - { - // Test 1 - "", + // Test 1 + "", - "", + "", - // Test 2 - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", + // Test 2 + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", - // Test 3 - "0123456789012345678901234567890123456789012345678901234567890123456789012" - "3456789012345678901234567890123456789012345678901234567890123456789012345" - "6789", + // Test 3 + "0123456789012345678901234567890123456789012345678901234567890123456789012" + "3456789012345678901234567890123456789012345678901234567890123456789012345" + "6789", - "0123456789012345678901234567890123456789012345678901234567890123456789012=\r\n" - "3456789012345678901234567890123456789012345678901234567890123456789012345=\r\n" - "6789", + "0123456789012345678901234567890123456789012345678901234567890123456789012=\r\n" + "3456789012345678901234567890123456789012345678901234567890123456789012345=\r\n" + "6789", - // Test 4 - vmime::string( - "\x89\xe8\x24\x04\x2f\xe8\xff\xfb\xeb\xff\x90\xd7\x74\x8d\x00\x26\x89\x55" - "\x83\xe5\x08\xec\x04\xc7\xa0\x24\x05\xa2\xe8\x08\x43\xee\x00\x00\xc0\x85" - "\x0a\x74\xec\x89\xc3\x5d\xb6\x8d\x00\x00\x00\x00\x04\xc7\xa8\x24\x05\xa2" - "\xe8\x08\x43\xd4\x00\x00\xe8\xeb\xf6\x89\x89\x55\x81\xe5\xa8\xec\x00\x00" - "\x89\x00\xfc\x75\x75\x8b\x89\x08\xf8\x5d\xb9\xe8\xff\xff\x83\xff\x14\xfe" - "\x47\x74\xc0\x31\x9d\x8d\xff\x68\xff\xff\x85\x89\xff\x68\xff\xff\x85\x8d" - "\xff\x6c\xff\xff\x04\x89\xe8\x24\xfa\x50\xff\xff\x45\xc7\x00\xec\x00\x00" - "\x31\x00\x89\xc0\x24\x44\x89\x08\x24\x5c\x89\x04\x24\x34\x87\xe8\xff\xf6" - "\x89\xff\x24\x34\x2f\xe8\xff\xf9\x8b\xff\xf8\x5d\x75\x8b\x89\xfc\x5d\xec" - "\xbe\xc3\x00\x13\x00\x00\xe7\xeb\xb6\x8d\x00\x00\x00\x00\x89\x55\x57\xe5" - "\x53\x56\xec\x81\x01\xdc\x00\x00\x45\xbb\x05\x5c\x8b\x08\x0c\x55\xe4\x83" - "\x8b\xf0\x89\x02\x24\x5c\xc7\x04\x24\x04\x00\x06\x00\x00\xec\xa3\x05\xa9" - "\xe8\x08\xf7\x2a\xff\xff\x04\xc7\x46\x24\x05\x5c\xb9\x08\x5c\x50\x08\x05" - "\x4c\x89\x04\x24\xf5\xe8\xff\xf7\xc7\xff\x24\x04\x5c\x46\x08\x05\xe9\xe8" - "\xff\xf8\xc7\xff\x24\x04\x1d\x70\x08\x05\x55\xe8\x00\xbb\xb8\x00\x00\x01" - "\x00\x00\xd2\x31\x08\xa3\x05\xa7\xb8\x08\x00\x01\x00\x00\x0c\xa3\x05\xa7", - 18 * 16), + // Test 4 + vmime::string( + "\x89\xe8\x24\x04\x2f\xe8\xff\xfb\xeb\xff\x90\xd7\x74\x8d\x00\x26\x89\x55" + "\x83\xe5\x08\xec\x04\xc7\xa0\x24\x05\xa2\xe8\x08\x43\xee\x00\x00\xc0\x85" + "\x0a\x74\xec\x89\xc3\x5d\xb6\x8d\x00\x00\x00\x00\x04\xc7\xa8\x24\x05\xa2" + "\xe8\x08\x43\xd4\x00\x00\xe8\xeb\xf6\x89\x89\x55\x81\xe5\xa8\xec\x00\x00" + "\x89\x00\xfc\x75\x75\x8b\x89\x08\xf8\x5d\xb9\xe8\xff\xff\x83\xff\x14\xfe" + "\x47\x74\xc0\x31\x9d\x8d\xff\x68\xff\xff\x85\x89\xff\x68\xff\xff\x85\x8d" + "\xff\x6c\xff\xff\x04\x89\xe8\x24\xfa\x50\xff\xff\x45\xc7\x00\xec\x00\x00" + "\x31\x00\x89\xc0\x24\x44\x89\x08\x24\x5c\x89\x04\x24\x34\x87\xe8\xff\xf6" + "\x89\xff\x24\x34\x2f\xe8\xff\xf9\x8b\xff\xf8\x5d\x75\x8b\x89\xfc\x5d\xec" + "\xbe\xc3\x00\x13\x00\x00\xe7\xeb\xb6\x8d\x00\x00\x00\x00\x89\x55\x57\xe5" + "\x53\x56\xec\x81\x01\xdc\x00\x00\x45\xbb\x05\x5c\x8b\x08\x0c\x55\xe4\x83" + "\x8b\xf0\x89\x02\x24\x5c\xc7\x04\x24\x04\x00\x06\x00\x00\xec\xa3\x05\xa9" + "\xe8\x08\xf7\x2a\xff\xff\x04\xc7\x46\x24\x05\x5c\xb9\x08\x5c\x50\x08\x05" + "\x4c\x89\x04\x24\xf5\xe8\xff\xf7\xc7\xff\x24\x04\x5c\x46\x08\x05\xe9\xe8" + "\xff\xf8\xc7\xff\x24\x04\x1d\x70\x08\x05\x55\xe8\x00\xbb\xb8\x00\x00\x01" + "\x00\x00\xd2\x31\x08\xa3\x05\xa7\xb8\x08\x00\x01\x00\x00\x0c\xa3\x05\xa7", + 18 * 16), - "=89=E8$=04/=E8=FF=FB=EB=FF=90=D7t=8D=00&=89U=83=E5=08=EC=04=C7=A0$=05=A2=E8=\r\n" - "=08C=EE=00=00=C0=85=0At=EC=89=C3]=B6=8D=00=00=00=00=04=C7=A8$=05=A2=E8=08=\r\n" - "C=D4=00=00=E8=EB=F6=89=89U=81=E5=A8=EC=00=00=89=00=FCuu=8B=89=08=F8]=B9=E8=\r\n" - "=FF=FF=83=FF=14=FEGt=C01=9D=8D=FFh=FF=FF=85=89=FFh=FF=FF=85=8D=FFl=FF=FF=04=\r\n" - "=89=E8$=FAP=FF=FFE=C7=00=EC=00=001=00=89=C0$D=89=08$\\=89=04$4=87=E8=FF=F6=\r\n" - "=89=FF$4/=E8=FF=F9=8B=FF=F8]u=8B=89=FC]=EC=BE=C3=00=13=00=00=E7=EB=B6=8D=00=\r\n" - "=00=00=00=89UW=E5SV=EC=81=01=DC=00=00E=BB=05\\=8B=08=0CU=E4=83=8B=F0=89=02=\r\n" - "$\\=C7=04$=04=00=06=00=00=EC=A3=05=A9=E8=08=F7*=FF=FF=04=C7F$=05\\=B9=08\\P=08=\r\n" - "=05L=89=04$=F5=E8=FF=F7=C7=FF$=04\\F=08=05=E9=E8=FF=F8=C7=FF$=04=1Dp=08=05=\r\n" - "U=E8=00=BB=B8=00=00=01=00=00=D21=08=A3=05=A7=B8=08=00=01=00=00=0C=A3=05=A7=\r\n" - }; + "=89=E8$=04/=E8=FF=FB=EB=FF=90=D7t=8D=00&=89U=83=E5=08=EC=04=C7=A0$=05=A2=E8=\r\n" + "=08C=EE=00=00=C0=85=0At=EC=89=C3]=B6=8D=00=00=00=00=04=C7=A8$=05=A2=E8=08=\r\n" + "C=D4=00=00=E8=EB=F6=89=89U=81=E5=A8=EC=00=00=89=00=FCuu=8B=89=08=F8]=B9=E8=\r\n" + "=FF=FF=83=FF=14=FEGt=C01=9D=8D=FFh=FF=FF=85=89=FFh=FF=FF=85=8D=FFl=FF=FF=04=\r\n" + "=89=E8$=FAP=FF=FFE=C7=00=EC=00=001=00=89=C0$D=89=08$\\=89=04$4=87=E8=FF=F6=\r\n" + "=89=FF$4/=E8=FF=F9=8B=FF=F8]u=8B=89=FC]=EC=BE=C3=00=13=00=00=E7=EB=B6=8D=00=\r\n" + "=00=00=00=89UW=E5SV=EC=81=01=DC=00=00E=BB=05\\=8B=08=0CU=E4=83=8B=F0=89=02=\r\n" + "$\\=C7=04$=04=00=06=00=00=EC=A3=05=A9=E8=08=F7*=FF=FF=04=C7F$=05\\=B9=08\\P=08=\r\n" + "=05L=89=04$=F5=E8=FF=F7=C7=FF$=04\\F=08=05=E9=E8=FF=F8=C7=FF$=04=1Dp=08=05=\r\n" + "U=E8=00=BB=B8=00=00=01=00=00=D21=08=A3=05=A7=B8=08=00=01=00=00=0C=A3=05=A7=\r\n" + }; - for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) - { - const vmime::string decoded = testSuites[i * 2]; - const vmime::string encoded = testSuites[i * 2 + 1]; + for (unsigned int i = 0 ; i < sizeof(testSuites) / sizeof(testSuites[0]) / 2 ; ++i) + { + const vmime::string decoded = testSuites[i * 2]; + const vmime::string encoded = testSuites[i * 2 + 1]; - std::ostringstream oss; - oss << "[QP] Test " << (i + 1) << ": "; + std::ostringstream oss; + oss << "[QP] Test " << (i + 1) << ": "; - // Encoding - assert_eq(oss.str() + "encoding", encoded, encode("quoted-printable", decoded, 74)); + // Encoding + VASSERT_EQ(oss.str() + "encoding", encoded, encode("quoted-printable", decoded, 74)); - // Decoding - assert_eq(oss.str() + "decoding", decoded, decode("quoted-printable", encoded, 74)); + // Decoding + VASSERT_EQ(oss.str() + "decoding", decoded, decode("quoted-printable", encoded, 74)); - // Multiple and successive encoding/decoding - assert_eq(oss.str() + "multiple1", decoded, + // Multiple and successive encoding/decoding + VASSERT_EQ(oss.str() + "multiple1", decoded, + decode("quoted-printable", + encode("quoted-printable", decoded))); + + VASSERT_EQ(oss.str() + "multiple2", decoded, + decode("quoted-printable", decode("quoted-printable", - encode("quoted-printable", decoded))); + encode("quoted-printable", + encode("quoted-printable", decoded))))); - assert_eq(oss.str() + "multiple2", decoded, + VASSERT_EQ(oss.str() + "multiple3", decoded, + decode("quoted-printable", decode("quoted-printable", decode("quoted-printable", encode("quoted-printable", - encode("quoted-printable", decoded))))); + encode("quoted-printable", + encode("quoted-printable", decoded))))))); - assert_eq(oss.str() + "multiple3", decoded, + VASSERT_EQ(oss.str() + "multiple4", decoded, + decode("quoted-printable", decode("quoted-printable", decode("quoted-printable", decode("quoted-printable", encode("quoted-printable", - encode("quoted-printable", - encode("quoted-printable", decoded))))))); - - assert_eq(oss.str() + "multiple4", decoded, - decode("quoted-printable", - decode("quoted-printable", - decode("quoted-printable", - decode("quoted-printable", encode("quoted-printable", encode("quoted-printable", - encode("quoted-printable", - encode("quoted-printable", decoded))))))))); - } + encode("quoted-printable", decoded))))))))); } + } - // TODO: UUEncode + // TODO: UUEncode - public: +VMIME_TEST_SUITE_END - encoderTest() : suite("vmime::encoder") - { - vmime::platformDependant::setHandler(); - - add("Base64", testcase(this, "Base64", &encoderTest::testBase64)); - add("QuotedPrintable", testcase(this, "QuotedPrintable", &encoderTest::testQuotedPrintable)); - - suite::main().add("vmime::encoder", this); - } - - }; - - encoderTest* theTest = new encoderTest(); -} diff --git a/tests/parser/headerTest.cpp b/tests/parser/headerTest.cpp index 83f0409e..18325f5c 100644 --- a/tests/parser/headerTest.cpp +++ b/tests/parser/headerTest.cpp @@ -17,356 +17,341 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class headerTest : public suite +#define VMIME_TEST_SUITE headerTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testHas1) + VMIME_TEST(testHas2) + + VMIME_TEST(testAppend1) + VMIME_TEST(testAppend2) + + VMIME_TEST(testInsertFieldBefore1) + VMIME_TEST(testInsertFieldBefore2) + + VMIME_TEST(testInsertFieldAfter1) + VMIME_TEST(testInsertFieldAfter2) + + VMIME_TEST(testRemoveField1) + VMIME_TEST(testRemoveField2) + + VMIME_TEST(testRemoveAllFields) + + VMIME_TEST(testgetFieldCount) + + VMIME_TEST(testIsEmpty1) + VMIME_TEST(testIsEmpty2) + + VMIME_TEST(testGetFieldAt) + + VMIME_TEST(testGetFieldList1) + VMIME_TEST(testGetFieldList2) + + VMIME_TEST(testFind1) + + VMIME_TEST(testFindAllFields1) + VMIME_TEST(testFindAllFields2) + VMIME_TEST(testFindAllFields3) + VMIME_TEST_LIST_END + + + static const std::string getFieldValue(const vmime::headerField& field) { - static const std::string getFieldValue(const vmime::headerField& field) - { - std::ostringstream oss; - vmime::utility::outputStreamAdapter voss(oss); - field.generate(voss); + std::ostringstream oss; + vmime::utility::outputStreamAdapter voss(oss); + field.generate(voss); - return (oss.str()); - } + return (oss.str()); + } - // has function tests - void testHas1() - { - vmime::header hdr; - hdr.parse("From: x\r\nTo: y\r\nTo: z\r\n"); + // has function tests + void testHas1() + { + vmime::header hdr; + hdr.parse("From: x\r\nTo: y\r\nTo: z\r\n"); - bool res = hdr.hasField("Z"); + bool res = hdr.hasField("Z"); - assert_eq("Value", false, res); - } + VASSERT_EQ("Value", false, res); + } - void testHas2() - { - vmime::header hdr; - hdr.parse("X: x\r\nTo: y\r\nTo: z\r\n"); + void testHas2() + { + vmime::header hdr; + hdr.parse("X: x\r\nTo: y\r\nTo: z\r\n"); - bool res = hdr.hasField("To"); + bool res = hdr.hasField("To"); - assert_eq("Value", true, res); - } + VASSERT_EQ("Value", true, res); + } - // appendField function tests - void testAppend1() - { - vmime::header hdr; - hdr.parse(""); + // appendField function tests + void testAppend1() + { + vmime::header hdr; + hdr.parse(""); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("A", "a"); - hdr.appendField(hf); + vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("A", "a"); + hdr.appendField(hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); - assert_eq("Count", static_cast (1), res.size()); - assert_eq("First value", "A: a", headerTest::getFieldValue(*res[0])); - } + VASSERT_EQ("Count", static_cast (1), res.size()); + VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); + } - void testAppend2() - { - vmime::header hdr; - hdr.parse("A: a\r\n"); + void testAppend2() + { + vmime::header hdr; + hdr.parse("A: a\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); - hdr.appendField(hf); + vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + hdr.appendField(hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); - assert_eq("Count", static_cast (2), res.size()); - assert_eq("First value", "A: a", headerTest::getFieldValue(*res[0])); - assert_eq("Second value", "B: b", headerTest::getFieldValue(*res[1])); - } + VASSERT_EQ("Count", static_cast (2), res.size()); + VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); + VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); + } - // insertFieldBefore - void testInsertFieldBefore1() - { - vmime::header hdr; - hdr.parse("A: a\r\nC: c\r\n"); + // insertFieldBefore + void testInsertFieldBefore1() + { + vmime::header hdr; + hdr.parse("A: a\r\nC: c\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); - hdr.insertFieldBefore(hdr.getField("C"), hf); + vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + hdr.insertFieldBefore(hdr.getField("C"), hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); - assert_eq("Count", static_cast (3), res.size()); - assert_eq("First value", "A: a", headerTest::getFieldValue(*res[0])); - assert_eq("Second value", "B: b", headerTest::getFieldValue(*res[1])); - assert_eq("Third value", "C: c", headerTest::getFieldValue(*res[2])); - } + VASSERT_EQ("Count", static_cast (3), res.size()); + VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); + VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); + VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); + } - void testInsertFieldBefore2() - { - vmime::header hdr; - hdr.parse("A: a\r\nC: c\r\n"); + void testInsertFieldBefore2() + { + vmime::header hdr; + hdr.parse("A: a\r\nC: c\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); - hdr.insertFieldBefore(1, hf); + vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + hdr.insertFieldBefore(1, hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); - assert_eq("Count", static_cast (3), res.size()); - assert_eq("First value", "A: a", headerTest::getFieldValue(*res[0])); - assert_eq("Second value", "B: b", headerTest::getFieldValue(*res[1])); - assert_eq("Third value", "C: c", headerTest::getFieldValue(*res[2])); - } + VASSERT_EQ("Count", static_cast (3), res.size()); + VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); + VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); + VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); + } - // insertFieldAfter - void testInsertFieldAfter1() - { - vmime::header hdr; - hdr.parse("A: a\r\nC: c\r\n"); + // insertFieldAfter + void testInsertFieldAfter1() + { + vmime::header hdr; + hdr.parse("A: a\r\nC: c\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); - hdr.insertFieldAfter(hdr.getField("A"), hf); + vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + hdr.insertFieldAfter(hdr.getField("A"), hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); - assert_eq("Count", static_cast (3), res.size()); - assert_eq("First value", "A: a", headerTest::getFieldValue(*res[0])); - assert_eq("Second value", "B: b", headerTest::getFieldValue(*res[1])); - assert_eq("Third value", "C: c", headerTest::getFieldValue(*res[2])); - } + VASSERT_EQ("Count", static_cast (3), res.size()); + VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); + VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); + VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); + } - void testInsertFieldAfter2() - { - vmime::header hdr; - hdr.parse("A: a\r\nC: c\r\n"); + void testInsertFieldAfter2() + { + vmime::header hdr; + hdr.parse("A: a\r\nC: c\r\n"); - vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); - hdr.insertFieldAfter(0, hf); + vmime::ref hf = vmime::headerFieldFactory::getInstance()->create("B", "b"); + hdr.insertFieldAfter(0, hf); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); - assert_eq("Count", static_cast (3), res.size()); - assert_eq("First value", "A: a", headerTest::getFieldValue(*res[0])); - assert_eq("Second value", "B: b", headerTest::getFieldValue(*res[1])); - assert_eq("Third value", "C: c", headerTest::getFieldValue(*res[2])); - } + VASSERT_EQ("Count", static_cast (3), res.size()); + VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); + VASSERT_EQ("Second value", "B: b", headerTest::getFieldValue(*res[1])); + VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); + } - // removeField - void testRemoveField1() - { - vmime::header hdr1, hdr2; - hdr1.parse("A: a\r\nB: b\r\nC: c\r\n"); - hdr2.parse("A: a\r\nB: b\r\nC: c\r\n"); - - hdr1.removeField(hdr1.getField("B")); - hdr2.removeField(1); + // removeField + void testRemoveField1() + { + vmime::header hdr1, hdr2; + hdr1.parse("A: a\r\nB: b\r\nC: c\r\n"); + hdr2.parse("A: a\r\nB: b\r\nC: c\r\n"); + + hdr1.removeField(hdr1.getField("B")); + hdr2.removeField(1); - std::vector > res1 = hdr1.getFieldList(); - - assert_eq("Count", static_cast (2), res1.size()); - assert_eq("First value", "A: a", headerTest::getFieldValue(*res1[0])); - assert_eq("Second value", "C: c", headerTest::getFieldValue(*res1[1])); - - std::vector > res2 = hdr2.getFieldList(); + std::vector > res1 = hdr1.getFieldList(); + + VASSERT_EQ("Count", static_cast (2), res1.size()); + VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res1[0])); + VASSERT_EQ("Second value", "C: c", headerTest::getFieldValue(*res1[1])); + + std::vector > res2 = hdr2.getFieldList(); - assert_eq("Count", static_cast (2), res2.size()); - assert_eq("First value", "A: a", headerTest::getFieldValue(*res2[0])); - assert_eq("Second value", "C: c", headerTest::getFieldValue(*res2[1])); - } - - void testRemoveField2() - { - vmime::header hdr1, hdr2; - hdr1.parse("A: a\r\n"); - hdr2.parse("A: a\r\n"); + VASSERT_EQ("Count", static_cast (2), res2.size()); + VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res2[0])); + VASSERT_EQ("Second value", "C: c", headerTest::getFieldValue(*res2[1])); + } + + void testRemoveField2() + { + vmime::header hdr1, hdr2; + hdr1.parse("A: a\r\n"); + hdr2.parse("A: a\r\n"); - hdr1.removeField(hdr1.getField("A")); - hdr2.removeField(0); - - std::vector > res1 = hdr1.getFieldList(); - assert_eq("Count", static_cast (0), res1.size()); - - std::vector > res2 = hdr2.getFieldList(); - assert_eq("Count", static_cast (0), res2.size()); - } + hdr1.removeField(hdr1.getField("A")); + hdr2.removeField(0); + + std::vector > res1 = hdr1.getFieldList(); + VASSERT_EQ("Count", static_cast (0), res1.size()); + + std::vector > res2 = hdr2.getFieldList(); + VASSERT_EQ("Count", static_cast (0), res2.size()); + } - // removeAllFields - void testRemoveAllFields() - { - vmime::header hdr1, hdr2; - hdr1.parse("A: a\r\n"); - hdr2.parse("A: a\r\nB: b\r\n"); - - hdr1.removeAllFields(); - hdr2.removeAllFields(); + // removeAllFields + void testRemoveAllFields() + { + vmime::header hdr1, hdr2; + hdr1.parse("A: a\r\n"); + hdr2.parse("A: a\r\nB: b\r\n"); + + hdr1.removeAllFields(); + hdr2.removeAllFields(); - std::vector > res1 = hdr1.getFieldList(); - assert_eq("Count", static_cast (0), res1.size()); + std::vector > res1 = hdr1.getFieldList(); + VASSERT_EQ("Count", static_cast (0), res1.size()); - std::vector > res2 = hdr2.getFieldList(); - assert_eq("Count", static_cast (0), res2.size()); - } + std::vector > res2 = hdr2.getFieldList(); + VASSERT_EQ("Count", static_cast (0), res2.size()); + } - // getFieldCount - void testgetFieldCount() - { - vmime::header hdr; - hdr.parse("A: a\r\nB: b\r\nC: c\r\nD: d\r\n"); - - assert_eq("Value", 4, hdr.getFieldCount()); - } + // getFieldCount + void testgetFieldCount() + { + vmime::header hdr; + hdr.parse("A: a\r\nB: b\r\nC: c\r\nD: d\r\n"); + + VASSERT_EQ("Value", 4, hdr.getFieldCount()); + } - // isEmpty - void testIsEmpty1() - { - vmime::header hdr; - hdr.parse("A: a\r\nB: b\r\nC: c\r\n"); + // isEmpty + void testIsEmpty1() + { + vmime::header hdr; + hdr.parse("A: a\r\nB: b\r\nC: c\r\n"); - assert_eq("Value", false, hdr.isEmpty()); - } + VASSERT_EQ("Value", false, hdr.isEmpty()); + } - void testIsEmpty2() - { - vmime::header hdr; - hdr.parse("\r\n"); + void testIsEmpty2() + { + vmime::header hdr; + hdr.parse("\r\n"); - assert_eq("Value", true, hdr.isEmpty()); - } + VASSERT_EQ("Value", true, hdr.isEmpty()); + } - // getFieldAt - void getFieldAt() - { - vmime::header hdr; - hdr.parse("B: b\r\nA: a\r\nC: c\r\n"); + // getFieldAt + void testGetFieldAt() + { + vmime::header hdr; + hdr.parse("B: b\r\nA: a\r\nC: c\r\n"); - vmime::ref res = hdr.getFieldAt(2); + vmime::ref res = hdr.getFieldAt(2); - assert_eq("Value", "C: c", getFieldValue(*res)); - } + VASSERT_EQ("Value", "C: c", getFieldValue(*res)); + } - // getFieldList - void testGetFieldList1() - { - vmime::header hdr; - hdr.parse("A: a\r\nB: b1\r\nC: c\r\nB: b2\r\n"); + // getFieldList + void testGetFieldList1() + { + vmime::header hdr; + hdr.parse("A: a\r\nB: b1\r\nC: c\r\nB: b2\r\n"); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); - assert_eq("Count", static_cast (4), res.size()); - assert_eq("First value", "A: a", headerTest::getFieldValue(*res[0])); - assert_eq("Second value", "B: b1", headerTest::getFieldValue(*res[1])); - assert_eq("Third value", "C: c", headerTest::getFieldValue(*res[2])); - assert_eq("Thourth value", "B: b2", headerTest::getFieldValue(*res[3])); - } + VASSERT_EQ("Count", static_cast (4), res.size()); + VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0])); + VASSERT_EQ("Second value", "B: b1", headerTest::getFieldValue(*res[1])); + VASSERT_EQ("Third value", "C: c", headerTest::getFieldValue(*res[2])); + VASSERT_EQ("Thourth value", "B: b2", headerTest::getFieldValue(*res[3])); + } - void testGetFieldList2() - { - vmime::header hdr; - hdr.parse("\r\n"); + void testGetFieldList2() + { + vmime::header hdr; + hdr.parse("\r\n"); - std::vector > res = hdr.getFieldList(); + std::vector > res = hdr.getFieldList(); - assert_eq("Count", static_cast (0), res.size()); - } + VASSERT_EQ("Count", static_cast (0), res.size()); + } - // find function tests - void testFind1() - { - vmime::header hdr; - hdr.parse("A: a\r\nB: b\r\nC: c\r\nB: d\r\n"); + // find function tests + void testFind1() + { + vmime::header hdr; + hdr.parse("A: a\r\nB: b\r\nC: c\r\nB: d\r\n"); - vmime::ref res = hdr.findField("B"); + vmime::ref res = hdr.findField("B"); - assert_eq("Value", "B: b", getFieldValue(*res)); - } + VASSERT_EQ("Value", "B: b", getFieldValue(*res)); + } - // getAllByName function tests - void testFindAllFields1() - { - vmime::header hdr; - hdr.parse("A: a1\nC: c1\n"); + // getAllByName function tests + void testFindAllFields1() + { + vmime::header hdr; + hdr.parse("A: a1\nC: c1\n"); - std::vector > res = hdr.findAllFields("B"); + std::vector > res = hdr.findAllFields("B"); - assert_eq("Count", static_cast (0), res.size()); - } + VASSERT_EQ("Count", static_cast (0), res.size()); + } - void testFindAllFields2() - { - vmime::header hdr; - hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\n"); + void testFindAllFields2() + { + vmime::header hdr; + hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\n"); - std::vector > res = hdr.findAllFields("B"); + std::vector > res = hdr.findAllFields("B"); - assert_eq("Count", static_cast (2), res.size()); - assert_eq("First value", "B: b1", headerTest::getFieldValue(*res[0])); - assert_eq("Second value", "B: b2", headerTest::getFieldValue(*res[1])); - } + VASSERT_EQ("Count", static_cast (2), res.size()); + VASSERT_EQ("First value", "B: b1", headerTest::getFieldValue(*res[0])); + VASSERT_EQ("Second value", "B: b2", headerTest::getFieldValue(*res[1])); + } - void testFindAllFields3() - { - vmime::header hdr; - hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\nC: c3\nC: c2\n"); + void testFindAllFields3() + { + vmime::header hdr; + hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\nC: c3\nC: c2\n"); - std::vector > res = hdr.findAllFields("C"); + std::vector > res = hdr.findAllFields("C"); - assert_eq("Count", static_cast (3), res.size()); - assert_eq("First value", "C: c1", headerTest::getFieldValue(*res[0])); - assert_eq("Second value", "C: c3", headerTest::getFieldValue(*res[1])); - assert_eq("Second value", "C: c2", headerTest::getFieldValue(*res[2])); - } + VASSERT_EQ("Count", static_cast (3), res.size()); + VASSERT_EQ("First value", "C: c1", headerTest::getFieldValue(*res[0])); + VASSERT_EQ("Second value", "C: c3", headerTest::getFieldValue(*res[1])); + VASSERT_EQ("Second value", "C: c2", headerTest::getFieldValue(*res[2])); + } - public: +VMIME_TEST_SUITE_END - headerTest() : suite("vmime::header") - { - // VMime initialization - vmime::platformDependant::setHandler(); - - add("Has", testcase(this, "Has1", &headerTest::testHas1)); - add("Has", testcase(this, "Has2", &headerTest::testHas2)); - - add("Append", testcase(this, "Append1", &headerTest::testAppend1)); - add("Append", testcase(this, "Append2", &headerTest::testAppend2)); - - add("InsertFieldBefore", testcase(this, "InsertFieldBefore1", &headerTest::testInsertFieldBefore1)); - add("InsertFieldBefore", testcase(this, "InsertFieldBefore2", &headerTest::testInsertFieldBefore2)); - - add("InsertFieldAfter", testcase(this, "InsertFieldAfter1", &headerTest::testInsertFieldAfter1)); - add("InsertFieldAfter", testcase(this, "InsertFieldAfter2", &headerTest::testInsertFieldAfter2)); - - add("RemoveField", testcase(this, "RemoveField1", &headerTest::testRemoveField1)); - add("RemoveField", testcase(this, "RemoveField2", &headerTest::testRemoveField2)); - - add("RemoveAllFields", testcase(this, "RemoveAllFields", &headerTest::testRemoveAllFields)); - - add("GetFieldCount", testcase(this, "GetFieldCount", &headerTest::testgetFieldCount)); - - add("IsEmpty", testcase(this, "IsEmpty1", &headerTest::testIsEmpty1)); - add("IsEmpty", testcase(this, "IsEmpty2", &headerTest::testIsEmpty2)); - - add("GetFieldAt", testcase(this, "GetFieldAt", &headerTest::getFieldAt)); - - add("GetFieldList", testcase(this, "GetFieldList1", &headerTest::testGetFieldList1)); - add("GetFieldList", testcase(this, "GetFieldList2", &headerTest::testGetFieldList2)); - - add("Find", testcase(this, "Find1", &headerTest::testFind1)); - - add("FindAllFields", testcase(this, "FindAllFields1", &headerTest::testFindAllFields1)); - add("FindAllFields", testcase(this, "FindAllFields2", &headerTest::testFindAllFields2)); - add("FindAllFields", testcase(this, "FindAllFields3", &headerTest::testFindAllFields3)); - - suite::main().add("vmime::header", this); - } - - }; - - headerTest* theTest = new headerTest(); -} diff --git a/tests/parser/mailboxTest.cpp b/tests/parser/mailboxTest.cpp index 3c991b61..b4683ca2 100644 --- a/tests/parser/mailboxTest.cpp +++ b/tests/parser/mailboxTest.cpp @@ -17,113 +17,97 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -#include "tests/parser/testUtils.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class mailboxTest : public suite +#define VMIME_TEST_SUITE mailboxTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testParse) + VMIME_TEST_LIST_END + + + void testParse() { - void testParse() + static const vmime::string testSuitesParse[] = { - static const vmime::string testSuitesParse[] = - { - // Test 1 - "My (this is a comment)name ", + // Test 1 + "My (this is a comment)name ", - "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=My name]]], email=me@somewhere.com]]]", + "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=My name]]], email=me@somewhere.com]]]", - // Test 2 - "mailbox1 ,;,,, ,, ,,;group1:mailbox1@group1, mailbox2@group2,,\"mailbox #3\" ;, ,,,,,,,,=?iso-8859-1?q?mailbox_number_3?= , =?abc?Q?mailbox?= =?def?Q?_number_4?= ", + // Test 2 + "mailbox1 ,;,,, ,, ,,;group1:mailbox1@group1, mailbox2@group2,,\"mailbox #3\" ;, ,,,,,,,,=?iso-8859-1?q?mailbox_number_3?= , =?abc?Q?mailbox?= =?def?Q?_number_4?= ", - "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=mailbox1]]], email=mailbox@one],[mailbox-group: name=[text: [[word: charset=us-ascii, buffer=group1]]], list=[[mailbox: name=[text: []], email=mailbox1@group1],[mailbox: name=[text: []], email=mailbox2@group2],[mailbox: name=[text: [[word: charset=us-ascii, buffer=mailbox #3]]], email=mailbox3@group2]]],[mailbox: name=[text: []], email=mailbox@two],[mailbox: name=[text: [[word: charset=iso-8859-1, buffer=mailbox number 3]]], email=mailbox@three],[mailbox: name=[text: [[word: charset=abc, buffer=mailbox],[word: charset=def, buffer= number 4]]], email=mailbox@four]]]", + "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=mailbox1]]], email=mailbox@one],[mailbox-group: name=[text: [[word: charset=us-ascii, buffer=group1]]], list=[[mailbox: name=[text: []], email=mailbox1@group1],[mailbox: name=[text: []], email=mailbox2@group2],[mailbox: name=[text: [[word: charset=us-ascii, buffer=mailbox #3]]], email=mailbox3@group2]]],[mailbox: name=[text: []], email=mailbox@two],[mailbox: name=[text: [[word: charset=iso-8859-1, buffer=mailbox number 3]]], email=mailbox@three],[mailbox: name=[text: [[word: charset=abc, buffer=mailbox],[word: charset=def, buffer= number 4]]], email=mailbox@four]]]", - // Test 3 - "John Doe ", + // Test 3 + "John Doe ", - "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John Doe]]], email=john.doe@acme.com]]]", + "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John Doe]]], email=john.doe@acme.com]]]", - // Test 4 - "john.doe@acme.com (John Doe)", + // Test 4 + "john.doe@acme.com (John Doe)", - "[address-list: [[mailbox: name=[text: []], email=john.doe@acme.com]]]", + "[address-list: [[mailbox: name=[text: []], email=john.doe@acme.com]]]", - // Test 5 - "John.Doe (ignore) @acme.com (John Doe)", + // Test 5 + "John.Doe (ignore) @acme.com (John Doe)", - "[address-list: [[mailbox: name=[text: []], email=John.Doe@acme.com]]]", + "[address-list: [[mailbox: name=[text: []], email=John.Doe@acme.com]]]", - // Test 6 - "", + // Test 6 + "", - "[address-list: [[mailbox: name=[text: []], email=john.doe@acme.com]]]", + "[address-list: [[mailbox: name=[text: []], email=john.doe@acme.com]]]", - // Test 7 - "john.doe@acme.com", + // Test 7 + "john.doe@acme.com", - "[address-list: [[mailbox: name=[text: []], email=john.doe@acme.com]]]", + "[address-list: [[mailbox: name=[text: []], email=john.doe@acme.com]]]", - // Test 8 - "\"John Doe\" ", + // Test 8 + "\"John Doe\" ", - "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John Doe]]], email=john.doe@acme.com]]]", + "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John Doe]]], email=john.doe@acme.com]]]", - // Test 9 - "=?us-ascii?q?John?=", + // Test 9 + "=?us-ascii?q?John?=", - "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], email=john.doe@acme.com]]]", + "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], email=john.doe@acme.com]]]", - // Test 10 - "\"John\"", + // Test 10 + "\"John\"", - "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], email=john.doe@acme.com]]]", + "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], email=john.doe@acme.com]]]", - // Test 11 - "John", + // Test 11 + "John", - "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], email=john.doe@acme.com]]]" - }; + "[address-list: [[mailbox: name=[text: [[word: charset=us-ascii, buffer=John]]], email=john.doe@acme.com]]]" + }; - for (unsigned int i = 0 ; i < sizeof(testSuitesParse) / sizeof(testSuitesParse[0]) / 2 ; ++i) - { - vmime::string in = testSuitesParse[i * 2]; - vmime::string out = testSuitesParse[i * 2 + 1]; - - std::ostringstream oss; - oss << "Test " << (i + 1); - - vmime::addressList addrList; - addrList.parse(in); - - std::ostringstream cmp; - cmp << addrList; - - assert_eq(oss.str(), out, cmp.str()); - } - } - - public: - - mailboxTest() : suite("vmime::mailbox") + for (unsigned int i = 0 ; i < sizeof(testSuitesParse) / sizeof(testSuitesParse[0]) / 2 ; ++i) { - vmime::platformDependant::setHandler(); + vmime::string in = testSuitesParse[i * 2]; + vmime::string out = testSuitesParse[i * 2 + 1]; - add("Parse", testcase(this, "Parse", &mailboxTest::testParse)); + std::ostringstream oss; + oss << "Test " << (i + 1); - suite::main().add("vmime::mailbox", this); + vmime::addressList addrList; + addrList.parse(in); + + std::ostringstream cmp; + cmp << addrList; + + VASSERT_EQ(oss.str(), out, cmp.str()); } + } - }; +VMIME_TEST_SUITE_END - mailboxTest* theTest = new mailboxTest(); -} diff --git a/tests/parser/mediaTypeTest.cpp b/tests/parser/mediaTypeTest.cpp index 52da8096..868fdab6 100644 --- a/tests/parser/mediaTypeTest.cpp +++ b/tests/parser/mediaTypeTest.cpp @@ -17,99 +17,85 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class mediaTypeTest : public suite +#define VMIME_TEST_SUITE mediaTypeTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testConstructors) + VMIME_TEST(testCopy) + VMIME_TEST(testSetFromString) + VMIME_TEST(testParse) + VMIME_TEST(testGenerate) + VMIME_TEST_LIST_END + + + void testConstructors() { - void testConstructors() - { - vmime::mediaType t1; + vmime::mediaType t1; - assert_eq("1.1", vmime::mediaTypes::APPLICATION, t1.getType()); - assert_eq("1.2", vmime::mediaTypes::APPLICATION_OCTET_STREAM, t1.getSubType()); + VASSERT_EQ("1.1", vmime::mediaTypes::APPLICATION, t1.getType()); + VASSERT_EQ("1.2", vmime::mediaTypes::APPLICATION_OCTET_STREAM, t1.getSubType()); - vmime::mediaType t2("type", "sub"); + vmime::mediaType t2("type", "sub"); - assert_eq("2.1", "type", t2.getType()); - assert_eq("2.2", "sub", t2.getSubType()); + VASSERT_EQ("2.1", "type", t2.getType()); + VASSERT_EQ("2.2", "sub", t2.getSubType()); - vmime::mediaType t3("type/sub"); + vmime::mediaType t3("type/sub"); - assert_eq("3.1", "type", t3.getType()); - assert_eq("3.2", "sub", t3.getSubType()); - } + VASSERT_EQ("3.1", "type", t3.getType()); + VASSERT_EQ("3.2", "sub", t3.getSubType()); + } - void testCopy() - { - vmime::mediaType t1("type/sub"); + void testCopy() + { + vmime::mediaType t1("type/sub"); - assert_eq("eq1", "type", t1.getType()); - assert_eq("eq2", "sub", t1.getSubType()); + VASSERT_EQ("eq1", "type", t1.getType()); + VASSERT_EQ("eq2", "sub", t1.getSubType()); - assert_true("operator==", t1 == t1); - assert_true("clone", t1 == *vmime::clone(t1)); + VASSERT("operator==", t1 == t1); + VASSERT("clone", t1 == *vmime::clone(t1)); - assert_eq("eq3", "type", vmime::clone(t1)->getType()); - assert_eq("eq4", "sub", vmime::clone(t1)->getSubType()); + VASSERT_EQ("eq3", "type", vmime::clone(t1)->getType()); + VASSERT_EQ("eq4", "sub", vmime::clone(t1)->getSubType()); - vmime::mediaType t2; - t2.copyFrom(t1); + vmime::mediaType t2; + t2.copyFrom(t1); - assert_true("copyFrom", t1 == t2); - } + VASSERT("copyFrom", t1 == t2); + } - void testSetFromString() - { - vmime::mediaType t1; - t1.setFromString("type/sub"); + void testSetFromString() + { + vmime::mediaType t1; + t1.setFromString("type/sub"); - assert_eq("1.1", "type", t1.getType()); - assert_eq("1.2", "sub", t1.getSubType()); - } + VASSERT_EQ("1.1", "type", t1.getType()); + VASSERT_EQ("1.2", "sub", t1.getSubType()); + } - void testParse() - { - vmime::mediaType t1; - t1.parse("type/sub"); + void testParse() + { + vmime::mediaType t1; + t1.parse("type/sub"); - assert_eq("1.1", "type", t1.getType()); - assert_eq("1.2", "sub", t1.getSubType()); - } + VASSERT_EQ("1.1", "type", t1.getType()); + VASSERT_EQ("1.2", "sub", t1.getSubType()); + } - void testGenerate() - { - vmime::mediaType t1("type", "sub"); + void testGenerate() + { + vmime::mediaType t1("type", "sub"); - assert_eq("1", "type/sub", t1.generate()); - } + VASSERT_EQ("1", "type/sub", t1.generate()); + } - public: +VMIME_TEST_SUITE_END - mediaTypeTest() : suite("vmime::mediaType") - { - vmime::platformDependant::setHandler(); - - add("Constructors", testcase(this, "Constructors", &mediaTypeTest::testConstructors)); - add("Copy", testcase(this, "Copy", &mediaTypeTest::testCopy)); - add("SetFromString", testcase(this, "SetFromString", &mediaTypeTest::testSetFromString)); - add("Parse", testcase(this, "Parse", &mediaTypeTest::testParse)); - add("Generate", testcase(this, "Generate", &mediaTypeTest::testGenerate)); - - suite::main().add("vmime::mediaType", this); - } - - }; - - mediaTypeTest* theTest = new mediaTypeTest(); -} diff --git a/tests/parser/messageIdSequenceTest.cpp b/tests/parser/messageIdSequenceTest.cpp index 6382adef..f9a1ede5 100644 --- a/tests/parser/messageIdSequenceTest.cpp +++ b/tests/parser/messageIdSequenceTest.cpp @@ -17,79 +17,63 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -#include "tests/parser/testUtils.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class messageIdSequenceTest : public suite +#define VMIME_TEST_SUITE messageIdSequenceTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testParse) + VMIME_TEST(testGenerate) + VMIME_TEST_LIST_END + + + void testParse() { - void testParse() - { - vmime::messageIdSequence s1; - s1.parse(""); + vmime::messageIdSequence s1; + s1.parse(""); - assert_eq("1", 0, s1.getMessageIdCount()); + VASSERT_EQ("1", 0, s1.getMessageIdCount()); - vmime::messageIdSequence s2; - s2.parse(" \t "); + vmime::messageIdSequence s2; + s2.parse(" \t "); - assert_eq("2", 0, s2.getMessageIdCount()); + VASSERT_EQ("2", 0, s2.getMessageIdCount()); - vmime::messageIdSequence s3; - s3.parse(""); + vmime::messageIdSequence s3; + s3.parse(""); - assert_eq("3.1", 1, s3.getMessageIdCount()); - assert_eq("3.2", "a", s3.getMessageIdAt(0)->getLeft()); - assert_eq("3.3", "b", s3.getMessageIdAt(0)->getRight()); + VASSERT_EQ("3.1", 1, s3.getMessageIdCount()); + VASSERT_EQ("3.2", "a", s3.getMessageIdAt(0)->getLeft()); + VASSERT_EQ("3.3", "b", s3.getMessageIdAt(0)->getRight()); - vmime::messageIdSequence s4; - s4.parse(" \r\n\t"); + vmime::messageIdSequence s4; + s4.parse(" \r\n\t"); - assert_eq("4.1", 2, s4.getMessageIdCount()); - assert_eq("4.2", "a", s4.getMessageIdAt(0)->getLeft()); - assert_eq("4.3", "b", s4.getMessageIdAt(0)->getRight()); - assert_eq("4.4", "c", s4.getMessageIdAt(1)->getLeft()); - assert_eq("4.5", "d", s4.getMessageIdAt(1)->getRight()); - } + VASSERT_EQ("4.1", 2, s4.getMessageIdCount()); + VASSERT_EQ("4.2", "a", s4.getMessageIdAt(0)->getLeft()); + VASSERT_EQ("4.3", "b", s4.getMessageIdAt(0)->getRight()); + VASSERT_EQ("4.4", "c", s4.getMessageIdAt(1)->getLeft()); + VASSERT_EQ("4.5", "d", s4.getMessageIdAt(1)->getRight()); + } - void testGenerate() - { - vmime::messageIdSequence s1; - s1.appendMessageId(vmime::create ("a", "b")); + void testGenerate() + { + vmime::messageIdSequence s1; + s1.appendMessageId(vmime::create ("a", "b")); - assert_eq("1", "", s1.generate()); + VASSERT_EQ("1", "", s1.generate()); - vmime::messageIdSequence s2; - s2.appendMessageId(vmime::create ("a", "b")); - s2.appendMessageId(vmime::create ("c", "d")); + vmime::messageIdSequence s2; + s2.appendMessageId(vmime::create ("a", "b")); + s2.appendMessageId(vmime::create ("c", "d")); - assert_eq("2", " ", s2.generate()); - } + VASSERT_EQ("2", " ", s2.generate()); + } - public: +VMIME_TEST_SUITE_END - messageIdSequenceTest() : suite("vmime::messageIdSequence") - { - vmime::platformDependant::setHandler(); - - add("Parse", testcase(this, "Parse", &messageIdSequenceTest::testParse)); - add("Generate", testcase(this, "Generate", &messageIdSequenceTest::testGenerate)); - - suite::main().add("vmime::messageIdSequence", this); - } - - }; - - messageIdSequenceTest* theTest = new messageIdSequenceTest(); -} diff --git a/tests/parser/messageIdTest.cpp b/tests/parser/messageIdTest.cpp index e05ac9c1..1c0661cd 100644 --- a/tests/parser/messageIdTest.cpp +++ b/tests/parser/messageIdTest.cpp @@ -17,68 +17,52 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -#include "tests/parser/testUtils.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class messageIdTest : public suite +#define VMIME_TEST_SUITE messageIdTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testParse) + VMIME_TEST(testGenerate) + VMIME_TEST_LIST_END + + + void testParse() { - void testParse() - { - vmime::messageId m1; - m1.parse(""); + vmime::messageId m1; + m1.parse(""); - assert_eq("1.1", "a", m1.getLeft()); - assert_eq("1.2", "b", m1.getRight()); - } + VASSERT_EQ("1.1", "a", m1.getLeft()); + VASSERT_EQ("1.2", "b", m1.getRight()); + } - void testGenerate() - { - vmime::messageId m1; + void testGenerate() + { + vmime::messageId m1; - assert_eq("1", "<@>", m1.generate()); + VASSERT_EQ("1", "<@>", m1.generate()); - vmime::messageId m2; - m2.setLeft("a"); + vmime::messageId m2; + m2.setLeft("a"); - assert_eq("2", "", m2.generate()); + VASSERT_EQ("2", "", m2.generate()); - vmime::messageId m3; - m3.setRight("b"); + vmime::messageId m3; + m3.setRight("b"); - assert_eq("3", "<@b>", m3.generate()); + VASSERT_EQ("3", "<@b>", m3.generate()); - vmime::messageId m4; - m4.setLeft("a"); - m4.setRight("b"); + vmime::messageId m4; + m4.setLeft("a"); + m4.setRight("b"); - assert_eq("4", "", m4.generate()); - } + VASSERT_EQ("4", "", m4.generate()); + } - public: +VMIME_TEST_SUITE_END - messageIdTest() : suite("vmime::messageId") - { - vmime::platformDependant::setHandler(); - - add("Parse", testcase(this, "Parse", &messageIdTest::testParse)); - add("Generate", testcase(this, "Generate", &messageIdTest::testGenerate)); - - suite::main().add("vmime::messageId", this); - } - - }; - - messageIdTest* theTest = new messageIdTest(); -} diff --git a/tests/parser/parameterTest.cpp b/tests/parser/parameterTest.cpp index 9b3bd66a..5f838fe1 100644 --- a/tests/parser/parameterTest.cpp +++ b/tests/parser/parameterTest.cpp @@ -17,21 +17,21 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -#include "tests/parser/testUtils.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" + + +#define VMIME_TEST_SUITE parameterTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testParse) + VMIME_TEST(testGenerate) + VMIME_TEST_LIST_END -namespace -{ // HACK: parameterizedHeaderField constructor is private class parameterizedHeaderField : public vmime::parameterizedHeaderField { @@ -65,193 +65,177 @@ namespace (p.getParameterAt(n).staticCast ())->getValue().getBuffer()) - class parameterTest : public suite + void testParse() { - void testParse() - { - // Simple parameter - parameterizedHeaderField p1; - p1.parse("X; param1=value1;\r\n"); + // Simple parameter + parameterizedHeaderField p1; + p1.parse("X; param1=value1;\r\n"); - assert_eq("1.1", 1, p1.getParameterCount()); - assert_eq("1.2", "param1", PARAM_NAME(p1, 0)); - assert_eq("1.3", "value1", PARAM_VALUE(p1, 0)); + VASSERT_EQ("1.1", 1, p1.getParameterCount()); + VASSERT_EQ("1.2", "param1", PARAM_NAME(p1, 0)); + VASSERT_EQ("1.3", "value1", PARAM_VALUE(p1, 0)); - // Multi-section parameters (1/2) - parameterizedHeaderField p2a; - p2a.parse("X; param1=value1;\r\n" - " param2*0=\"val\";\r\n" - " param2*1=\"ue2\";"); + // Multi-section parameters (1/2) + parameterizedHeaderField p2a; + p2a.parse("X; param1=value1;\r\n" + " param2*0=\"val\";\r\n" + " param2*1=\"ue2\";"); - assert_eq("2a.1", 2, p2a.getParameterCount()); - assert_eq("2a.2", "param1", PARAM_NAME(p2a, 0)); - assert_eq("2a.3", "value1", PARAM_VALUE(p2a, 0)); - assert_eq("2a.4", "param2", PARAM_NAME(p2a, 1)); - assert_eq("2a.5", "value2", PARAM_VALUE(p2a, 1)); + VASSERT_EQ("2a.1", 2, p2a.getParameterCount()); + VASSERT_EQ("2a.2", "param1", PARAM_NAME(p2a, 0)); + VASSERT_EQ("2a.3", "value1", PARAM_VALUE(p2a, 0)); + VASSERT_EQ("2a.4", "param2", PARAM_NAME(p2a, 1)); + VASSERT_EQ("2a.5", "value2", PARAM_VALUE(p2a, 1)); - // Multi-section parameters (2/2) - parameterizedHeaderField p2b; - p2b.parse("X; param1=value1;\r\n" - " param2=\"should be ignored\";\r\n" - " param2*0=\"val\";\r\n" - " param2*1=\"ue2\";"); + // Multi-section parameters (2/2) + parameterizedHeaderField p2b; + p2b.parse("X; param1=value1;\r\n" + " param2=\"should be ignored\";\r\n" + " param2*0=\"val\";\r\n" + " param2*1=\"ue2\";"); - assert_eq("2b.1", 2, p2b.getParameterCount()); - assert_eq("2b.2", "param1", PARAM_NAME(p2b, 0)); - assert_eq("2b.3", "value1", PARAM_VALUE(p2b, 0)); - assert_eq("2b.4", "param2", PARAM_NAME(p2b, 1)); - assert_eq("2b.5", "value2", PARAM_VALUE(p2b, 1)); + VASSERT_EQ("2b.1", 2, p2b.getParameterCount()); + VASSERT_EQ("2b.2", "param1", PARAM_NAME(p2b, 0)); + VASSERT_EQ("2b.3", "value1", PARAM_VALUE(p2b, 0)); + VASSERT_EQ("2b.4", "param2", PARAM_NAME(p2b, 1)); + VASSERT_EQ("2b.5", "value2", PARAM_VALUE(p2b, 1)); - // Extended parameter (charset and language information) - parameterizedHeaderField p3; - p3.parse("X; param1*=charset'language'value1;\r\n"); + // Extended parameter (charset and language information) + parameterizedHeaderField p3; + p3.parse("X; param1*=charset'language'value1;\r\n"); - assert_eq("3.1", 1, p3.getParameterCount()); - assert_eq("3.2", "param1", PARAM_NAME(p3, 0)); - assert_eq("3.3", "charset", PARAM_CHARSET(p3, 0)); - assert_eq("3.4", "value1", PARAM_BUFFER(p3, 0)); + VASSERT_EQ("3.1", 1, p3.getParameterCount()); + VASSERT_EQ("3.2", "param1", PARAM_NAME(p3, 0)); + VASSERT_EQ("3.3", "charset", PARAM_CHARSET(p3, 0)); + VASSERT_EQ("3.4", "value1", PARAM_BUFFER(p3, 0)); - // Encoded characters in extended parameter values - parameterizedHeaderField p4; - p4.parse("X; param1*=a%20value%20with%20multiple%20word%73"); // 0x73 = 's' + // Encoded characters in extended parameter values + parameterizedHeaderField p4; + p4.parse("X; param1*=a%20value%20with%20multiple%20word%73"); // 0x73 = 's' - assert_eq("4.1", 1, p4.getParameterCount()); - assert_eq("4.2", "param1", PARAM_NAME(p4, 0)); - assert_eq("4.3", "a value with multiple words", PARAM_VALUE(p4, 0)); + VASSERT_EQ("4.1", 1, p4.getParameterCount()); + VASSERT_EQ("4.2", "param1", PARAM_NAME(p4, 0)); + VASSERT_EQ("4.3", "a value with multiple words", PARAM_VALUE(p4, 0)); - // Invalid encoded character - parameterizedHeaderField p5; - p5.parse("X; param1*=test%20value%"); + // Invalid encoded character + parameterizedHeaderField p5; + p5.parse("X; param1*=test%20value%"); - assert_eq("5.1", 1, p5.getParameterCount()); - assert_eq("5.2", "param1", PARAM_NAME(p5, 0)); - assert_eq("5.3", "test value%", PARAM_VALUE(p5, 0)); + VASSERT_EQ("5.1", 1, p5.getParameterCount()); + VASSERT_EQ("5.2", "param1", PARAM_NAME(p5, 0)); + VASSERT_EQ("5.3", "test value%", PARAM_VALUE(p5, 0)); - // Spaces before and after '=' - parameterizedHeaderField p6; - p6.parse("X; param1\t= \"value1\""); + // Spaces before and after '=' + parameterizedHeaderField p6; + p6.parse("X; param1\t= \"value1\""); - assert_eq("6.1", 1, p6.getParameterCount()); - assert_eq("6.2", "param1", PARAM_NAME(p6, 0)); - assert_eq("6.3", "value1", PARAM_VALUE(p6, 0)); + VASSERT_EQ("6.1", 1, p6.getParameterCount()); + VASSERT_EQ("6.2", "param1", PARAM_NAME(p6, 0)); + VASSERT_EQ("6.3", "value1", PARAM_VALUE(p6, 0)); - // Quoted strings and escaped chars - parameterizedHeaderField p7; - p7.parse("X; param1=\"this is a slash: \\\"\\\\\\\"\""); // \"\\\" + // Quoted strings and escaped chars + parameterizedHeaderField p7; + p7.parse("X; param1=\"this is a slash: \\\"\\\\\\\"\""); // \"\\\" - assert_eq("7.1", 1, p7.getParameterCount()); - assert_eq("7.2", "param1", PARAM_NAME(p7, 0)); - assert_eq("7.3", "this is a slash: \"\\\"", PARAM_VALUE(p7, 0)); + VASSERT_EQ("7.1", 1, p7.getParameterCount()); + VASSERT_EQ("7.2", "param1", PARAM_NAME(p7, 0)); + VASSERT_EQ("7.3", "this is a slash: \"\\\"", PARAM_VALUE(p7, 0)); - // Extended parameter with charset specified in more than one - // section (this is forbidden by RFC, but is should not fail) - parameterizedHeaderField p8; - p8.parse("X; param1*0*=charset1'language1'value1;\r\n" - " param1*1*=charset2'language2'value2;"); + // Extended parameter with charset specified in more than one + // section (this is forbidden by RFC, but is should not fail) + parameterizedHeaderField p8; + p8.parse("X; param1*0*=charset1'language1'value1;\r\n" + " param1*1*=charset2'language2'value2;"); - assert_eq("8.1", 1, p8.getParameterCount()); - assert_eq("8.2", "param1", PARAM_NAME(p8, 0)); - assert_eq("8.3", "charset1", PARAM_CHARSET(p8, 0)); - assert_eq("8.4", "value1charset2'language2'value2", PARAM_BUFFER(p8, 0)); + VASSERT_EQ("8.1", 1, p8.getParameterCount()); + VASSERT_EQ("8.2", "param1", PARAM_NAME(p8, 0)); + VASSERT_EQ("8.3", "charset1", PARAM_CHARSET(p8, 0)); + VASSERT_EQ("8.4", "value1charset2'language2'value2", PARAM_BUFFER(p8, 0)); - // Charset not specified in the first section (that is not encoded), - // but specified in the second one (legal) - parameterizedHeaderField p9; - p9.parse("X; param1*0=value1;\r\n" - " param1*1*=charset'language'value2;"); + // Charset not specified in the first section (that is not encoded), + // but specified in the second one (legal) + parameterizedHeaderField p9; + p9.parse("X; param1*0=value1;\r\n" + " param1*1*=charset'language'value2;"); - assert_eq("9.1", 1, p9.getParameterCount()); - assert_eq("9.2", "param1", PARAM_NAME(p9, 0)); - assert_eq("9.3", "charset", PARAM_CHARSET(p9, 0)); - assert_eq("9.4", "value1value2", PARAM_BUFFER(p9, 0)); + VASSERT_EQ("9.1", 1, p9.getParameterCount()); + VASSERT_EQ("9.2", "param1", PARAM_NAME(p9, 0)); + VASSERT_EQ("9.3", "charset", PARAM_CHARSET(p9, 0)); + VASSERT_EQ("9.4", "value1value2", PARAM_BUFFER(p9, 0)); - // Characters prefixed with '%' in a simple (not extended) section - // should not be decoded - parameterizedHeaderField p10; - p10.parse("X; param1=val%20ue1"); + // Characters prefixed with '%' in a simple (not extended) section + // should not be decoded + parameterizedHeaderField p10; + p10.parse("X; param1=val%20ue1"); - assert_eq("10.1", 1, p10.getParameterCount()); - assert_eq("10.2", "param1", PARAM_NAME(p10, 0)); - assert_eq("10.3", "val%20ue1", PARAM_VALUE(p10, 0)); + VASSERT_EQ("10.1", 1, p10.getParameterCount()); + VASSERT_EQ("10.2", "param1", PARAM_NAME(p10, 0)); + VASSERT_EQ("10.3", "val%20ue1", PARAM_VALUE(p10, 0)); - // Multiple sections + charset specified and encoding - parameterizedHeaderField p11; - p11.parse("X; param1*0*=charset'language'value1a%20;" - " param1*1*=value1b%20;" - " param1*2=value1c"); + // Multiple sections + charset specified and encoding + parameterizedHeaderField p11; + p11.parse("X; param1*0*=charset'language'value1a%20;" + " param1*1*=value1b%20;" + " param1*2=value1c"); - assert_eq("11.1", 1, p11.getParameterCount()); - assert_eq("11.2", "param1", PARAM_NAME(p11, 0)); - assert_eq("11.3", "charset", PARAM_CHARSET(p11, 0)); - assert_eq("11.4", "value1a value1b value1c", PARAM_BUFFER(p11, 0)); + VASSERT_EQ("11.1", 1, p11.getParameterCount()); + VASSERT_EQ("11.2", "param1", PARAM_NAME(p11, 0)); + VASSERT_EQ("11.3", "charset", PARAM_CHARSET(p11, 0)); + VASSERT_EQ("11.4", "value1a value1b value1c", PARAM_BUFFER(p11, 0)); - // No charset specified: defaults to US-ASCII - parameterizedHeaderField p12; - p12.parse("X; param1*='language'value1"); + // No charset specified: defaults to US-ASCII + parameterizedHeaderField p12; + p12.parse("X; param1*='language'value1"); - assert_eq("12.1", 1, p12.getParameterCount()); - assert_eq("12.2", "param1", PARAM_NAME(p12, 0)); - assert_eq("12.3", "us-ascii", PARAM_CHARSET(p12, 0)); - assert_eq("12.4", "value1", PARAM_BUFFER(p12, 0)); - } + VASSERT_EQ("12.1", 1, p12.getParameterCount()); + VASSERT_EQ("12.2", "param1", PARAM_NAME(p12, 0)); + VASSERT_EQ("12.3", "us-ascii", PARAM_CHARSET(p12, 0)); + VASSERT_EQ("12.4", "value1", PARAM_BUFFER(p12, 0)); + } - void testGenerate() - { - // Simple parameter/value - parameterizedHeaderField p1; - p1.appendParameter(vmime::parameterFactory::getInstance()->create("param1", "value1")); + void testGenerate() + { + // Simple parameter/value + parameterizedHeaderField p1; + p1.appendParameter(vmime::parameterFactory::getInstance()->create("param1", "value1")); - assert_eq("1", "F: X; param1=value1", p1.generate()); + VASSERT_EQ("1", "F: X; param1=value1", p1.generate()); - // Value that needs quoting (1/2) - parameterizedHeaderField p2a; - p2a.appendParameter(vmime::parameterFactory::getInstance()->create("param1", "value1a;value1b")); + // Value that needs quoting (1/2) + parameterizedHeaderField p2a; + p2a.appendParameter(vmime::parameterFactory::getInstance()->create("param1", "value1a;value1b")); - assert_eq("2a", "F: X; param1=\"value1a;value1b\"", p2a.generate()); + VASSERT_EQ("2a", "F: X; param1=\"value1a;value1b\"", p2a.generate()); - // Value that needs quoting (2/2) - parameterizedHeaderField p2b; - p2b.appendParameter(vmime::parameterFactory::getInstance()->create("param1", "va\\lue\"1")); + // Value that needs quoting (2/2) + parameterizedHeaderField p2b; + p2b.appendParameter(vmime::parameterFactory::getInstance()->create("param1", "va\\lue\"1")); - assert_eq("2b", "F: X; param1=\"va\\\\lue\\\"1\"", p2b.generate()); + VASSERT_EQ("2b", "F: X; param1=\"va\\\\lue\\\"1\"", p2b.generate()); - // Extended parameter with charset specifier - parameterizedHeaderField p3; - p3.appendParameter(vmime::parameterFactory::getInstance()->create("param1", - vmime::word("value 1\xe9", vmime::charset("charset")))); + // Extended parameter with charset specifier + parameterizedHeaderField p3; + p3.appendParameter(vmime::parameterFactory::getInstance()->create("param1", + vmime::word("value 1\xe9", vmime::charset("charset")))); - assert_eq("3", "F: X; param1=\"value 1\";param1*=charset''value%201%E9", p3.generate()); + VASSERT_EQ("3", "F: X; param1=\"value 1\";param1*=charset''value%201%E9", p3.generate()); - // Value that spans on multiple lines - parameterizedHeaderField p4; - p4.appendParameter(vmime::parameterFactory::getInstance()->create("param1", - vmime::word("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", - vmime::charset("charset")))); + // Value that spans on multiple lines + parameterizedHeaderField p4; + p4.appendParameter(vmime::parameterFactory::getInstance()->create("param1", + vmime::word("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", + vmime::charset("charset")))); - assert_eq("4", "F: X; \r\n " - "param1=abcdefghijklm;\r\n " - "param1*0*=charset''abc;\r\n " - "param1*1*=defghijkl;\r\n " - "param1*2*=mnopqrstu;\r\n " - "param1*3*=vwxyzABCD;\r\n " - "param1*4*=EFGHIJKLM;\r\n " - "param1*5*=NOPQRSTUV;\r\n " - "param1*6*=WXYZ", p4.generate(25)); // max line length = 25 - } + VASSERT_EQ("4", "F: X; \r\n " + "param1=abcdefghijklm;\r\n " + "param1*0*=charset''abc;\r\n " + "param1*1*=defghijkl;\r\n " + "param1*2*=mnopqrstu;\r\n " + "param1*3*=vwxyzABCD;\r\n " + "param1*4*=EFGHIJKLM;\r\n " + "param1*5*=NOPQRSTUV;\r\n " + "param1*6*=WXYZ", p4.generate(25)); // max line length = 25 + } - public: +VMIME_TEST_SUITE_END - parameterTest() : suite("vmime::path") - { - vmime::platformDependant::setHandler(); - - add("Parse", testcase(this, "Parse", ¶meterTest::testParse)); - add("Generate", testcase(this, "Generate", ¶meterTest::testGenerate)); - - suite::main().add("vmime::parameter", this); - } - - }; - - parameterTest* theTest = new parameterTest(); -} diff --git a/tests/parser/pathTest.cpp b/tests/parser/pathTest.cpp index a2fc76b8..aca18489 100644 --- a/tests/parser/pathTest.cpp +++ b/tests/parser/pathTest.cpp @@ -17,103 +17,87 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -#include "tests/parser/testUtils.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class pathTest : public suite +#define VMIME_TEST_SUITE pathTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testParse) + VMIME_TEST(testParse2) + VMIME_TEST(testGenerate) + VMIME_TEST_LIST_END + + + void testParse() { - void testParse() - { - vmime::path p1; - p1.parse("<>"); + vmime::path p1; + p1.parse("<>"); - assert_eq("1.1", "", p1.getLocalPart()); - assert_eq("1.2", "", p1.getDomain()); + VASSERT_EQ("1.1", "", p1.getLocalPart()); + VASSERT_EQ("1.2", "", p1.getDomain()); - vmime::path p2; - p2.parse(""); + vmime::path p2; + p2.parse(""); - assert_eq("2.1", "", p2.getLocalPart()); - assert_eq("2.2", "domain", p2.getDomain()); + VASSERT_EQ("2.1", "", p2.getLocalPart()); + VASSERT_EQ("2.2", "domain", p2.getDomain()); - vmime::path p3; - p3.parse(""); + vmime::path p3; + p3.parse(""); - assert_eq("3.1", "local", p3.getLocalPart()); - assert_eq("3.2", "domain", p3.getDomain()); - } + VASSERT_EQ("3.1", "local", p3.getLocalPart()); + VASSERT_EQ("3.2", "domain", p3.getDomain()); + } - void testParse2() - { - // Test some invalid paths (no '<>') - vmime::path p1; - p1.parse(""); + void testParse2() + { + // Test some invalid paths (no '<>') + vmime::path p1; + p1.parse(""); - assert_eq("1.1", "", p1.getLocalPart()); - assert_eq("1.2", "", p1.getDomain()); + VASSERT_EQ("1.1", "", p1.getLocalPart()); + VASSERT_EQ("1.2", "", p1.getDomain()); - vmime::path p2; - p2.parse("domain"); + vmime::path p2; + p2.parse("domain"); - assert_eq("2.1", "", p2.getLocalPart()); - assert_eq("2.2", "domain", p2.getDomain()); + VASSERT_EQ("2.1", "", p2.getLocalPart()); + VASSERT_EQ("2.2", "domain", p2.getDomain()); - vmime::path p3; - p3.parse("local@domain"); + vmime::path p3; + p3.parse("local@domain"); - assert_eq("3.1", "local", p3.getLocalPart()); - assert_eq("3.2", "domain", p3.getDomain()); - } + VASSERT_EQ("3.1", "local", p3.getLocalPart()); + VASSERT_EQ("3.2", "domain", p3.getDomain()); + } - void testGenerate() - { - vmime::path p1; + void testGenerate() + { + vmime::path p1; - assert_eq("1", "<>", p1.generate()); + VASSERT_EQ("1", "<>", p1.generate()); - vmime::path p2; - p2.setLocalPart("local"); + vmime::path p2; + p2.setLocalPart("local"); - assert_eq("2", "", p2.generate()); + VASSERT_EQ("2", "", p2.generate()); - vmime::path p3; - p3.setDomain("domain"); + vmime::path p3; + p3.setDomain("domain"); - assert_eq("3", "<@domain>", p3.generate()); + VASSERT_EQ("3", "<@domain>", p3.generate()); - vmime::path p4; - p4.setLocalPart("local"); - p4.setDomain("domain"); + vmime::path p4; + p4.setLocalPart("local"); + p4.setDomain("domain"); - assert_eq("4", "", p4.generate()); - } + VASSERT_EQ("4", "", p4.generate()); + } - public: +VMIME_TEST_SUITE_END - pathTest() : suite("vmime::path") - { - vmime::platformDependant::setHandler(); - - add("Parse", testcase(this, "Parse", &pathTest::testParse)); - add("Parse2", testcase(this, "Parse2", &pathTest::testParse2)); - add("Generate", testcase(this, "Generate", &pathTest::testGenerate)); - - suite::main().add("vmime::path", this); - } - - }; - - pathTest* theTest = new pathTest(); -} diff --git a/tests/parser/testUtils.hpp b/tests/parser/testUtils.hpp deleted file mode 100644 index 15b6840e..00000000 --- a/tests/parser/testUtils.hpp +++ /dev/null @@ -1,123 +0,0 @@ -// -// VMime library (http://www.vmime.org) -// Copyright (C) 2002-2005 Vincent Richard -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of -// the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// - -#include - - -namespace std -{ - - -std::ostream& operator<<(std::ostream& os, const vmime::charset& ch) -{ - os << "[charset: " << ch.getName() << "]"; - return (os); -} - - -std::ostream& operator<<(std::ostream& os, const vmime::text& txt) -{ - os << "[text: ["; - - for (int i = 0 ; i < txt.getWordCount() ; ++i) - { - const vmime::word& w = *txt.getWordAt(i); - - if (i != 0) - os << ","; - - os << "[word: charset=" << w.getCharset().getName() << ", buffer=" << w.getBuffer() << "]"; - } - - os << "]]"; - - return (os); -} - - -std::ostream& operator<<(std::ostream& os, const vmime::mailbox& mbox) -{ - os << "[mailbox: name=" << mbox.getName() << ", email=" << mbox.getEmail() << "]"; - - return (os); -} - - -std::ostream& operator<<(std::ostream& os, const vmime::mailboxGroup& group) -{ - os << "[mailbox-group: name=" << group.getName() << ", list=["; - - for (int i = 0 ; i < group.getMailboxCount() ; ++i) - { - if (i != 0) - os << ","; - - os << *group.getMailboxAt(i); - } - - os << "]]"; - - return (os); -} - - -std::ostream& operator<<(std::ostream& os, const vmime::addressList& list) -{ - os << "[address-list: ["; - - for (int i = 0 ; i < list.getAddressCount() ; ++i) - { - const vmime::address& addr = *list.getAddressAt(i); - - if (i != 0) - os << ","; - - if (addr.isGroup()) - { - const vmime::mailboxGroup& group = - dynamic_cast (addr); - - os << group; - } - else - { - const vmime::mailbox& mbox = - dynamic_cast (addr); - - os << mbox; - } - } - - os << "]]"; - - return (os); -} - - -std::ostream& operator<<(std::ostream& os, const vmime::datetime& d) -{ - os << "[datetime: " << d.getYear() << "/" << d.getMonth() << "/" << d.getDay(); - os << " " << d.getHour() << ":" << d.getMinute() << ":" << d.getSecond(); - os << " #" << d.getZone() << "]"; - - return (os); -} - - -} diff --git a/tests/parser/textTest.cpp b/tests/parser/textTest.cpp index d07208fb..7109a0b5 100644 --- a/tests/parser/textTest.cpp +++ b/tests/parser/textTest.cpp @@ -17,255 +17,238 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -#include "tests/parser/testUtils.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class textTest : public suite +#define VMIME_TEST_SUITE textTest +#define VMIME_TEST_SUITE_MODULE "Parser" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testConstructors) + VMIME_TEST(testCopy) + VMIME_TEST(testNewFromString) + VMIME_TEST(testDisplayForm) + VMIME_TEST(testParse) + VMIME_TEST(testGenerate) + + VMIME_TEST(testWordConstructors) + VMIME_TEST(testWordParse) + VMIME_TEST(testWordGenerate) + VMIME_TEST_LIST_END + + + void testConstructors() { - void testConstructors() - { - vmime::text t1; + vmime::text t1; - assert_eq("1.1", 0, t1.getWordCount()); + VASSERT_EQ("1.1", 0, t1.getWordCount()); - vmime::text t2("Test\xa9\xc3"); + vmime::text t2("Test\xa9\xc3"); - assert_eq("2.1", 1, t2.getWordCount()); - assert_eq("2.2", "Test\xa9\xc3", t2.getWordAt(0)->getBuffer()); - assert_eq("2.3", vmime::charset::getLocaleCharset(), t2.getWordAt(0)->getCharset()); + VASSERT_EQ("2.1", 1, t2.getWordCount()); + VASSERT_EQ("2.2", "Test\xa9\xc3", t2.getWordAt(0)->getBuffer()); + VASSERT_EQ("2.3", vmime::charset::getLocaleCharset(), t2.getWordAt(0)->getCharset()); - vmime::text t3("Test\xa9\xc3", vmime::charset(vmime::charsets::ISO8859_13)); + vmime::text t3("Test\xa9\xc3", vmime::charset(vmime::charsets::ISO8859_13)); - assert_eq("3.1", 1, t3.getWordCount()); - assert_eq("3.2", "Test\xa9\xc3", t3.getWordAt(0)->getBuffer()); - assert_eq("3.3", vmime::charset(vmime::charsets::ISO8859_13), t3.getWordAt(0)->getCharset()); + VASSERT_EQ("3.1", 1, t3.getWordCount()); + VASSERT_EQ("3.2", "Test\xa9\xc3", t3.getWordAt(0)->getBuffer()); + VASSERT_EQ("3.3", vmime::charset(vmime::charsets::ISO8859_13), t3.getWordAt(0)->getCharset()); - vmime::word w1("Test", vmime::charset(vmime::charsets::UTF_8)); - vmime::text t4(w1); + vmime::word w1("Test", vmime::charset(vmime::charsets::UTF_8)); + vmime::text t4(w1); - assert_eq("4.1", 1, t4.getWordCount()); - assert_eq("4.2", w1.getBuffer(), t4.getWordAt(0)->getBuffer()); - assert_eq("4.3", w1.getCharset(), t4.getWordAt(0)->getCharset()); + VASSERT_EQ("4.1", 1, t4.getWordCount()); + VASSERT_EQ("4.2", w1.getBuffer(), t4.getWordAt(0)->getBuffer()); + VASSERT_EQ("4.3", w1.getCharset(), t4.getWordAt(0)->getCharset()); - vmime::word w2("Other", vmime::charset(vmime::charsets::US_ASCII)); - t4.appendWord(vmime::create (w2)); + vmime::word w2("Other", vmime::charset(vmime::charsets::US_ASCII)); + t4.appendWord(vmime::create (w2)); - vmime::text t5(t4); + vmime::text t5(t4); - assert_eq("5.1", 2, t5.getWordCount()); - assert_eq("5.2", w1.getBuffer(), t5.getWordAt(0)->getBuffer()); - assert_eq("5.3", w1.getCharset(), t5.getWordAt(0)->getCharset()); - assert_eq("5.4", w2.getBuffer(), t5.getWordAt(1)->getBuffer()); - assert_eq("5.5", w2.getCharset(), t5.getWordAt(1)->getCharset()); - } + VASSERT_EQ("5.1", 2, t5.getWordCount()); + VASSERT_EQ("5.2", w1.getBuffer(), t5.getWordAt(0)->getBuffer()); + VASSERT_EQ("5.3", w1.getCharset(), t5.getWordAt(0)->getCharset()); + VASSERT_EQ("5.4", w2.getBuffer(), t5.getWordAt(1)->getBuffer()); + VASSERT_EQ("5.5", w2.getCharset(), t5.getWordAt(1)->getCharset()); + } - void testCopy() - { - vmime::text t1("Test: \xa9\xc3"); + void testCopy() + { + vmime::text t1("Test: \xa9\xc3"); - assert_true("operator==", t1 == t1); - assert_true("clone", *vmime::clone(t1) == t1); + VASSERT("operator==", t1 == t1); + VASSERT("clone", *vmime::clone(t1) == t1); - vmime::text t2; - t2.copyFrom(t1); + vmime::text t2; + t2.copyFrom(t1); - assert_true("copyFrom", t1 == t2); - } + VASSERT("copyFrom", t1 == t2); + } - void testNewFromString() - { - vmime::string s1 = "only ASCII characters"; - vmime::charset c1("test"); - vmime::text t1; + void testNewFromString() + { + vmime::string s1 = "only ASCII characters"; + vmime::charset c1("test"); + vmime::text t1; - t1.createFromString(s1, c1); + t1.createFromString(s1, c1); - assert_eq("1.1", 1, t1.getWordCount()); - assert_eq("1.2", s1, t1.getWordAt(0)->getBuffer()); - assert_eq("1.3", vmime::charset(vmime::charsets::US_ASCII), t1.getWordAt(0)->getCharset()); + VASSERT_EQ("1.1", 1, t1.getWordCount()); + VASSERT_EQ("1.2", s1, t1.getWordAt(0)->getBuffer()); + VASSERT_EQ("1.3", vmime::charset(vmime::charsets::US_ASCII), t1.getWordAt(0)->getCharset()); - vmime::string s2_1 = "some ASCII characters and special chars: "; - vmime::string s2_2 = "\xf1\xf2\xf3\xf4 "; - vmime::string s2_3 = "and then more ASCII chars."; - vmime::string s2 = s2_1 + s2_2 + s2_3; - vmime::charset c2("test"); - vmime::text t2; + vmime::string s2_1 = "some ASCII characters and special chars: "; + vmime::string s2_2 = "\xf1\xf2\xf3\xf4 "; + vmime::string s2_3 = "and then more ASCII chars."; + vmime::string s2 = s2_1 + s2_2 + s2_3; + vmime::charset c2("test"); + vmime::text t2; - t2.createFromString(s2, c2); + t2.createFromString(s2, c2); - assert_eq("2.1", 3, t2.getWordCount()); - assert_eq("2.2", s2_1, t2.getWordAt(0)->getBuffer()); - assert_eq("2.3", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(0)->getCharset()); - assert_eq("2.4", s2_2, t2.getWordAt(1)->getBuffer()); - assert_eq("2.5", c2, t2.getWordAt(1)->getCharset()); - assert_eq("2.6", s2_3, t2.getWordAt(2)->getBuffer()); - assert_eq("2.7", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(2)->getCharset()); - } + VASSERT_EQ("2.1", 3, t2.getWordCount()); + VASSERT_EQ("2.2", s2_1, t2.getWordAt(0)->getBuffer()); + VASSERT_EQ("2.3", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(0)->getCharset()); + VASSERT_EQ("2.4", s2_2, t2.getWordAt(1)->getBuffer()); + VASSERT_EQ("2.5", c2, t2.getWordAt(1)->getCharset()); + VASSERT_EQ("2.6", s2_3, t2.getWordAt(2)->getBuffer()); + VASSERT_EQ("2.7", vmime::charset(vmime::charsets::US_ASCII), t2.getWordAt(2)->getCharset()); + } - static const vmime::string parseText(const vmime::string& buffer) - { - vmime::text t; - t.parse(buffer); + static const vmime::string parseText(const vmime::string& buffer) + { + vmime::text t; + t.parse(buffer); - std::ostringstream oss; - oss << t; + std::ostringstream oss; + oss << t; - return (oss.str()); - } + return (oss.str()); + } - void testParse() - { - // From RFC-2047 - assert_eq("1", "[text: [[word: charset=US-ASCII, buffer=Keith Moore]]]", - parseText("=?US-ASCII?Q?Keith_Moore?=")); + void testParse() + { + // From RFC-2047 + VASSERT_EQ("1", "[text: [[word: charset=US-ASCII, buffer=Keith Moore]]]", + parseText("=?US-ASCII?Q?Keith_Moore?=")); - assert_eq("2", "[text: [[word: charset=ISO-8859-1, buffer=Keld J\xf8rn Simonsen]]]", - parseText("=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?=")); + VASSERT_EQ("2", "[text: [[word: charset=ISO-8859-1, buffer=Keld J\xf8rn Simonsen]]]", + parseText("=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?=")); - assert_eq("3", "[text: [[word: charset=ISO-8859-1, buffer=Andr\xe9]," \ - "[word: charset=us-ascii, buffer= Pirard]]]", - parseText("=?ISO-8859-1?Q?Andr=E9?= Pirard")); + VASSERT_EQ("3", "[text: [[word: charset=ISO-8859-1, buffer=Andr\xe9]," \ + "[word: charset=us-ascii, buffer= Pirard]]]", + parseText("=?ISO-8859-1?Q?Andr=E9?= Pirard")); - assert_eq("4", "[text: [[word: charset=ISO-8859-1, buffer=If you can read this yo]," \ - "[word: charset=ISO-8859-2, buffer=u understand the example.]]]", - parseText("=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\r\n " \ - "=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=")); + VASSERT_EQ("4", "[text: [[word: charset=ISO-8859-1, buffer=If you can read this yo]," \ + "[word: charset=ISO-8859-2, buffer=u understand the example.]]]", + parseText("=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\r\n " \ + "=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=")); - // Bugfix: in "=?charset?q?=XX=YY?=", the "?=" finish - // sequence was not correctly found (should be the one - // after '=YY' and not the one after '?q'). - assert_eq("5", "[text: [[word: charset=abc, buffer=\xe9\xe9]]]", - parseText("=?abc?q?=E9=E9?=")); + // Bugfix: in "=?charset?q?=XX=YY?=", the "?=" finish + // sequence was not correctly found (should be the one + // after '=YY' and not the one after '?q'). + VASSERT_EQ("5", "[text: [[word: charset=abc, buffer=\xe9\xe9]]]", + parseText("=?abc?q?=E9=E9?=")); - // Question marks (?) in the middle of the string - assert_eq("6", "[text: [[word: charset=iso-8859-1, buffer=Know wh\xe4t? It works!]]]", - parseText("=?iso-8859-1?Q?Know_wh=E4t?_It_works!?=")); + // Question marks (?) in the middle of the string + VASSERT_EQ("6", "[text: [[word: charset=iso-8859-1, buffer=Know wh\xe4t? It works!]]]", + parseText("=?iso-8859-1?Q?Know_wh=E4t?_It_works!?=")); - // TODO: add more - } + // TODO: add more + } - void testGenerate() - { - // TODO - } + void testGenerate() + { + // TODO + } - static const vmime::string getDisplayText(const vmime::text& t) - { - vmime::string res; + static const vmime::string getDisplayText(const vmime::text& t) + { + vmime::string res; - for (int i = 0 ; i < t.getWordCount() ; ++i) - res += t.getWordAt(i)->getBuffer(); + for (int i = 0 ; i < t.getWordCount() ; ++i) + res += t.getWordAt(i)->getBuffer(); - return res; - } + return res; + } - void testDisplayForm() - { + void testDisplayForm() + { #define DISPLAY_FORM(x) getDisplayText(*vmime::text::decodeAndUnfold(x)) - // From RFC-2047 - assert_eq("1", "a", DISPLAY_FORM("=?ISO-8859-1?Q?a?=")); - assert_eq("2", "a b", DISPLAY_FORM("=?ISO-8859-1?Q?a?= b")); - assert_eq("3", "ab", DISPLAY_FORM("=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=")); - assert_eq("4", "ab", DISPLAY_FORM("=?ISO-8859-1?Q?a?= \t =?ISO-8859-1?Q?b?=")); - assert_eq("5", "ab", DISPLAY_FORM("=?ISO-8859-1?Q?a?= \r\n \t =?ISO-8859-1?Q?b?=")); - assert_eq("6", "a b", DISPLAY_FORM("=?ISO-8859-1?Q?a_b?=")); - assert_eq("7", "a b", DISPLAY_FORM("=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=")); + // From RFC-2047 + VASSERT_EQ("1", "a", DISPLAY_FORM("=?ISO-8859-1?Q?a?=")); + VASSERT_EQ("2", "a b", DISPLAY_FORM("=?ISO-8859-1?Q?a?= b")); + VASSERT_EQ("3", "ab", DISPLAY_FORM("=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=")); + VASSERT_EQ("4", "ab", DISPLAY_FORM("=?ISO-8859-1?Q?a?= \t =?ISO-8859-1?Q?b?=")); + VASSERT_EQ("5", "ab", DISPLAY_FORM("=?ISO-8859-1?Q?a?= \r\n \t =?ISO-8859-1?Q?b?=")); + VASSERT_EQ("6", "a b", DISPLAY_FORM("=?ISO-8859-1?Q?a_b?=")); + VASSERT_EQ("7", "a b", DISPLAY_FORM("=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=")); - // Some more tests... - assert_eq("8", "a b", DISPLAY_FORM(" a =?ISO-8859-1?Q?b?= ")); - assert_eq("9", "a b ", DISPLAY_FORM(" \t =?ISO-8859-1?Q?a?= b ")); - assert_eq("10", "a b", DISPLAY_FORM(" a\r\n\t b")); + // Some more tests... + VASSERT_EQ("8", "a b", DISPLAY_FORM(" a =?ISO-8859-1?Q?b?= ")); + VASSERT_EQ("9", "a b ", DISPLAY_FORM(" \t =?ISO-8859-1?Q?a?= b ")); + VASSERT_EQ("10", "a b", DISPLAY_FORM(" a\r\n\t b")); #undef DISPLAY_FORM - } + } - void testWordConstructors() - { - assert_eq("1.1", vmime::charset::getLocaleCharset(), vmime::word().getCharset()); - assert_eq("1.2", "", vmime::word().getBuffer()); + void testWordConstructors() + { + VASSERT_EQ("1.1", vmime::charset::getLocaleCharset(), vmime::word().getCharset()); + VASSERT_EQ("1.2", "", vmime::word().getBuffer()); - assert_eq("2.1", vmime::charset::getLocaleCharset(), vmime::word("foo").getCharset()); - assert_eq("2.2", "foo", vmime::word("foo").getBuffer()); + VASSERT_EQ("2.1", vmime::charset::getLocaleCharset(), vmime::word("foo").getCharset()); + VASSERT_EQ("2.2", "foo", vmime::word("foo").getBuffer()); - assert_eq("3.1", "bar", vmime::word("foo", vmime::charset("bar")).getCharset().getName()); - assert_eq("3.2", "foo", vmime::word("foo", vmime::charset("bar")).getBuffer()); - } + VASSERT_EQ("3.1", "bar", vmime::word("foo", vmime::charset("bar")).getCharset().getName()); + VASSERT_EQ("3.2", "foo", vmime::word("foo", vmime::charset("bar")).getBuffer()); + } - void testWordParse() - { - // Simple encoded word - vmime::word w1; - w1.parse("=?foo?q?bar=E9 baz?="); + void testWordParse() + { + // Simple encoded word + vmime::word w1; + w1.parse("=?foo?q?bar=E9 baz?="); - assert_eq("1.1", "foo", w1.getCharset().getName()); - assert_eq("1.2", "bar\xe9 baz", w1.getBuffer()); + VASSERT_EQ("1.1", "foo", w1.getCharset().getName()); + VASSERT_EQ("1.2", "bar\xe9 baz", w1.getBuffer()); - // Unencoded text - vmime::word w2; - w2.parse(" foo bar \tbaz..."); + // Unencoded text + vmime::word w2; + w2.parse(" foo bar \tbaz..."); - assert_eq("2.1", vmime::charset(vmime::charsets::US_ASCII), w2.getCharset()); - assert_eq("2.2", " foo bar \tbaz...", w2.getBuffer()); + VASSERT_EQ("2.1", vmime::charset(vmime::charsets::US_ASCII), w2.getCharset()); + VASSERT_EQ("2.2", " foo bar \tbaz...", w2.getBuffer()); - // Malformed word - vmime::word w3; - w3.parse("=?foo bar"); + // Malformed word + vmime::word w3; + w3.parse("=?foo bar"); - assert_eq("3.1", vmime::charset(vmime::charsets::US_ASCII), w3.getCharset()); - assert_eq("3.2", "=?foo bar", w3.getBuffer()); + VASSERT_EQ("3.1", vmime::charset(vmime::charsets::US_ASCII), w3.getCharset()); + VASSERT_EQ("3.2", "=?foo bar", w3.getBuffer()); - // Unknown encoding - vmime::word w4; - w4.parse("=?whatever?not_q_or_b?whatever?="); + // Unknown encoding + vmime::word w4; + w4.parse("=?whatever?not_q_or_b?whatever?="); - assert_eq("4.1", vmime::charset(vmime::charsets::US_ASCII), w4.getCharset()); - assert_eq("4.2", "=?whatever?not_q_or_b?whatever?=", w4.getBuffer()); - } + VASSERT_EQ("4.1", vmime::charset(vmime::charsets::US_ASCII), w4.getCharset()); + VASSERT_EQ("4.2", "=?whatever?not_q_or_b?whatever?=", w4.getBuffer()); + } - void testWordGenerate() - { - assert_eq("1", "=?foo?Q?bar=E9_baz?=", - vmime::word("bar\xe9 baz", vmime::charset("foo")).generate()); + void testWordGenerate() + { + VASSERT_EQ("1", "=?foo?Q?bar=E9_baz?=", + vmime::word("bar\xe9 baz", vmime::charset("foo")).generate()); - assert_eq("2", "=?foo?B?8fLz9PU=?=", - vmime::word("\xf1\xf2\xf3\xf4\xf5", vmime::charset("foo")).generate()); - } + VASSERT_EQ("2", "=?foo?B?8fLz9PU=?=", + vmime::word("\xf1\xf2\xf3\xf4\xf5", vmime::charset("foo")).generate()); + } - public: +VMIME_TEST_SUITE_END - textTest() : suite("vmime::text") - { - vmime::platformDependant::setHandler(); - - add("Constructors", testcase(this, "Constructors", &textTest::testConstructors)); - add("Copy", testcase(this, "Copy", &textTest::testCopy)); - add("NewFromString", testcase(this, "NewFromString", &textTest::testNewFromString)); - add("DisplayForm", testcase(this, "DisplayForm", &textTest::testDisplayForm)); - add("Parse", testcase(this, "Parse", &textTest::testParse)); - add("Generate", testcase(this, "Generate", &textTest::testGenerate)); - - add("WordConstructors", testcase(this, "WordConstructors", &textTest::testWordConstructors)); - add("WordParse", testcase(this, "WordParse", &textTest::testWordParse)); - add("WordGenerate", testcase(this, "WordGenerate", &textTest::testWordGenerate)); - - suite::main().add("vmime::text", this); - } - - }; - - textTest* theTest = new textTest(); -} diff --git a/tests/testRunner.cpp b/tests/testRunner.cpp new file mode 100644 index 00000000..fb8d9108 --- /dev/null +++ b/tests/testRunner.cpp @@ -0,0 +1,54 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2005 Vincent Richard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#include +#include +#include + +#include "vmime/vmime.hpp" +#include "vmime/platforms/posix/posixHandler.hpp" + + +int main(int argc, char* argv[]) +{ + // VMime initialization + vmime::platformDependant::setHandler(); + + // Get the top level suite from the registry + CppUnit::Test* suite = NULL; + + if (argc > 1) + suite = CppUnit::TestFactoryRegistry::getRegistry(argv[1]).makeTest(); + else + suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); + + // Adds the test to the list of test to run + CppUnit::TextUi::TestRunner runner; + runner.addTest(suite); + + // Change the default outputter to a compiler error format outputter +// runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), std::cerr)); + + // Run the tests + const bool wasSucessful = runner.run(); + + // Return error code 1 if the one of test failed + return wasSucessful ? 0 : 1; +} + diff --git a/tests/testUtils.hpp b/tests/testUtils.hpp new file mode 100644 index 00000000..cb4549e0 --- /dev/null +++ b/tests/testUtils.hpp @@ -0,0 +1,182 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2005 Vincent Richard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#include +#include +#include +#include + + +// VMime +#include "vmime/vmime.hpp" + + +// CppUnit +#include +#include + +#define VASSERT(msg, cond) \ + CPPUNIT_ASSERT_MESSAGE(std::string(msg), cond) + +#define VASSERT_TRUE(msg, cond) \ + VASSERT(msg, cond) +#define VASSERT_FALSE(msg, cond) \ + VASSERT(!(msg, cond)) + +#define VASSERT_EQ(msg, expected, actual) \ + CPPUNIT_ASSERT_EQUAL_MESSAGE(std::string(msg), expected, actual) + +#define VASSERT_THROW(msg, expression, exceptionType) \ + CPPUNIT_ASSERT_THROW(expression, exceptionType) +#define VASSERT_NO_THROW(msg, expression) \ + CPPUNIT_ASSERT_NO_THROW(expression) + +#define VMIME_TEST_SUITE_BEGIN \ + class VMIME_TEST_SUITE : public CppUnit::TestFixture { public: +#define VMIME_TEST_SUITE_END \ + }; \ + \ + static CppUnit::AutoRegisterSuite (autoRegisterRegistry1); \ + static CppUnit::AutoRegisterSuite (autoRegisterRegistry2)(VMIME_TEST_SUITE_MODULE); + +#define VMIME_TEST_LIST_BEGIN CPPUNIT_TEST_SUITE(VMIME_TEST_SUITE); +#define VMIME_TEST_LIST_END CPPUNIT_TEST_SUITE_END(); +#define VMIME_TEST(name) CPPUNIT_TEST(name); + + +namespace CppUnit +{ + // Work-around for comparing 'std::string' against 'char*' + inline void assertEquals(const char* expected, const std::string actual, + SourceLine sourceLine, const std::string &message) + { + assertEquals(std::string(expected), actual, sourceLine, message); + } + + template + void assertEquals(const X expected, const Y actual, + SourceLine sourceLine, const std::string &message) + { + assertEquals(static_cast (expected), actual, sourceLine, message); + } +} + + +namespace std +{ + + +inline std::ostream& operator<<(std::ostream& os, const vmime::charset& ch) +{ + os << "[charset: " << ch.getName() << "]"; + return (os); +} + + +inline std::ostream& operator<<(std::ostream& os, const vmime::text& txt) +{ + os << "[text: ["; + + for (int i = 0 ; i < txt.getWordCount() ; ++i) + { + const vmime::word& w = *txt.getWordAt(i); + + if (i != 0) + os << ","; + + os << "[word: charset=" << w.getCharset().getName() << ", buffer=" << w.getBuffer() << "]"; + } + + os << "]]"; + + return (os); +} + + +inline std::ostream& operator<<(std::ostream& os, const vmime::mailbox& mbox) +{ + os << "[mailbox: name=" << mbox.getName() << ", email=" << mbox.getEmail() << "]"; + + return (os); +} + + +inline std::ostream& operator<<(std::ostream& os, const vmime::mailboxGroup& group) +{ + os << "[mailbox-group: name=" << group.getName() << ", list=["; + + for (int i = 0 ; i < group.getMailboxCount() ; ++i) + { + if (i != 0) + os << ","; + + os << *group.getMailboxAt(i); + } + + os << "]]"; + + return (os); +} + + +inline std::ostream& operator<<(std::ostream& os, const vmime::addressList& list) +{ + os << "[address-list: ["; + + for (int i = 0 ; i < list.getAddressCount() ; ++i) + { + const vmime::address& addr = *list.getAddressAt(i); + + if (i != 0) + os << ","; + + if (addr.isGroup()) + { + const vmime::mailboxGroup& group = + dynamic_cast (addr); + + os << group; + } + else + { + const vmime::mailbox& mbox = + dynamic_cast (addr); + + os << mbox; + } + } + + os << "]]"; + + return (os); +} + + +inline std::ostream& operator<<(std::ostream& os, const vmime::datetime& d) +{ + os << "[datetime: " << d.getYear() << "/" << d.getMonth() << "/" << d.getDay(); + os << " " << d.getHour() << ":" << d.getMinute() << ":" << d.getSecond(); + os << " #" << d.getZone() << "]"; + + return (os); +} + + +} + diff --git a/tests/utility/filteredStreamTest.cpp b/tests/utility/filteredStreamTest.cpp index 0552902a..ca974774 100644 --- a/tests/utility/filteredStreamTest.cpp +++ b/tests/utility/filteredStreamTest.cpp @@ -17,274 +17,257 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" +#include "tests/testUtils.hpp" #include "vmime/utility/filteredStream.hpp" -using namespace unitpp; + +#define VMIME_TEST_SUITE filteredStreamTest +#define VMIME_TEST_SUITE_MODULE "Utility" -namespace -{ - class filteredStreamTest : public suite +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testDotFilteredInputStream) + VMIME_TEST(testDotFilteredOutputStream) + VMIME_TEST(testCRLFToLFFilteredOutputStream) + VMIME_TEST(testStopSequenceFilteredInputStream1) + VMIME_TEST(testStopSequenceFilteredInputStreamN_2) + VMIME_TEST(testStopSequenceFilteredInputStreamN_3) + VMIME_TEST_LIST_END + + + class chunkInputStream : public vmime::utility::inputStream { - class chunkInputStream : public vmime::utility::inputStream - { - private: + private: - std::vector m_chunks; - std::vector ::size_type m_index; - - public: - - chunkInputStream() : m_index(0) { } - - void addChunk(const std::string& chunk) { m_chunks.push_back(chunk); } - - const bool eof() const { return (m_index >= m_chunks.size()); } - void reset() { m_index = 0; } - - const size_type read(value_type* const data, const size_type /* count */) - { - if (eof()) - return 0; - - const std::string chunk = m_chunks[m_index]; - - // Warning: 'count' should be larger than chunk length. - // This is OK for our tests. - std::copy(chunk.begin(), chunk.end(), data); - - ++m_index; - - return chunk.length(); - } - - const size_type skip(const size_type /* count */) - { - // Not supported - return 0; - } - }; - - - const std::string readWhole(vmime::utility::inputStream& is) - { - vmime::utility::stream::value_type buffer[256]; - std::string whole; - - while (!is.eof()) - { - const vmime::utility::stream::size_type read = - is.read(buffer, sizeof(buffer)); - - whole += std::string(buffer, read); - } - - return (whole); - } - - - // dotFilteredInputStream - - void testDotFilteredInputStreamHelper - (const std::string& number, const std::string& expected, - const std::string& c1, const std::string& c2 = "", - const std::string& c3 = "", const std::string& c4 = "") - { - chunkInputStream cis; - cis.addChunk(c1); - if (!c2.empty()) cis.addChunk(c2); - if (!c3.empty()) cis.addChunk(c3); - if (!c4.empty()) cis.addChunk(c4); - - vmime::utility::dotFilteredInputStream is(cis); - - std::ostringstream oss; - vmime::utility::outputStreamAdapter os(oss); - - vmime::utility::bufferedStreamCopy(is, os); - - assert_eq(number, expected, oss.str()); - } - - void testDotFilteredInputStream() - { - testDotFilteredInputStreamHelper("1", "foo\n.bar", "foo\n..bar"); - testDotFilteredInputStreamHelper("2", "foo\n.bar", "foo\n", "..bar"); - testDotFilteredInputStreamHelper("3", "foo\n.bar", "foo\n.", ".bar"); - testDotFilteredInputStreamHelper("4", "foo\n.bar", "foo\n..", "bar"); - testDotFilteredInputStreamHelper("5", "foo\n.bar", "foo\n", ".", ".bar"); - testDotFilteredInputStreamHelper("6", "foo\n.bar", "foo\n", ".", ".", "bar"); - } - - // dotFilteredOutputStream - // CRLFToLFFilteredOutputStream - - template - void testFilteredOutputStreamHelper - (const std::string& number, const std::string& expected, - const std::string& c1, const std::string& c2 = "", - const std::string& c3 = "", const std::string& c4 = "") - { - std::ostringstream oss; - vmime::utility::outputStreamAdapter os(oss); - - FILTER fos(os); - - fos.write(c1.data(), c1.length()); - if (!c2.empty()) fos.write(c2.data(), c2.length()); - if (!c3.empty()) fos.write(c3.data(), c3.length()); - if (!c4.empty()) fos.write(c4.data(), c4.length()); - - assert_eq(number, expected, oss.str()); - } - - void testDotFilteredOutputStream() - { - typedef vmime::utility::dotFilteredOutputStream FILTER; - - testFilteredOutputStreamHelper("1", "foo\n..bar", "foo\n.bar"); - testFilteredOutputStreamHelper("2", "foo\n..bar", "foo\n", ".bar"); - testFilteredOutputStreamHelper("3", "foo\n..bar", "foo", "\n.bar"); - testFilteredOutputStreamHelper("4", "foo\n..bar", "foo", "\n", ".bar"); - testFilteredOutputStreamHelper("5", "foo\n..bar", "foo", "\n", ".", "bar"); - } - - void testCRLFToLFFilteredOutputStream() - { - typedef vmime::utility::CRLFToLFFilteredOutputStream FILTER; - - testFilteredOutputStreamHelper("1", "foo\nbar", "foo\r\nbar"); - testFilteredOutputStreamHelper("2", "foo\nbar", "foo\r\n", "bar"); - testFilteredOutputStreamHelper("3", "foo\nbar", "foo\r", "\nbar"); - testFilteredOutputStreamHelper("4", "foo\nbar", "foo", "\r\nbar"); - testFilteredOutputStreamHelper("5", "foo\nbar", "foo", "\r", "\nbar"); - testFilteredOutputStreamHelper("6", "foo\nbar", "foo", "\r", "\n", "bar"); - } - - // stopSequenceFilteredInputStream - - template - void testStopSequenceFISHelper - (const std::string& number, const std::string& sequence, - const std::string& expected, const std::string& c1, - const std::string& c2 = "", const std::string& c3 = "", - const std::string& c4 = "", const std::string& c5 = "") - { - chunkInputStream cis; - cis.addChunk(c1); - if (!c2.empty()) cis.addChunk(c2); - if (!c3.empty()) cis.addChunk(c3); - if (!c4.empty()) cis.addChunk(c4); - if (!c5.empty()) cis.addChunk(c5); - - vmime::utility::stopSequenceFilteredInputStream is(cis, sequence.data()); - - assert_eq(number, expected, readWhole(is)); - } - - void testStopSequenceFilteredInputStream1() - { - testStopSequenceFISHelper <1>("1", "x", "foo", "fooxbar"); - testStopSequenceFISHelper <1>("2", "x", "foo", "foox", "bar"); - testStopSequenceFISHelper <1>("3", "x", "foo", "foo", "x", "bar"); - testStopSequenceFISHelper <1>("4", "x", "foo", "fo", "o", "x", "bar"); - testStopSequenceFISHelper <1>("5", "x", "foo", "fo", "o", "x", "b", "ar"); - - testStopSequenceFISHelper <1>("6", "x", "foobar", "fo", "o", "b", "ar"); - testStopSequenceFISHelper <1>("7", "x", "foobar", "foo", "bar"); - testStopSequenceFISHelper <1>("8", "x", "foobar", "foo", "b", "ar"); - - testStopSequenceFISHelper <1>("9", "x", "foobar", "foobar"); - testStopSequenceFISHelper <1>("10", "x", "foobar", "foobarx"); - - testStopSequenceFISHelper <1>("11", "x", "", ""); - testStopSequenceFISHelper <1>("12", "x", "", "x"); - testStopSequenceFISHelper <1>("13", "x", "", "", "x"); - } - - void testStopSequenceFilteredInputStreamN_2() - { - testStopSequenceFISHelper <2>("1", "xy", "foo", "fooxybar"); - testStopSequenceFISHelper <2>("2", "xy", "foo", "foox", "ybar"); - testStopSequenceFISHelper <2>("3", "xy", "foo", "foox", "y", "bar"); - testStopSequenceFISHelper <2>("4", "xy", "foo", "foo", "x", "ybar"); - testStopSequenceFISHelper <2>("5", "xy", "foo", "foo", "xy", "bar"); - testStopSequenceFISHelper <2>("6", "xy", "foo", "foo", "x", "y", "bar"); - - testStopSequenceFISHelper <2>("7", "xy", "fooxbar", "foox", "bar"); - testStopSequenceFISHelper <2>("8", "xy", "fooxbar", "foo", "xbar"); - testStopSequenceFISHelper <2>("9", "xy", "fooxbar", "foo", "x", "bar"); - testStopSequenceFISHelper <2>("10", "xy", "foobarx", "foo", "barx"); - - testStopSequenceFISHelper <2>("11", "xy", "foobar", "foobarxy"); - testStopSequenceFISHelper <2>("12", "xy", "foobar", "foo", "barxy"); - testStopSequenceFISHelper <2>("13", "xy", "foobar", "foo", "bar", "xy"); - - testStopSequenceFISHelper <2>("14", "xy", "", ""); - testStopSequenceFISHelper <2>("15", "xy", "x", "x"); - testStopSequenceFISHelper <2>("16", "xy", "", "xy"); - testStopSequenceFISHelper <2>("17", "xy", "", "x", "y"); - } - - void testStopSequenceFilteredInputStreamN_3() - { - testStopSequenceFISHelper <3>("1", "xyz", "foo", "fooxyzbar"); - testStopSequenceFISHelper <3>("2", "xyz", "foo", "foox", "yzbar"); - testStopSequenceFISHelper <3>("3", "xyz", "foo", "foox", "y", "zbar"); - testStopSequenceFISHelper <3>("4", "xyz", "foo", "foox", "yz", "bar"); - testStopSequenceFISHelper <3>("5", "xyz", "foo", "foo", "xyz", "bar"); - testStopSequenceFISHelper <3>("6", "xyz", "foo", "foo", "xy", "zbar"); - testStopSequenceFISHelper <3>("7", "xyz", "foo", "foo", "x", "y", "zbar"); - testStopSequenceFISHelper <3>("8", "xyz", "foo", "foo", "x", "y", "z", "bar"); - testStopSequenceFISHelper <3>("9", "xyz", "foo", "fooxy", "z", "bar"); - - testStopSequenceFISHelper <3>("10", "xyz", "fooxybar", "foox", "y", "bar"); - testStopSequenceFISHelper <3>("11", "xyz", "fooxybar", "fooxy", "bar"); - testStopSequenceFISHelper <3>("12", "xyz", "fooxybar", "fo", "ox", "y", "bar"); - testStopSequenceFISHelper <3>("13", "xyz", "fooxybar", "fo", "o", "x", "y", "bar"); - testStopSequenceFISHelper <3>("14", "xyz", "fooxybar", "foo", "x", "ybar"); - testStopSequenceFISHelper <3>("15", "xyz", "fooxybar", "foo", "xybar"); - - testStopSequenceFISHelper <3>("16", "xyz", "xfoxoxybxar", "xfoxo", "xybxar"); - testStopSequenceFISHelper <3>("17", "xyz", "xfoxoxybxarx", "xfoxo", "xybxarx"); - testStopSequenceFISHelper <3>("18", "xyz", "xfoxoxybxarxy", "xfoxo", "xybxarxy"); - - testStopSequenceFISHelper <3>("19", "xyz", "", ""); - testStopSequenceFISHelper <3>("20", "xyz", "x", "x"); - testStopSequenceFISHelper <3>("21", "xyz", "xy", "xy"); - testStopSequenceFISHelper <3>("22", "xyz", "", "xyz"); - testStopSequenceFISHelper <3>("23", "xyz", "", "x", "yz"); - testStopSequenceFISHelper <3>("24", "xyz", "", "x", "y", "z"); - } + std::vector m_chunks; + std::vector ::size_type m_index; public: - filteredStreamTest() : suite("vmime::utility::filteredStream") + chunkInputStream() : m_index(0) { } + + void addChunk(const std::string& chunk) { m_chunks.push_back(chunk); } + + const bool eof() const { return (m_index >= m_chunks.size()); } + void reset() { m_index = 0; } + + const size_type read(value_type* const data, const size_type /* count */) { - // VMime initialization - vmime::platformDependant::setHandler(); + if (eof()) + return 0; - add("dotFilteredInputStream", testcase(this, "dotFilteredInputStream", &filteredStreamTest::testDotFilteredInputStream)); - add("dotFilteredOutputStream", testcase(this, "dotFilteredOutputStream", &filteredStreamTest::testDotFilteredOutputStream)); - add("CRLFToLFFilteredOutputStream", testcase(this, "CRLFToLFFilteredOutputStream", &filteredStreamTest::testCRLFToLFFilteredOutputStream)); - add("stopSequenceFilteredInputStream1", testcase(this, "stopSequenceFilteredInputStream1", &filteredStreamTest::testStopSequenceFilteredInputStream1)); - add("stopSequenceFilteredInputStreamN_2", testcase(this, "stopSequenceFilteredInputStreamN_2", &filteredStreamTest::testStopSequenceFilteredInputStreamN_2)); - add("stopSequenceFilteredInputStreamN_3", testcase(this, "stopSequenceFilteredInputStreamN_3", &filteredStreamTest::testStopSequenceFilteredInputStreamN_3)); + const std::string chunk = m_chunks[m_index]; - suite::main().add("vmime::utility::filteredStream", this); + // Warning: 'count' should be larger than chunk length. + // This is OK for our tests. + std::copy(chunk.begin(), chunk.end(), data); + + ++m_index; + + return chunk.length(); } + const size_type skip(const size_type /* count */) + { + // Not supported + return 0; + } }; - filteredStreamTest* theTest = new filteredStreamTest(); -} + + const std::string readWhole(vmime::utility::inputStream& is) + { + vmime::utility::stream::value_type buffer[256]; + std::string whole; + + while (!is.eof()) + { + const vmime::utility::stream::size_type read = + is.read(buffer, sizeof(buffer)); + + whole += std::string(buffer, read); + } + + return (whole); + } + + + // dotFilteredInputStream + + void testDotFilteredInputStreamHelper + (const std::string& number, const std::string& expected, + const std::string& c1, const std::string& c2 = "", + const std::string& c3 = "", const std::string& c4 = "") + { + chunkInputStream cis; + cis.addChunk(c1); + if (!c2.empty()) cis.addChunk(c2); + if (!c3.empty()) cis.addChunk(c3); + if (!c4.empty()) cis.addChunk(c4); + + vmime::utility::dotFilteredInputStream is(cis); + + std::ostringstream oss; + vmime::utility::outputStreamAdapter os(oss); + + vmime::utility::bufferedStreamCopy(is, os); + + VASSERT_EQ(number, expected, oss.str()); + } + + void testDotFilteredInputStream() + { + testDotFilteredInputStreamHelper("1", "foo\n.bar", "foo\n..bar"); + testDotFilteredInputStreamHelper("2", "foo\n.bar", "foo\n", "..bar"); + testDotFilteredInputStreamHelper("3", "foo\n.bar", "foo\n.", ".bar"); + testDotFilteredInputStreamHelper("4", "foo\n.bar", "foo\n..", "bar"); + testDotFilteredInputStreamHelper("5", "foo\n.bar", "foo\n", ".", ".bar"); + testDotFilteredInputStreamHelper("6", "foo\n.bar", "foo\n", ".", ".", "bar"); + } + + // dotFilteredOutputStream + // CRLFToLFFilteredOutputStream + + template + void testFilteredOutputStreamHelper + (const std::string& number, const std::string& expected, + const std::string& c1, const std::string& c2 = "", + const std::string& c3 = "", const std::string& c4 = "") + { + std::ostringstream oss; + vmime::utility::outputStreamAdapter os(oss); + + FILTER fos(os); + + fos.write(c1.data(), c1.length()); + if (!c2.empty()) fos.write(c2.data(), c2.length()); + if (!c3.empty()) fos.write(c3.data(), c3.length()); + if (!c4.empty()) fos.write(c4.data(), c4.length()); + + VASSERT_EQ(number, expected, oss.str()); + } + + void testDotFilteredOutputStream() + { + typedef vmime::utility::dotFilteredOutputStream FILTER; + + testFilteredOutputStreamHelper("1", "foo\n..bar", "foo\n.bar"); + testFilteredOutputStreamHelper("2", "foo\n..bar", "foo\n", ".bar"); + testFilteredOutputStreamHelper("3", "foo\n..bar", "foo", "\n.bar"); + testFilteredOutputStreamHelper("4", "foo\n..bar", "foo", "\n", ".bar"); + testFilteredOutputStreamHelper("5", "foo\n..bar", "foo", "\n", ".", "bar"); + } + + void testCRLFToLFFilteredOutputStream() + { + typedef vmime::utility::CRLFToLFFilteredOutputStream FILTER; + + testFilteredOutputStreamHelper("1", "foo\nbar", "foo\r\nbar"); + testFilteredOutputStreamHelper("2", "foo\nbar", "foo\r\n", "bar"); + testFilteredOutputStreamHelper("3", "foo\nbar", "foo\r", "\nbar"); + testFilteredOutputStreamHelper("4", "foo\nbar", "foo", "\r\nbar"); + testFilteredOutputStreamHelper("5", "foo\nbar", "foo", "\r", "\nbar"); + testFilteredOutputStreamHelper("6", "foo\nbar", "foo", "\r", "\n", "bar"); + } + + // stopSequenceFilteredInputStream + + template + void testStopSequenceFISHelper + (const std::string& number, const std::string& sequence, + const std::string& expected, const std::string& c1, + const std::string& c2 = "", const std::string& c3 = "", + const std::string& c4 = "", const std::string& c5 = "") + { + chunkInputStream cis; + cis.addChunk(c1); + if (!c2.empty()) cis.addChunk(c2); + if (!c3.empty()) cis.addChunk(c3); + if (!c4.empty()) cis.addChunk(c4); + if (!c5.empty()) cis.addChunk(c5); + + vmime::utility::stopSequenceFilteredInputStream is(cis, sequence.data()); + + VASSERT_EQ(number, expected, readWhole(is)); + } + + void testStopSequenceFilteredInputStream1() + { + testStopSequenceFISHelper <1>("1", "x", "foo", "fooxbar"); + testStopSequenceFISHelper <1>("2", "x", "foo", "foox", "bar"); + testStopSequenceFISHelper <1>("3", "x", "foo", "foo", "x", "bar"); + testStopSequenceFISHelper <1>("4", "x", "foo", "fo", "o", "x", "bar"); + testStopSequenceFISHelper <1>("5", "x", "foo", "fo", "o", "x", "b", "ar"); + + testStopSequenceFISHelper <1>("6", "x", "foobar", "fo", "o", "b", "ar"); + testStopSequenceFISHelper <1>("7", "x", "foobar", "foo", "bar"); + testStopSequenceFISHelper <1>("8", "x", "foobar", "foo", "b", "ar"); + + testStopSequenceFISHelper <1>("9", "x", "foobar", "foobar"); + testStopSequenceFISHelper <1>("10", "x", "foobar", "foobarx"); + + testStopSequenceFISHelper <1>("11", "x", "", ""); + testStopSequenceFISHelper <1>("12", "x", "", "x"); + testStopSequenceFISHelper <1>("13", "x", "", "", "x"); + } + + void testStopSequenceFilteredInputStreamN_2() + { + testStopSequenceFISHelper <2>("1", "xy", "foo", "fooxybar"); + testStopSequenceFISHelper <2>("2", "xy", "foo", "foox", "ybar"); + testStopSequenceFISHelper <2>("3", "xy", "foo", "foox", "y", "bar"); + testStopSequenceFISHelper <2>("4", "xy", "foo", "foo", "x", "ybar"); + testStopSequenceFISHelper <2>("5", "xy", "foo", "foo", "xy", "bar"); + testStopSequenceFISHelper <2>("6", "xy", "foo", "foo", "x", "y", "bar"); + + testStopSequenceFISHelper <2>("7", "xy", "fooxbar", "foox", "bar"); + testStopSequenceFISHelper <2>("8", "xy", "fooxbar", "foo", "xbar"); + testStopSequenceFISHelper <2>("9", "xy", "fooxbar", "foo", "x", "bar"); + testStopSequenceFISHelper <2>("10", "xy", "foobarx", "foo", "barx"); + + testStopSequenceFISHelper <2>("11", "xy", "foobar", "foobarxy"); + testStopSequenceFISHelper <2>("12", "xy", "foobar", "foo", "barxy"); + testStopSequenceFISHelper <2>("13", "xy", "foobar", "foo", "bar", "xy"); + + testStopSequenceFISHelper <2>("14", "xy", "", ""); + testStopSequenceFISHelper <2>("15", "xy", "x", "x"); + testStopSequenceFISHelper <2>("16", "xy", "", "xy"); + testStopSequenceFISHelper <2>("17", "xy", "", "x", "y"); + } + + void testStopSequenceFilteredInputStreamN_3() + { + testStopSequenceFISHelper <3>("1", "xyz", "foo", "fooxyzbar"); + testStopSequenceFISHelper <3>("2", "xyz", "foo", "foox", "yzbar"); + testStopSequenceFISHelper <3>("3", "xyz", "foo", "foox", "y", "zbar"); + testStopSequenceFISHelper <3>("4", "xyz", "foo", "foox", "yz", "bar"); + testStopSequenceFISHelper <3>("5", "xyz", "foo", "foo", "xyz", "bar"); + testStopSequenceFISHelper <3>("6", "xyz", "foo", "foo", "xy", "zbar"); + testStopSequenceFISHelper <3>("7", "xyz", "foo", "foo", "x", "y", "zbar"); + testStopSequenceFISHelper <3>("8", "xyz", "foo", "foo", "x", "y", "z", "bar"); + testStopSequenceFISHelper <3>("9", "xyz", "foo", "fooxy", "z", "bar"); + + testStopSequenceFISHelper <3>("10", "xyz", "fooxybar", "foox", "y", "bar"); + testStopSequenceFISHelper <3>("11", "xyz", "fooxybar", "fooxy", "bar"); + testStopSequenceFISHelper <3>("12", "xyz", "fooxybar", "fo", "ox", "y", "bar"); + testStopSequenceFISHelper <3>("13", "xyz", "fooxybar", "fo", "o", "x", "y", "bar"); + testStopSequenceFISHelper <3>("14", "xyz", "fooxybar", "foo", "x", "ybar"); + testStopSequenceFISHelper <3>("15", "xyz", "fooxybar", "foo", "xybar"); + + testStopSequenceFISHelper <3>("16", "xyz", "xfoxoxybxar", "xfoxo", "xybxar"); + testStopSequenceFISHelper <3>("17", "xyz", "xfoxoxybxarx", "xfoxo", "xybxarx"); + testStopSequenceFISHelper <3>("18", "xyz", "xfoxoxybxarxy", "xfoxo", "xybxarxy"); + + testStopSequenceFISHelper <3>("19", "xyz", "", ""); + testStopSequenceFISHelper <3>("20", "xyz", "x", "x"); + testStopSequenceFISHelper <3>("21", "xyz", "xy", "xy"); + testStopSequenceFISHelper <3>("22", "xyz", "", "xyz"); + testStopSequenceFISHelper <3>("23", "xyz", "", "x", "yz"); + testStopSequenceFISHelper <3>("24", "xyz", "", "x", "y", "z"); + } + +VMIME_TEST_SUITE_END diff --git a/tests/utility/md5Test.cpp b/tests/utility/md5Test.cpp index 94fb3cd2..a55fddf7 100644 --- a/tests/utility/md5Test.cpp +++ b/tests/utility/md5Test.cpp @@ -17,96 +17,82 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" +#include "tests/testUtils.hpp" -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" #include "vmime/utility/md5.hpp" -using namespace unitpp; + +#define VMIME_TEST_SUITE md5Test +#define VMIME_TEST_SUITE_MODULE "Utility" -namespace -{ - class md5Test : public suite +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testString) + VMIME_TEST(testUpdate) + VMIME_TEST_LIST_END + + + void testString() { - void testString() - { - // Test suites from RFC #1321 - assert_eq("1", "d41d8cd98f00b204e9800998ecf8427e", vmime::utility::md5("").hex()); - assert_eq("2", "0cc175b9c0f1b6a831c399e269772661", vmime::utility::md5("a").hex()); - assert_eq("3", "900150983cd24fb0d6963f7d28e17f72", vmime::utility::md5("abc").hex()); - assert_eq("4", "f96b697d7cb7938d525a2f31aaf161d0", vmime::utility::md5("message digest").hex()); - assert_eq("5", "c3fcd3d76192e4007dfb496cca67e13b", vmime::utility::md5("abcdefghijklmnopqrstuvwxyz").hex()); - assert_eq("6", "d174ab98d277d9f5a5611c2c9f419d9f", vmime::utility::md5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789").hex()); - assert_eq("7", "57edf4a22be3c955ac49da2e2107b67a", vmime::utility::md5("12345678901234567890123456789012345678901234567890123456789012345678901234567890").hex()); - } + // Test suites from RFC #1321 + VASSERT_EQ("1", "d41d8cd98f00b204e9800998ecf8427e", vmime::utility::md5("").hex()); + VASSERT_EQ("2", "0cc175b9c0f1b6a831c399e269772661", vmime::utility::md5("a").hex()); + VASSERT_EQ("3", "900150983cd24fb0d6963f7d28e17f72", vmime::utility::md5("abc").hex()); + VASSERT_EQ("4", "f96b697d7cb7938d525a2f31aaf161d0", vmime::utility::md5("message digest").hex()); + VASSERT_EQ("5", "c3fcd3d76192e4007dfb496cca67e13b", vmime::utility::md5("abcdefghijklmnopqrstuvwxyz").hex()); + VASSERT_EQ("6", "d174ab98d277d9f5a5611c2c9f419d9f", vmime::utility::md5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789").hex()); + VASSERT_EQ("7", "57edf4a22be3c955ac49da2e2107b67a", vmime::utility::md5("12345678901234567890123456789012345678901234567890123456789012345678901234567890").hex()); + } - void testUpdate() - { - vmime::utility::md5 m1; - m1.update(""); - assert_eq("1", "d41d8cd98f00b204e9800998ecf8427e", m1.hex()); + void testUpdate() + { + vmime::utility::md5 m1; + m1.update(""); + VASSERT_EQ("1", "d41d8cd98f00b204e9800998ecf8427e", m1.hex()); - vmime::utility::md5 m2; - m2.update("a"); - m2.update(""); - assert_eq("2", "0cc175b9c0f1b6a831c399e269772661", m2.hex()); + vmime::utility::md5 m2; + m2.update("a"); + m2.update(""); + VASSERT_EQ("2", "0cc175b9c0f1b6a831c399e269772661", m2.hex()); - vmime::utility::md5 m3; - m3.update("ab"); - m3.update("c"); - assert_eq("3", "900150983cd24fb0d6963f7d28e17f72", m3.hex()); + vmime::utility::md5 m3; + m3.update("ab"); + m3.update("c"); + VASSERT_EQ("3", "900150983cd24fb0d6963f7d28e17f72", m3.hex()); - vmime::utility::md5 m4; - m4.update(""); - m4.update("message"); - m4.update(" "); - m4.update("digest"); - assert_eq("4", "f96b697d7cb7938d525a2f31aaf161d0", m4.hex()); + vmime::utility::md5 m4; + m4.update(""); + m4.update("message"); + m4.update(" "); + m4.update("digest"); + VASSERT_EQ("4", "f96b697d7cb7938d525a2f31aaf161d0", m4.hex()); - vmime::utility::md5 m5; - m5.update("abcd"); - m5.update(""); - m5.update("efghijklmnop"); - m5.update("qrstuvwx"); - m5.update("yz"); - assert_eq("5", "c3fcd3d76192e4007dfb496cca67e13b", m5.hex()); + vmime::utility::md5 m5; + m5.update("abcd"); + m5.update(""); + m5.update("efghijklmnop"); + m5.update("qrstuvwx"); + m5.update("yz"); + VASSERT_EQ("5", "c3fcd3d76192e4007dfb496cca67e13b", m5.hex()); - vmime::utility::md5 m6; - m6.update("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012"); - m6.update("345"); - m6.update("6"); - m6.update("7"); - m6.update("89"); - assert_eq("6", "d174ab98d277d9f5a5611c2c9f419d9f", m6.hex()); + vmime::utility::md5 m6; + m6.update("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012"); + m6.update("345"); + m6.update("6"); + m6.update("7"); + m6.update("89"); + VASSERT_EQ("6", "d174ab98d277d9f5a5611c2c9f419d9f", m6.hex()); - vmime::utility::md5 m7; - m7.update("12345678901234567890123456789"); - m7.update("01234567890123456789012345678901"); - m7.update("234567890123456789"); - m7.update(""); - m7.update("0"); - assert_eq("7", "57edf4a22be3c955ac49da2e2107b67a", m7.hex()); - } + vmime::utility::md5 m7; + m7.update("12345678901234567890123456789"); + m7.update("01234567890123456789012345678901"); + m7.update("234567890123456789"); + m7.update(""); + m7.update("0"); + VASSERT_EQ("7", "57edf4a22be3c955ac49da2e2107b67a", m7.hex()); + } - public: +VMIME_TEST_SUITE_END - md5Test() : suite("vmime::utility::md5") - { - // VMime initialization - vmime::platformDependant::setHandler(); - - add("String", testcase(this, "String", &md5Test::testString)); - add("Update", testcase(this, "Update", &md5Test::testUpdate)); - - suite::main().add("vmime::utility::md5", this); - } - - }; - - md5Test* theTest = new md5Test(); -} diff --git a/tests/utility/pathTest.cpp b/tests/utility/pathTest.cpp index 7710cf13..bb9f2098 100644 --- a/tests/utility/pathTest.cpp +++ b/tests/utility/pathTest.cpp @@ -17,301 +17,287 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" +#include "tests/testUtils.hpp" -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" #include "vmime/utility/path.hpp" -using namespace unitpp; + +#define VMIME_TEST_SUITE pathTest +#define VMIME_TEST_SUITE_MODULE "Utility" -namespace -{ - class pathTest : public suite +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testConstruct1) + VMIME_TEST(testConstruct2) + VMIME_TEST(testConstruct3) + VMIME_TEST(testConstruct4) + + VMIME_TEST(testAppendComponent) + + VMIME_TEST(testOperatorDiv1) + VMIME_TEST(testOperatorDiv2) + + VMIME_TEST(testOperatorDivEqual1) + VMIME_TEST(testOperatorDivEqual2) + + VMIME_TEST(testGetParent) + + VMIME_TEST(testComparison) + + VMIME_TEST(testGetLastComponent) + + VMIME_TEST(testIsDirectParentOf) + VMIME_TEST(testIsParentOf) + + VMIME_TEST(testRenameParent) + VMIME_TEST_LIST_END + + + typedef vmime::utility::path path; + typedef vmime::utility::path::component comp; + + + void testConstruct1() { - typedef vmime::utility::path path; - typedef vmime::utility::path::component comp; + VASSERT_EQ("1", true, path().isEmpty()); + VASSERT_EQ("2", 0, path().getSize()); + } + + void testConstruct2() + { + path p(comp("foo")); + + VASSERT_EQ("1", false, p.isEmpty()); + VASSERT_EQ("2", 1, p.getSize()); + VASSERT_EQ("3", "foo", p.getComponentAt(0).getBuffer()); + } + + void testAppendComponent() + { + path p; + + VASSERT_EQ("1", 0, p.getSize()); + + comp c("foo"); + p.appendComponent(c); + + VASSERT_EQ("2", 1, p.getSize()); + VASSERT_EQ("3", c.getBuffer(), p.getComponentAt(0).getBuffer()); + } + + void testConstruct3() + { + path p1; + p1.appendComponent(comp("foo")); + p1.appendComponent(comp("bar")); + + path p2(p1); + VASSERT_EQ("1", 2, p2.getSize()); + VASSERT_EQ("2", "foo", p2.getComponentAt(0).getBuffer()); + VASSERT_EQ("3", "bar", p2.getComponentAt(1).getBuffer()); + } + + void testConstruct4() + { + // Same as path::path(const component&) + path p("foo"); + + VASSERT_EQ("1", false, p.isEmpty()); + VASSERT_EQ("2", 1, p.getSize()); + VASSERT_EQ("3", "foo", p.getComponentAt(0).getBuffer()); + } + + void testOperatorDiv1() + { + path p1; + p1.appendComponent(comp("foo")); + p1.appendComponent(comp("bar")); - void testConstruct1() - { - assert_eq("1", true, path().isEmpty()); - assert_eq("2", 0, path().getSize()); - } - - void testConstruct2() - { - path p(comp("foo")); - - assert_eq("1", false, p.isEmpty()); - assert_eq("2", 1, p.getSize()); - assert_eq("3", "foo", p.getComponentAt(0).getBuffer()); - } + path p2; + p2.appendComponent(comp("baz")); - void testAppendComponent() - { - path p; + path p3 = p1 / p2; + + VASSERT_EQ("1", 3, p3.getSize()); + VASSERT_EQ("2", p1.getComponentAt(0).getBuffer(), p3.getComponentAt(0).getBuffer()); + VASSERT_EQ("3", p1.getComponentAt(1).getBuffer(), p3.getComponentAt(1).getBuffer()); + VASSERT_EQ("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer()); + } + + void testOperatorDiv2() + { + path p1; + p1.appendComponent(comp("foo")); + p1.appendComponent(comp("bar")); + + comp c("baz"); + + path p2 = p1 / c; + + VASSERT_EQ("1", 3, p2.getSize()); + VASSERT_EQ("2", p1.getComponentAt(0).getBuffer(), p2.getComponentAt(0).getBuffer()); + VASSERT_EQ("3", p1.getComponentAt(1).getBuffer(), p2.getComponentAt(1).getBuffer()); + VASSERT_EQ("4", c.getBuffer(), p2.getComponentAt(2).getBuffer()); + } + + void testOperatorDivEqual1() + { + path p1; + p1.appendComponent(comp("foo")); + p1.appendComponent(comp("bar")); + + path p2; + p2.appendComponent(comp("baz")); + + path p3(p1); + p3 /= p2; + + VASSERT_EQ("1", 3, p3.getSize()); + VASSERT_EQ("2", p1.getComponentAt(0).getBuffer(), p3.getComponentAt(0).getBuffer()); + VASSERT_EQ("3", p1.getComponentAt(1).getBuffer(), p3.getComponentAt(1).getBuffer()); + VASSERT_EQ("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer()); + } + + void testOperatorDivEqual2() + { + path p1; + p1.appendComponent(comp("foo")); + p1.appendComponent(comp("bar")); + + comp c("baz"); + + path p2(p1); + p2 /= c; + + VASSERT_EQ("1", 3, p2.getSize()); + VASSERT_EQ("2", p1.getComponentAt(0).getBuffer(), p2.getComponentAt(0).getBuffer()); + VASSERT_EQ("3", p1.getComponentAt(1).getBuffer(), p2.getComponentAt(1).getBuffer()); + VASSERT_EQ("4", c.getBuffer(), p2.getComponentAt(2).getBuffer()); + } + + void testGetParent() + { + path p1; + path p1p = p1.getParent(); + + VASSERT_EQ("1", true, p1p.isEmpty()); + + path p2; + p2.appendComponent(comp("foo")); + p2.appendComponent(comp("bar")); + + path p2p = p2.getParent(); + + VASSERT_EQ("2", 1, p2p.getSize()); + VASSERT_EQ("3", p2.getComponentAt(0).getBuffer(), p2p.getComponentAt(0).getBuffer()); + } + + void testComparison() + { + path p1; + p1.appendComponent(comp("foo")); + p1.appendComponent(comp("bar")); + + path p2; + p2.appendComponent(comp("foo")); + p2.appendComponent(comp("bar")); + + path p3; + p3.appendComponent(comp("foo")); + p3.appendComponent(comp("bar")); + p3.appendComponent(comp("baz")); + + VASSERT_EQ("1", true, p1 == p2); + VASSERT_EQ("2", false, p1 == p3); + + VASSERT_EQ("3", false, p1 != p2); + VASSERT_EQ("4", true, p1 != p3); + + VASSERT_EQ("5", true, p3.getParent() == p1); + } + + void testGetLastComponent() + { + path p1; + p1.appendComponent(comp("foo")); + p1.appendComponent(comp("bar")); + p1.appendComponent(comp("baz")); + + VASSERT_EQ("1", "baz", p1.getLastComponent().getBuffer()); + VASSERT_EQ("2", "bar", p1.getParent().getLastComponent().getBuffer()); + VASSERT_EQ("3", "foo", p1.getParent().getParent().getLastComponent().getBuffer()); + } + + void testIsDirectParentOf() + { + path p1; + p1.appendComponent(comp("foo")); + + path p2; + p2.appendComponent(comp("foo")); + p2.appendComponent(comp("bar")); + + path p3; + p3.appendComponent(comp("foo")); + p3.appendComponent(comp("bar")); + p3.appendComponent(comp("baz")); + + VASSERT_EQ("1", true, p1.isDirectParentOf(p2)); + VASSERT_EQ("2", true, p2.isDirectParentOf(p3)); + VASSERT_EQ("3", false, p1.isDirectParentOf(p3)); + VASSERT_EQ("4", false, p2.isDirectParentOf(p1)); + } + + void testIsParentOf() + { + path p1; + p1.appendComponent(comp("foo")); + + path p2; + p2.appendComponent(comp("foo")); + p2.appendComponent(comp("bar")); + + path p3; + p3.appendComponent(comp("foo")); + p3.appendComponent(comp("bar")); + p3.appendComponent(comp("baz")); + + VASSERT_EQ("1", true, p1.isParentOf(p2)); + VASSERT_EQ("2", true, p2.isParentOf(p3)); + VASSERT_EQ("3", true, p1.isParentOf(p3)); + VASSERT_EQ("4", false, p2.isParentOf(p1)); + } + + void testRenameParent() + { + path p1; + p1.appendComponent(comp("a")); + p1.appendComponent(comp("b")); + p1.appendComponent(comp("c")); + p1.appendComponent(comp("d")); + + path p2; + p2.appendComponent(comp("a")); + p2.appendComponent(comp("b")); + + path p3; + p3.appendComponent(comp("x")); + p3.appendComponent(comp("y")); + p3.appendComponent(comp("z")); + + path p(p1); + p.renameParent(p2, p3); + + VASSERT_EQ("1", 5, p.getSize()); + VASSERT_EQ("2", "x", p.getComponentAt(0).getBuffer()); + VASSERT_EQ("3", "y", p.getComponentAt(1).getBuffer()); + VASSERT_EQ("4", "z", p.getComponentAt(2).getBuffer()); + VASSERT_EQ("5", "c", p.getComponentAt(3).getBuffer()); + VASSERT_EQ("6", "d", p.getComponentAt(4).getBuffer()); + } + +VMIME_TEST_SUITE_END - assert_eq("1", 0, p.getSize()); - - comp c("foo"); - p.appendComponent(c); - - assert_eq("2", 1, p.getSize()); - assert_eq("3", c.getBuffer(), p.getComponentAt(0).getBuffer()); - } - - void testConstruct3() - { - path p1; - p1.appendComponent(comp("foo")); - p1.appendComponent(comp("bar")); - - path p2(p1); - - assert_eq("1", 2, p2.getSize()); - assert_eq("2", "foo", p2.getComponentAt(0).getBuffer()); - assert_eq("3", "bar", p2.getComponentAt(1).getBuffer()); - } - - void testConstruct4() - { - // Same as path::path(const component&) - path p("foo"); - - assert_eq("1", false, p.isEmpty()); - assert_eq("2", 1, p.getSize()); - assert_eq("3", "foo", p.getComponentAt(0).getBuffer()); - } - - void testOperatorDiv1() - { - path p1; - p1.appendComponent(comp("foo")); - p1.appendComponent(comp("bar")); - - path p2; - p2.appendComponent(comp("baz")); - - path p3 = p1 / p2; - - assert_eq("1", 3, p3.getSize()); - assert_eq("2", p1.getComponentAt(0).getBuffer(), p3.getComponentAt(0).getBuffer()); - assert_eq("3", p1.getComponentAt(1).getBuffer(), p3.getComponentAt(1).getBuffer()); - assert_eq("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer()); - } - - void testOperatorDiv2() - { - path p1; - p1.appendComponent(comp("foo")); - p1.appendComponent(comp("bar")); - - comp c("baz"); - - path p2 = p1 / c; - - assert_eq("1", 3, p2.getSize()); - assert_eq("2", p1.getComponentAt(0).getBuffer(), p2.getComponentAt(0).getBuffer()); - assert_eq("3", p1.getComponentAt(1).getBuffer(), p2.getComponentAt(1).getBuffer()); - assert_eq("4", c.getBuffer(), p2.getComponentAt(2).getBuffer()); - } - - void testOperatorDivEqual1() - { - path p1; - p1.appendComponent(comp("foo")); - p1.appendComponent(comp("bar")); - - path p2; - p2.appendComponent(comp("baz")); - - path p3(p1); - p3 /= p2; - - assert_eq("1", 3, p3.getSize()); - assert_eq("2", p1.getComponentAt(0).getBuffer(), p3.getComponentAt(0).getBuffer()); - assert_eq("3", p1.getComponentAt(1).getBuffer(), p3.getComponentAt(1).getBuffer()); - assert_eq("4", p2.getComponentAt(0).getBuffer(), p3.getComponentAt(2).getBuffer()); - } - - void testOperatorDivEqual2() - { - path p1; - p1.appendComponent(comp("foo")); - p1.appendComponent(comp("bar")); - - comp c("baz"); - - path p2(p1); - p2 /= c; - - assert_eq("1", 3, p2.getSize()); - assert_eq("2", p1.getComponentAt(0).getBuffer(), p2.getComponentAt(0).getBuffer()); - assert_eq("3", p1.getComponentAt(1).getBuffer(), p2.getComponentAt(1).getBuffer()); - assert_eq("4", c.getBuffer(), p2.getComponentAt(2).getBuffer()); - } - - void testGetParent() - { - path p1; - path p1p = p1.getParent(); - - assert_eq("1", true, p1p.isEmpty()); - - path p2; - p2.appendComponent(comp("foo")); - p2.appendComponent(comp("bar")); - - path p2p = p2.getParent(); - - assert_eq("2", 1, p2p.getSize()); - assert_eq("3", p2.getComponentAt(0).getBuffer(), p2p.getComponentAt(0).getBuffer()); - } - - void testComparison() - { - path p1; - p1.appendComponent(comp("foo")); - p1.appendComponent(comp("bar")); - - path p2; - p2.appendComponent(comp("foo")); - p2.appendComponent(comp("bar")); - - path p3; - p3.appendComponent(comp("foo")); - p3.appendComponent(comp("bar")); - p3.appendComponent(comp("baz")); - - assert_eq("1", true, p1 == p2); - assert_eq("2", false, p1 == p3); - - assert_eq("3", false, p1 != p2); - assert_eq("4", true, p1 != p3); - - assert_eq("5", true, p3.getParent() == p1); - } - - void testGetLastComponent() - { - path p1; - p1.appendComponent(comp("foo")); - p1.appendComponent(comp("bar")); - p1.appendComponent(comp("baz")); - - assert_eq("1", "baz", p1.getLastComponent().getBuffer()); - assert_eq("2", "bar", p1.getParent().getLastComponent().getBuffer()); - assert_eq("3", "foo", p1.getParent().getParent().getLastComponent().getBuffer()); - } - - void testIsDirectParentOf() - { - path p1; - p1.appendComponent(comp("foo")); - - path p2; - p2.appendComponent(comp("foo")); - p2.appendComponent(comp("bar")); - - path p3; - p3.appendComponent(comp("foo")); - p3.appendComponent(comp("bar")); - p3.appendComponent(comp("baz")); - - assert_eq("1", true, p1.isDirectParentOf(p2)); - assert_eq("2", true, p2.isDirectParentOf(p3)); - assert_eq("3", false, p1.isDirectParentOf(p3)); - assert_eq("4", false, p2.isDirectParentOf(p1)); - } - - void testIsParentOf() - { - path p1; - p1.appendComponent(comp("foo")); - - path p2; - p2.appendComponent(comp("foo")); - p2.appendComponent(comp("bar")); - - path p3; - p3.appendComponent(comp("foo")); - p3.appendComponent(comp("bar")); - p3.appendComponent(comp("baz")); - - assert_eq("1", true, p1.isParentOf(p2)); - assert_eq("2", true, p2.isParentOf(p3)); - assert_eq("3", true, p1.isParentOf(p3)); - assert_eq("4", false, p2.isParentOf(p1)); - } - - void testRenameParent() - { - path p1; - p1.appendComponent(comp("a")); - p1.appendComponent(comp("b")); - p1.appendComponent(comp("c")); - p1.appendComponent(comp("d")); - - path p2; - p2.appendComponent(comp("a")); - p2.appendComponent(comp("b")); - - path p3; - p3.appendComponent(comp("x")); - p3.appendComponent(comp("y")); - p3.appendComponent(comp("z")); - - path p(p1); - p.renameParent(p2, p3); - - assert_eq("1", 5, p.getSize()); - assert_eq("2", "x", p.getComponentAt(0).getBuffer()); - assert_eq("3", "y", p.getComponentAt(1).getBuffer()); - assert_eq("4", "z", p.getComponentAt(2).getBuffer()); - assert_eq("5", "c", p.getComponentAt(3).getBuffer()); - assert_eq("6", "d", p.getComponentAt(4).getBuffer()); - } - - public: - - pathTest() : suite("vmime::utility::path") - { - // VMime initialization - vmime::platformDependant::setHandler(); - - add("Construct1", testcase(this, "Construct1", &pathTest::testConstruct1)); - add("Construct2", testcase(this, "Construct2", &pathTest::testConstruct2)); - add("Construct3", testcase(this, "Construct3", &pathTest::testConstruct3)); - add("Construct4", testcase(this, "Construct4", &pathTest::testConstruct4)); - - add("AppendComponent", testcase(this, "AppendComponent", &pathTest::testAppendComponent)); - - add("OperatorDiv1", testcase(this, "OperatorDiv1", &pathTest::testOperatorDiv1)); - add("OperatorDiv2", testcase(this, "OperatorDiv2", &pathTest::testOperatorDiv2)); - - add("OperatorDivEqual1", testcase(this, "OperatorDivEqual1", &pathTest::testOperatorDivEqual1)); - add("OperatorDivEqual2", testcase(this, "OperatorDivEqual2", &pathTest::testOperatorDivEqual2)); - - add("GetParent", testcase(this, "GetParent", &pathTest::testGetParent)); - - add("Comparison", testcase(this, "Comparison", &pathTest::testComparison)); - - add("GetLastComponent", testcase(this, "GetLastComponent", &pathTest::testGetLastComponent)); - - add("IsDirectParentOf", testcase(this, "IsDirectParentOf", &pathTest::testIsDirectParentOf)); - add("IsParentOf", testcase(this, "IsParentOf", &pathTest::testIsParentOf)); - - add("RenameParent", testcase(this, "RenameParent", &pathTest::testRenameParent)); - - suite::main().add("vmime::utility::path", this); - } - - }; - - pathTest* theTest = new pathTest(); -} diff --git a/tests/utility/smartPtrTest.cpp b/tests/utility/smartPtrTest.cpp index 9a7eb539..35824f42 100644 --- a/tests/utility/smartPtrTest.cpp +++ b/tests/utility/smartPtrTest.cpp @@ -17,242 +17,225 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" +#include "tests/testUtils.hpp" #include "vmime/utility/smartPtr.hpp" -using namespace unitpp; + +#define VMIME_TEST_SUITE smartPtrTest +#define VMIME_TEST_SUITE_MODULE "Utility" -namespace -{ - class smartPtrTest : public suite +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testNull) + VMIME_TEST(testRefCounting) + VMIME_TEST(testWeakRef) + VMIME_TEST(testCast) + VMIME_TEST(testContainer) + VMIME_TEST(testCompare) + VMIME_TEST_LIST_END + + + struct A : public vmime::object { - struct A : public vmime::object - { - const int strongCount() const { return getStrongRefCount(); } - const int weakCount() const { return getWeakRefCount(); } - }; - - struct B : public virtual A { }; - struct C : public virtual A { }; - struct D : public B, public C { }; - - class R : public A - { - public: - - R(bool* aliveFlag) : m_aliveFlag(aliveFlag) { *m_aliveFlag = true; } - ~R() { *m_aliveFlag = false; } - - private: - - bool* m_aliveFlag; - }; - - - void testNull() - { - vmime::ref r1; - - assert_true("1", r1 == NULL); - assert_true("2", r1 == 0); - assert_true("3", NULL == r1); - assert_true("4", 0 == r1); - assert_true("5", !r1); - assert_true("6", r1 == vmime::null); - assert_true("7", vmime::null == r1); - assert_eq("8", static_cast (0), r1.get()); - } - - void testRefCounting() - { - bool o1_alive; - vmime::ref r1 = vmime::create (&o1_alive); - - assert_true("1", r1.get() != 0); - assert_true("2", o1_alive); - assert_eq("3", 1, r1->strongCount()); - assert_eq("4", 0, r1->weakCount()); - - vmime::ref r2 = r1; - - assert_true("5", o1_alive); - assert_eq("6", 2, r1->strongCount()); - assert_eq("7", 0, r1->weakCount()); - - bool o2_alive; - vmime::ref r3 = vmime::create (&o2_alive); - - r2 = r3; - - assert_true("8", o1_alive); - assert_true("9", o2_alive); - assert_eq("10", 1, r1->strongCount()); - assert_eq("11", 2, r2->strongCount()); - assert_eq("12", 2, r3->strongCount()); - - { - vmime::ref r4; - - r4 = r1; - - assert_true("13", o1_alive); - assert_true("14", o2_alive); - assert_eq("15", 2, r4->strongCount()); - assert_eq("16", 2, r1->strongCount()); - - r1 = NULL; - - assert_true("17", o1_alive); - assert_true("18", o2_alive); - assert_eq("19", 1, r4->strongCount()); - - // Here, object1 will be deleted - } - - assert_true("20", !o1_alive); - assert_true("21", o2_alive); - - { - vmime::weak_ref w1 = r3; - - assert_eq("22", 1, r3->weakCount()); - } - - assert_true("23", o2_alive); - assert_eq("24", 2, r3->strongCount()); - assert_eq("25", 0, r3->weakCount()); - } - - void testWeakRef() - { - vmime::ref r1 = vmime::create (); - vmime::weak_ref w1 = r1; - - assert_true("1", r1.get() != 0); - assert_true("2", r1.get() == w1.get()); - - { - vmime::ref r2 = r1; - - assert_true("3", r1.get() == r2.get()); - assert_true("4", r1.get() == w1.get()); - } - - assert_true("5", r1.get() != 0); - assert_true("6", r1.get() == w1.get()); - - r1 = 0; - - assert_true("7", w1.get() == 0); - } - - void testCast() - { - // Explicit upcast - vmime::ref r1 = vmime::create (); - vmime::ref r2 = r1.dynamicCast (); - - assert_true("1", r2.get() == dynamic_cast (r1.get())); - assert_true("2", 0 == r1.dynamicCast ().get()); - - // Implicit downcast - vmime::ref r3 = vmime::create (); - vmime::ref r4 = r3; - - assert_true("3", r4.get() == dynamic_cast (r3.get())); - } - - void testContainer() - { - bool o1_alive; - vmime::ref r1 = vmime::create (&o1_alive); - - bool o2_alive; - vmime::ref r2 = vmime::create (&o2_alive); - - std::vector > v1; - v1.push_back(r1); - v1.push_back(r2); - - assert_true("1", o1_alive); - assert_eq("2", 2, r1->strongCount()); - assert_true("3", o2_alive); - assert_eq("4", 2, r2->strongCount()); - - { - std::vector > v2 = v1; - - assert_true("5", o1_alive); - assert_eq("6", 3, r1->strongCount()); - assert_true("7", o2_alive); - assert_eq("8", 3, r2->strongCount()); - - v2[1] = NULL; - - assert_true("9", o1_alive); - assert_eq("10", 3, r1->strongCount()); - assert_true("11", o2_alive); - assert_eq("12", 2, r2->strongCount()); - } - - assert_true("13", o1_alive); - assert_eq("14", 2, r1->strongCount()); - assert_true("15", o2_alive); - assert_eq("16", 2, r2->strongCount()); - } - - void testCompare() - { - vmime::ref r1 = vmime::create (); - vmime::ref r2 = vmime::create (); - vmime::ref r3 = vmime::create (); - vmime::ref r4 = r1; - - assert_true("1", r1 != r2); - assert_true("2", r1.get() == r1); - assert_true("3", r1 == r1.get()); - assert_true("4", r2 != r1.get()); - assert_true("5", r1.get() != r2); - assert_true("6", r1 == r4); - assert_true("7", r1.get() == r4); - - std::vector > v; - v.push_back(r1); - v.push_back(r2); - - assert_true("8", std::find(v.begin(), v.end(), r1) == v.begin()); - assert_true("9", std::find(v.begin(), v.end(), r2) == v.begin() + 1); - assert_true("10", std::find(v.begin(), v.end(), r3) == v.end()); - } - - public: - - smartPtrTest() : suite("vmime::utility::url") - { - // VMime initialization - vmime::platformDependant::setHandler(); - - add("Null", testcase(this, "TestNull", &smartPtrTest::testNull)); - add("RefCounting", testcase(this, "TestRefCounting", &smartPtrTest::testRefCounting)); - add("WeakRef", testcase(this, "TestWeakRef", &smartPtrTest::testWeakRef)); - add("Cast", testcase(this, "TestCast", &smartPtrTest::testCast)); - add("Container", testcase(this, "TestContainer", &smartPtrTest::testContainer)); - add("Compare", testcase(this, "TestCompare", &smartPtrTest::testCompare)); - - suite::main().add("vmime::utility::smartPtr", this); - } - + const int strongCount() const { return getStrongRefCount(); } + const int weakCount() const { return getWeakRefCount(); } }; - smartPtrTest* theTest = new smartPtrTest(); -} + struct B : public virtual A { }; + struct C : public virtual A { }; + struct D : public B, public C { }; + + class R : public A + { + public: + + R(bool* aliveFlag) : m_aliveFlag(aliveFlag) { *m_aliveFlag = true; } + ~R() { *m_aliveFlag = false; } + + private: + + bool* m_aliveFlag; + }; + + + void testNull() + { + vmime::ref r1; + + VASSERT("1", r1 == NULL); + VASSERT("2", r1 == 0); + VASSERT("3", NULL == r1); + VASSERT("4", 0 == r1); + VASSERT("5", !r1); + VASSERT("6", r1 == vmime::null); + VASSERT("7", vmime::null == r1); + VASSERT_EQ("8", static_cast (0), r1.get()); + } + + void testRefCounting() + { + bool o1_alive; + vmime::ref r1 = vmime::create (&o1_alive); + + VASSERT("1", r1.get() != 0); + VASSERT("2", o1_alive); + VASSERT_EQ("3", 1, r1->strongCount()); + VASSERT_EQ("4", 0, r1->weakCount()); + + vmime::ref r2 = r1; + + VASSERT("5", o1_alive); + VASSERT_EQ("6", 2, r1->strongCount()); + VASSERT_EQ("7", 0, r1->weakCount()); + + bool o2_alive; + vmime::ref r3 = vmime::create (&o2_alive); + + r2 = r3; + + VASSERT("8", o1_alive); + VASSERT("9", o2_alive); + VASSERT_EQ("10", 1, r1->strongCount()); + VASSERT_EQ("11", 2, r2->strongCount()); + VASSERT_EQ("12", 2, r3->strongCount()); + + { + vmime::ref r4; + + r4 = r1; + + VASSERT("13", o1_alive); + VASSERT("14", o2_alive); + VASSERT_EQ("15", 2, r4->strongCount()); + VASSERT_EQ("16", 2, r1->strongCount()); + + r1 = NULL; + + VASSERT("17", o1_alive); + VASSERT("18", o2_alive); + VASSERT_EQ("19", 1, r4->strongCount()); + + // Here, object1 will be deleted + } + + VASSERT("20", !o1_alive); + VASSERT("21", o2_alive); + + { + vmime::weak_ref w1 = r3; + + VASSERT_EQ("22", 1, r3->weakCount()); + } + + VASSERT("23", o2_alive); + VASSERT_EQ("24", 2, r3->strongCount()); + VASSERT_EQ("25", 0, r3->weakCount()); + } + + void testWeakRef() + { + vmime::ref r1 = vmime::create (); + vmime::weak_ref w1 = r1; + + VASSERT("1", r1.get() != 0); + VASSERT("2", r1.get() == w1.get()); + + { + vmime::ref r2 = r1; + + VASSERT("3", r1.get() == r2.get()); + VASSERT("4", r1.get() == w1.get()); + } + + VASSERT("5", r1.get() != 0); + VASSERT("6", r1.get() == w1.get()); + + r1 = 0; + + VASSERT("7", w1.get() == 0); + } + + void testCast() + { + // Explicit upcast + vmime::ref r1 = vmime::create (); + vmime::ref r2 = r1.dynamicCast (); + + VASSERT("1", r2.get() == dynamic_cast (r1.get())); + VASSERT("2", 0 == r1.dynamicCast ().get()); + + // Implicit downcast + vmime::ref r3 = vmime::create (); + vmime::ref r4 = r3; + + VASSERT("3", r4.get() == dynamic_cast (r3.get())); + } + + void testContainer() + { + bool o1_alive; + vmime::ref r1 = vmime::create (&o1_alive); + + bool o2_alive; + vmime::ref r2 = vmime::create (&o2_alive); + + std::vector > v1; + v1.push_back(r1); + v1.push_back(r2); + + VASSERT("1", o1_alive); + VASSERT_EQ("2", 2, r1->strongCount()); + VASSERT("3", o2_alive); + VASSERT_EQ("4", 2, r2->strongCount()); + + { + std::vector > v2 = v1; + + VASSERT("5", o1_alive); + VASSERT_EQ("6", 3, r1->strongCount()); + VASSERT("7", o2_alive); + VASSERT_EQ("8", 3, r2->strongCount()); + + v2[1] = NULL; + + VASSERT("9", o1_alive); + VASSERT_EQ("10", 3, r1->strongCount()); + VASSERT("11", o2_alive); + VASSERT_EQ("12", 2, r2->strongCount()); + } + + VASSERT("13", o1_alive); + VASSERT_EQ("14", 2, r1->strongCount()); + VASSERT("15", o2_alive); + VASSERT_EQ("16", 2, r2->strongCount()); + } + + void testCompare() + { + vmime::ref r1 = vmime::create (); + vmime::ref r2 = vmime::create (); + vmime::ref r3 = vmime::create (); + vmime::ref r4 = r1; + + VASSERT("1", r1 != r2); + VASSERT("2", r1.get() == r1); + VASSERT("3", r1 == r1.get()); + VASSERT("4", r2 != r1.get()); + VASSERT("5", r1.get() != r2); + VASSERT("6", r1 == r4); + VASSERT("7", r1.get() == r4); + + std::vector > v; + v.push_back(r1); + v.push_back(r2); + + VASSERT("8", std::find(v.begin(), v.end(), r1) == v.begin()); + VASSERT("9", std::find(v.begin(), v.end(), r2) == v.begin() + 1); + VASSERT("10", std::find(v.begin(), v.end(), r3) == v.end()); + } + +VMIME_TEST_SUITE_END diff --git a/tests/utility/stringProxyTest.cpp b/tests/utility/stringProxyTest.cpp index 8c719920..b4803e82 100644 --- a/tests/utility/stringProxyTest.cpp +++ b/tests/utility/stringProxyTest.cpp @@ -17,189 +17,174 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" - -using namespace unitpp; +#include "tests/testUtils.hpp" -namespace -{ - class stringProxyTest : public suite +#define VMIME_TEST_SUITE stringProxyTest +#define VMIME_TEST_SUITE_MODULE "Utility" + + +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testConstruct) + VMIME_TEST(testConstruct2) + + VMIME_TEST(testDetach) + + VMIME_TEST(testSet) + + VMIME_TEST(testExtract) + + VMIME_TEST(testOperatorLTLT1) + VMIME_TEST(testOperatorLTLT2) + VMIME_TEST_LIST_END + + + void testConstruct() { - void testConstruct() - { - vmime::utility::stringProxy s; + vmime::utility::stringProxy s; - assert_eq("1", static_cast (0), s.length()); - assert_eq("2", static_cast (0), s.start()); - assert_eq("3", static_cast (0), s.end()); - } + VASSERT_EQ("1", static_cast (0), s.length()); + VASSERT_EQ("2", static_cast (0), s.start()); + VASSERT_EQ("3", static_cast (0), s.end()); + } - void testConstruct2() - { - vmime::string str("This is a test string."); + void testConstruct2() + { + vmime::string str("This is a test string."); - vmime::utility::stringProxy s1(str); + vmime::utility::stringProxy s1(str); - assert_eq("1", str.length(), s1.length()); - assert_eq("2", static_cast (0), s1.start()); - assert_eq("3", str.length(), s1.end()); + VASSERT_EQ("1", str.length(), s1.length()); + VASSERT_EQ("2", static_cast (0), s1.start()); + VASSERT_EQ("3", str.length(), s1.end()); - vmime::utility::stringProxy s2(str, 10); + vmime::utility::stringProxy s2(str, 10); - assert_eq("4", str.length() - 10, s2.length()); - assert_eq("5", static_cast (10), s2.start()); - assert_eq("6", str.length(), s2.end()); + VASSERT_EQ("4", str.length() - 10, s2.length()); + VASSERT_EQ("5", static_cast (10), s2.start()); + VASSERT_EQ("6", str.length(), s2.end()); - vmime::utility::stringProxy s3(str, 10, 14); + vmime::utility::stringProxy s3(str, 10, 14); - assert_eq("7", static_cast (4), s3.length()); - assert_eq("8", static_cast (10), s3.start()); - assert_eq("9", static_cast (14), s3.end()); + VASSERT_EQ("7", static_cast (4), s3.length()); + VASSERT_EQ("8", static_cast (10), s3.start()); + VASSERT_EQ("9", static_cast (14), s3.end()); - assert_eq("10", 't', *s3.it_begin()); - assert_eq("11", 'e', *(s3.it_begin() + 1)); - assert_eq("12", 's', *(s3.it_begin() + 2)); - assert_eq("13", 't', *(s3.it_begin() + 3)); - } + VASSERT_EQ("10", 't', *s3.it_begin()); + VASSERT_EQ("11", 'e', *(s3.it_begin() + 1)); + VASSERT_EQ("12", 's', *(s3.it_begin() + 2)); + VASSERT_EQ("13", 't', *(s3.it_begin() + 3)); + } - void testDetach() - { - vmime::utility::stringProxy s; - s = "foo"; + void testDetach() + { + vmime::utility::stringProxy s; + s = "foo"; - s.detach(); + s.detach(); - assert_eq("1", static_cast (0), s.length()); - assert_eq("2", static_cast (0), s.start()); - assert_eq("3", static_cast (0), s.end()); - } + VASSERT_EQ("1", static_cast (0), s.length()); + VASSERT_EQ("2", static_cast (0), s.start()); + VASSERT_EQ("3", static_cast (0), s.end()); + } - void testSet() - { - vmime::string str("This is a test string."); + void testSet() + { + vmime::string str("This is a test string."); - vmime::utility::stringProxy s1; - s1.set(str); + vmime::utility::stringProxy s1; + s1.set(str); - assert_eq("1", str.length(), s1.length()); - assert_eq("2", static_cast (0), s1.start()); - assert_eq("3", str.length(), s1.end()); + VASSERT_EQ("1", str.length(), s1.length()); + VASSERT_EQ("2", static_cast (0), s1.start()); + VASSERT_EQ("3", str.length(), s1.end()); - vmime::utility::stringProxy s2; - s2.set(str, 10); + vmime::utility::stringProxy s2; + s2.set(str, 10); - assert_eq("4", str.length() - 10, s2.length()); - assert_eq("5", static_cast (10), s2.start()); - assert_eq("6", str.length(), s2.end()); + VASSERT_EQ("4", str.length() - 10, s2.length()); + VASSERT_EQ("5", static_cast (10), s2.start()); + VASSERT_EQ("6", str.length(), s2.end()); - vmime::utility::stringProxy s3; - s3.set(str, 10, 14); + vmime::utility::stringProxy s3; + s3.set(str, 10, 14); - assert_eq("7", static_cast (4), s3.length()); - assert_eq("8", static_cast (10), s3.start()); - assert_eq("9", static_cast (14), s3.end()); + VASSERT_EQ("7", static_cast (4), s3.length()); + VASSERT_EQ("8", static_cast (10), s3.start()); + VASSERT_EQ("9", static_cast (14), s3.end()); - assert_eq("10", 't', *s3.it_begin()); - assert_eq("11", 'e', *(s3.it_begin() + 1)); - assert_eq("12", 's', *(s3.it_begin() + 2)); - assert_eq("13", 't', *(s3.it_begin() + 3)); - } + VASSERT_EQ("10", 't', *s3.it_begin()); + VASSERT_EQ("11", 'e', *(s3.it_begin() + 1)); + VASSERT_EQ("12", 's', *(s3.it_begin() + 2)); + VASSERT_EQ("13", 't', *(s3.it_begin() + 3)); + } - void testExtract() - { - vmime::string str("This is a test string."); + void testExtract() + { + vmime::string str("This is a test string."); - vmime::utility::stringProxy s1(str, 10, 14); + vmime::utility::stringProxy s1(str, 10, 14); - std::ostringstream oss1; - vmime::utility::outputStreamAdapter osa1(oss1); + std::ostringstream oss1; + vmime::utility::outputStreamAdapter osa1(oss1); - s1.extract(osa1); + s1.extract(osa1); - assert_eq("1", "test", oss1.str()); + VASSERT_EQ("1", "test", oss1.str()); - vmime::utility::stringProxy s2(str); + vmime::utility::stringProxy s2(str); - std::ostringstream oss2; - vmime::utility::outputStreamAdapter osa2(oss2); + std::ostringstream oss2; + vmime::utility::outputStreamAdapter osa2(oss2); - s2.extract(osa2); + s2.extract(osa2); - assert_eq("2", str, oss2.str()); - } + VASSERT_EQ("2", str, oss2.str()); + } - void testOperatorLTLT1() - { - vmime::string str("This is a test string."); + void testOperatorLTLT1() + { + vmime::string str("This is a test string."); - vmime::utility::stringProxy s1(str, 10, 14); + vmime::utility::stringProxy s1(str, 10, 14); - std::ostringstream oss1; - oss1 << s1; + std::ostringstream oss1; + oss1 << s1; - assert_eq("1", "test", oss1.str()); + VASSERT_EQ("1", "test", oss1.str()); - vmime::utility::stringProxy s2(str); + vmime::utility::stringProxy s2(str); - std::ostringstream oss2; - oss2 << s2; + std::ostringstream oss2; + oss2 << s2; - assert_eq("2", str, oss2.str()); - } + VASSERT_EQ("2", str, oss2.str()); + } - void testOperatorLTLT2() - { - vmime::string str("This is a test string."); + void testOperatorLTLT2() + { + vmime::string str("This is a test string."); - vmime::utility::stringProxy s1(str, 10, 14); + vmime::utility::stringProxy s1(str, 10, 14); - std::ostringstream oss1; - vmime::utility::outputStreamAdapter osa1(oss1); + std::ostringstream oss1; + vmime::utility::outputStreamAdapter osa1(oss1); - osa1 << s1; + osa1 << s1; - assert_eq("1", "test", oss1.str()); + VASSERT_EQ("1", "test", oss1.str()); - vmime::utility::stringProxy s2(str); + vmime::utility::stringProxy s2(str); - std::ostringstream oss2; - vmime::utility::outputStreamAdapter osa2(oss2); + std::ostringstream oss2; + vmime::utility::outputStreamAdapter osa2(oss2); - osa2 << s2; + osa2 << s2; - assert_eq("2", str, oss2.str()); - } + VASSERT_EQ("2", str, oss2.str()); + } - public: +VMIME_TEST_SUITE_END - stringProxyTest() : suite("vmime::utility::stringProxy") - { - // VMime initialization - vmime::platformDependant::setHandler(); - - add("Construct", testcase(this, "Construct", &stringProxyTest::testConstruct)); - add("Construct2", testcase(this, "Construct2", &stringProxyTest::testConstruct2)); - - add("Detach", testcase(this, "Detach", &stringProxyTest::testDetach)); - - add("Set", testcase(this, "Set", &stringProxyTest::testSet)); - - add("Extract", testcase(this, "Extract", &stringProxyTest::testExtract)); - - add("Operator<<(1)", testcase(this, "Operator<<(1)", &stringProxyTest::testOperatorLTLT1)); - add("Operator<<(2)", testcase(this, "Operator<<(2)", &stringProxyTest::testOperatorLTLT2)); - - suite::main().add("vmime::utility::stringProxy", this); - } - - }; - - stringProxyTest* theTest = new stringProxyTest(); -} diff --git a/tests/utility/stringUtilsTest.cpp b/tests/utility/stringUtilsTest.cpp index dee01f8e..9befe134 100644 --- a/tests/utility/stringUtilsTest.cpp +++ b/tests/utility/stringUtilsTest.cpp @@ -17,117 +17,103 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" +#include "tests/testUtils.hpp" -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" #include "vmime/utility/stringUtils.hpp" -using namespace unitpp; + +#define VMIME_TEST_SUITE stringUtilsTest +#define VMIME_TEST_SUITE_MODULE "Utility" -namespace -{ - class stringUtilsTest : public suite +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testIsStringEqualNoCase1) + VMIME_TEST(testIsStringEqualNoCase2) + VMIME_TEST(testIsStringEqualNoCase3) + + VMIME_TEST(testToLower) + + VMIME_TEST(testTrim) + + VMIME_TEST(testCountASCIIChars) + VMIME_TEST_LIST_END + + + typedef vmime::utility::stringUtils stringUtils; + + + void testIsStringEqualNoCase1() { - typedef vmime::utility::stringUtils stringUtils; + VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), "foo", 3)); + VASSERT_EQ("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), "foo", 3)); + VASSERT_EQ("3", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "FOo", 3)); + VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "bar", 3)); + } - void testIsStringEqualNoCase1() - { - assert_eq("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), "foo", 3)); - assert_eq("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), "foo", 3)); + void testIsStringEqualNoCase2() + { + VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), vmime::string("foo"))); + VASSERT_EQ("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), vmime::string("foo"))); + VASSERT_EQ("3", true, stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("FOo"))); + } - assert_eq("3", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "FOo", 3)); - assert_eq("4", false, stringUtils::isStringEqualNoCase(vmime::string("foo"), "bar", 3)); - } + void testIsStringEqualNoCase3() + { + vmime::string str1("FooBar"); - void testIsStringEqualNoCase2() - { - assert_eq("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), vmime::string("foo"))); - assert_eq("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), vmime::string("foo"))); - assert_eq("3", true, stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("FOo"))); - } + VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "foobar", 6)); + VASSERT_EQ("2", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "FooBar", 6)); + VASSERT_EQ("3", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "fooBar", 3)); + VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.begin() + 3, "fooBar", 6)); + } - void testIsStringEqualNoCase3() - { - vmime::string str1("FooBar"); + void testToLower() + { + VASSERT_EQ("1", "foo", stringUtils::toLower("FOO")); + VASSERT_EQ("2", "foo", stringUtils::toLower("foO")); + VASSERT_EQ("3", "foo", stringUtils::toLower("foo")); + } - assert_eq("1", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "foobar", 6)); - assert_eq("2", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "FooBar", 6)); - assert_eq("3", true, stringUtils::isStringEqualNoCase(str1.begin(), str1.end(), "fooBar", 3)); - assert_eq("4", false, stringUtils::isStringEqualNoCase(str1.begin(), str1.begin() + 3, "fooBar", 6)); - } + void testTrim() + { + VASSERT_EQ("1", "foo", stringUtils::trim(" foo")); + VASSERT_EQ("2", "foo", stringUtils::trim("\t\tfoo")); + VASSERT_EQ("3", "foo", stringUtils::trim(" \t \tfoo")); + VASSERT_EQ("4", "foo", stringUtils::trim(" \r\n\tfoo")); - void testToLower() - { - assert_eq("1", "foo", stringUtils::toLower("FOO")); - assert_eq("2", "foo", stringUtils::toLower("foO")); - assert_eq("3", "foo", stringUtils::toLower("foo")); - } + VASSERT_EQ("5", "foo", stringUtils::trim("foo ")); + VASSERT_EQ("6", "foo", stringUtils::trim("foo\t\t")); + VASSERT_EQ("7", "foo", stringUtils::trim("foo \t \t")); + VASSERT_EQ("8", "foo", stringUtils::trim("foo \r\n\t")); - void testTrim() - { - assert_eq("1", "foo", stringUtils::trim(" foo")); - assert_eq("2", "foo", stringUtils::trim("\t\tfoo")); - assert_eq("3", "foo", stringUtils::trim(" \t \tfoo")); - assert_eq("4", "foo", stringUtils::trim(" \r\n\tfoo")); + VASSERT_EQ( "9", "foo", stringUtils::trim("foo ")); + VASSERT_EQ("10", "foo", stringUtils::trim(" foo ")); + VASSERT_EQ("11", "foo", stringUtils::trim(" foo\t\t")); + VASSERT_EQ("12", "foo", stringUtils::trim("\tfoo \r \t")); + VASSERT_EQ("13", "foo", stringUtils::trim("\r \tfoo \n\t")); + } - assert_eq("5", "foo", stringUtils::trim("foo ")); - assert_eq("6", "foo", stringUtils::trim("foo\t\t")); - assert_eq("7", "foo", stringUtils::trim("foo \t \t")); - assert_eq("8", "foo", stringUtils::trim("foo \r\n\t")); + void testCountASCIIChars() + { + vmime::string str1("foo"); + VASSERT_EQ("1", static_cast (3), + stringUtils::countASCIIchars(str1.begin(), str1.end())); - assert_eq( "9", "foo", stringUtils::trim("foo ")); - assert_eq("10", "foo", stringUtils::trim(" foo ")); - assert_eq("11", "foo", stringUtils::trim(" foo\t\t")); - assert_eq("12", "foo", stringUtils::trim("\tfoo \r \t")); - assert_eq("13", "foo", stringUtils::trim("\r \tfoo \n\t")); - } + vmime::string str2("f=?oo"); + VASSERT_EQ("2", static_cast (3 + 1), + stringUtils::countASCIIchars(str2.begin(), str2.end())); - void testCountASCIIChars() - { - vmime::string str1("foo"); - assert_eq("1", static_cast (3), - stringUtils::countASCIIchars(str1.begin(), str1.end())); + vmime::string str3("foo\x7f"); + VASSERT_EQ("3", static_cast (4), + stringUtils::countASCIIchars(str3.begin(), str3.end())); - vmime::string str2("f=?oo"); - assert_eq("2", static_cast (3 + 1), - stringUtils::countASCIIchars(str2.begin(), str2.end())); + vmime::string str4("foo\x80"); + VASSERT_EQ("4", static_cast (3), + stringUtils::countASCIIchars(str4.begin(), str4.end())); + } - vmime::string str3("foo\x7f"); - assert_eq("3", static_cast (4), - stringUtils::countASCIIchars(str3.begin(), str3.end())); +VMIME_TEST_SUITE_END - vmime::string str4("foo\x80"); - assert_eq("4", static_cast (3), - stringUtils::countASCIIchars(str4.begin(), str4.end())); - } - - public: - - stringUtilsTest() : suite("vmime::utility::stringUtils") - { - // VMime initialization - vmime::platformDependant::setHandler(); - - add("IsStringEqualNoCase1", testcase(this, "IsStringEqualNoCase1", &stringUtilsTest::testIsStringEqualNoCase1)); - add("IsStringEqualNoCase2", testcase(this, "IsStringEqualNoCase2", &stringUtilsTest::testIsStringEqualNoCase2)); - add("IsStringEqualNoCase3", testcase(this, "IsStringEqualNoCase3", &stringUtilsTest::testIsStringEqualNoCase3)); - - add("ToLower", testcase(this, "ToLower", &stringUtilsTest::testToLower)); - - add("Trim", testcase(this, "Trim", &stringUtilsTest::testTrim)); - - add("CountASCIIChars", testcase(this, "CountASCIIChars", &stringUtilsTest::testCountASCIIChars)); - - suite::main().add("vmime::utility::stringUtils", this); - } - - }; - - stringUtilsTest* theTest = new stringUtilsTest(); -} diff --git a/tests/utility/urlTest.cpp b/tests/utility/urlTest.cpp index 963febda..4ed45dfb 100644 --- a/tests/utility/urlTest.cpp +++ b/tests/utility/urlTest.cpp @@ -17,238 +17,223 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include "../lib/unit++/unit++.h" - -#include -#include - -#include "vmime/vmime.hpp" -#include "vmime/platforms/posix/posixHandler.hpp" +#include "tests/testUtils.hpp" #include "vmime/utility/url.hpp" #include "vmime/utility/urlUtils.hpp" -using namespace unitpp; + +#define VMIME_TEST_SUITE urlTest +#define VMIME_TEST_SUITE_MODULE "Utility" -namespace -{ - class urlTest : public suite +VMIME_TEST_SUITE_BEGIN + + VMIME_TEST_LIST_BEGIN + VMIME_TEST(testParse1) + VMIME_TEST(testParse2) + VMIME_TEST(testParse3) + VMIME_TEST(testParse4) + VMIME_TEST(testGenerate) + VMIME_TEST(testUtilsEncode) + VMIME_TEST(testUtilsDecode) + VMIME_TEST_LIST_END + + + static const bool parseHelper(vmime::utility::url& u, const vmime::string& str) { - static const bool parseHelper(vmime::utility::url& u, const vmime::string& str) + try { - try - { - u = vmime::utility::url(str); - } - catch (vmime::exceptions::malformed_url) - { - return false; - } - - return true; + u = vmime::utility::url(str); + } + catch (vmime::exceptions::malformed_url) + { + return false; } + return true; + } - void testParse1() + + void testParse1() + { + // Test some valid constructions + vmime::utility::url u1("", ""); + + VASSERT_EQ("1.1", true, parseHelper(u1, "protocol://user:password@host:12345/path/")); + VASSERT_EQ("1.2", "protocol", u1.getProtocol()); + VASSERT_EQ("1.3", "user", u1.getUsername()); + VASSERT_EQ("1.4", "password", u1.getPassword()); + VASSERT_EQ("1.5", "host", u1.getHost()); + VASSERT_EQ("1.6", 12345, u1.getPort()); + VASSERT_EQ("1.7", "/path/", u1.getPath()); + + vmime::utility::url u2("", ""); + + VASSERT_EQ("2.1", true, parseHelper(u2, "protocol://user@host:12345/path/")); + VASSERT_EQ("2.2", "protocol", u2.getProtocol()); + VASSERT_EQ("2.3", "user", u2.getUsername()); + VASSERT_EQ("2.4", "", u2.getPassword()); + VASSERT_EQ("2.5", "host", u2.getHost()); + VASSERT_EQ("2.6", 12345, u2.getPort()); + VASSERT_EQ("2.7", "/path/", u2.getPath()); + + vmime::utility::url u3("", ""); + + VASSERT_EQ("3.1", true, parseHelper(u3, "protocol://host:12345/path/")); + VASSERT_EQ("3.2", "protocol", u3.getProtocol()); + VASSERT_EQ("3.3", "", u3.getUsername()); + VASSERT_EQ("3.4", "", u3.getPassword()); + VASSERT_EQ("3.5", "host", u3.getHost()); + VASSERT_EQ("3.6", 12345, u3.getPort()); + VASSERT_EQ("3.7", "/path/", u3.getPath()); + + vmime::utility::url u4("", ""); + + VASSERT_EQ("4.1", true, parseHelper(u4, "protocol://host/path/")); + VASSERT_EQ("4.2", "protocol", u4.getProtocol()); + VASSERT_EQ("4.3", "", u4.getUsername()); + VASSERT_EQ("4.4", "", u4.getPassword()); + VASSERT_EQ("4.5", "host", u4.getHost()); + VASSERT_EQ("4.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); + VASSERT_EQ("4.7", "/path/", u4.getPath()); + + vmime::utility::url u5("", ""); + + VASSERT_EQ("5.1", true, parseHelper(u5, "protocol://host/")); + VASSERT_EQ("5.2", "protocol", u5.getProtocol()); + VASSERT_EQ("5.3", "", u5.getUsername()); + VASSERT_EQ("5.4", "", u5.getPassword()); + VASSERT_EQ("5.5", "host", u5.getHost()); + VASSERT_EQ("5.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); + VASSERT_EQ("5.7", "", u5.getPath()); + + vmime::utility::url u6("", ""); + + VASSERT_EQ("6.1", true, parseHelper(u4, "protocol://host/path/file")); + VASSERT_EQ("6.2", "protocol", u4.getProtocol()); + VASSERT_EQ("6.3", "", u4.getUsername()); + VASSERT_EQ("6.4", "", u4.getPassword()); + VASSERT_EQ("6.5", "host", u4.getHost()); + VASSERT_EQ("6.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); + VASSERT_EQ("6.7", "/path/file", u4.getPath()); + } + + void testParse2() + { + // Now, test some ill-formed URLs + + // -- missing protocol + vmime::utility::url u1("", ""); + VASSERT_EQ("1", false, parseHelper(u1, "://host")); + + // -- port can contain only digits + vmime::utility::url u2("", ""); + VASSERT_EQ("2", false, parseHelper(u2, "proto://host:abc123")); + + // -- no host specified + vmime::utility::url u3("", ""); + VASSERT_EQ("3", false, parseHelper(u3, "proto:///path")); + + // -- no protocol separator (://) + vmime::utility::url u4("", ""); + VASSERT_EQ("4", false, parseHelper(u4, "protohost/path")); + } + + void testParse3() + { + // Test decoding + vmime::utility::url u1("", ""); + + VASSERT_EQ("1.1", true, parseHelper(u1, "pro%12to://user%34:pass%56word@ho%78st:12345/pa%abth/")); + VASSERT_EQ("1.2", "pro%12to", u1.getProtocol()); // protocol should not be decoded + VASSERT_EQ("1.3", "user\x34", u1.getUsername()); + VASSERT_EQ("1.4", "pass\x56word", u1.getPassword()); + VASSERT_EQ("1.5", "ho\x78st", u1.getHost()); + VASSERT_EQ("1.6", 12345, u1.getPort()); + VASSERT_EQ("1.7", "/pa\xabth/", u1.getPath()); + } + + void testParse4() + { + // Test parameters + vmime::utility::url u1("", ""); + + VASSERT_EQ("1.1", true, parseHelper(u1, "proto://host/path?p1=v1&p2=v2")); + VASSERT_EQ("1.2", "v1", u1.getParams().getProperty ("p1")); + VASSERT_EQ("1.3", "v2", u1.getParams().getProperty ("p2")); + VASSERT_EQ("1.4", "/path", u1.getPath()); + + vmime::utility::url u2("", ""); + + VASSERT_EQ("2.1", true, parseHelper(u2, "proto://host/path?p1=v1&p2")); + VASSERT_EQ("2.2", "v1", u2.getParams().getProperty ("p1")); + VASSERT_EQ("2.3", "p2", u2.getParams().getProperty ("p2")); + VASSERT_EQ("2.4", "/path", u2.getPath()); + + vmime::utility::url u3("", ""); + + VASSERT_EQ("3.1", true, parseHelper(u3, "proto://host/?p1=v1&p2=v2")); + VASSERT_EQ("3.2", "v1", u3.getParams().getProperty ("p1")); + VASSERT_EQ("3.3", "v2", u3.getParams().getProperty ("p2")); + VASSERT_EQ("3.4", "", u3.getPath()); + + vmime::utility::url u4("", ""); + + VASSERT_EQ("4.1", true, parseHelper(u4, "proto://host/path?p1=%3D&%3D=v2")); + VASSERT_EQ("4.2", "=", u4.getParams().getProperty ("p1")); + VASSERT_EQ("4.3", "v2", u4.getParams().getProperty ("=")); + VASSERT_EQ("4.4", "/path", u4.getPath()); + } + + void testGenerate() + { + vmime::utility::url u1("proto", "host", 12345, "path", "user", "password"); + VASSERT_EQ("1", "proto://user:password@host:12345/path", + static_cast (u1)); + + vmime::utility::url u2("proto", "host"); + VASSERT_EQ("2", "proto://host", static_cast (u2)); + + vmime::utility::url u3("proto", "host"); + u3.getParams().setProperty("p1", "v1"); + VASSERT_EQ("3.1", "proto://host/?p1=v1", + static_cast (u3)); + u3.getParams().setProperty("p2", "v2"); + VASSERT_EQ("3.2", "proto://host/?p1=v1&p2=v2", + static_cast (u3)); + u3.getParams().setProperty("&", "="); + VASSERT_EQ("3.3", "proto://host/?p1=v1&p2=v2&%26=%3D", + static_cast (u3)); + } + + void testUtilsEncode() + { + VASSERT_EQ("1", "%01", vmime::utility::urlUtils::encode("\x01")); + VASSERT_EQ("2", "%20", vmime::utility::urlUtils::encode(" ")); + VASSERT_EQ("3", "%FF", vmime::utility::urlUtils::encode("\xff")); + VASSERT_EQ("4", "a", vmime::utility::urlUtils::encode("a")); + } + + void testUtilsDecode() + { + for (int i = 0 ; i < 255 ; ++i) { - // Test some valid constructions - vmime::utility::url u1("", ""); + std::ostringstream ossTest; + ossTest << "%" << "0123456789ABCDEF"[i / 16] + << "0123456789ABCDEF"[i % 16]; - assert_eq("1.1", true, parseHelper(u1, "protocol://user:password@host:12345/path/")); - assert_eq("1.2", "protocol", u1.getProtocol()); - assert_eq("1.3", "user", u1.getUsername()); - assert_eq("1.4", "password", u1.getPassword()); - assert_eq("1.5", "host", u1.getHost()); - assert_eq("1.6", 12345, u1.getPort()); - assert_eq("1.7", "/path/", u1.getPath()); + std::ostringstream ossNum; + ossNum << i; - vmime::utility::url u2("", ""); + vmime::string res; + res += static_cast (i); - assert_eq("2.1", true, parseHelper(u2, "protocol://user@host:12345/path/")); - assert_eq("2.2", "protocol", u2.getProtocol()); - assert_eq("2.3", "user", u2.getUsername()); - assert_eq("2.4", "", u2.getPassword()); - assert_eq("2.5", "host", u2.getHost()); - assert_eq("2.6", 12345, u2.getPort()); - assert_eq("2.7", "/path/", u2.getPath()); - - vmime::utility::url u3("", ""); - - assert_eq("3.1", true, parseHelper(u3, "protocol://host:12345/path/")); - assert_eq("3.2", "protocol", u3.getProtocol()); - assert_eq("3.3", "", u3.getUsername()); - assert_eq("3.4", "", u3.getPassword()); - assert_eq("3.5", "host", u3.getHost()); - assert_eq("3.6", 12345, u3.getPort()); - assert_eq("3.7", "/path/", u3.getPath()); - - vmime::utility::url u4("", ""); - - assert_eq("4.1", true, parseHelper(u4, "protocol://host/path/")); - assert_eq("4.2", "protocol", u4.getProtocol()); - assert_eq("4.3", "", u4.getUsername()); - assert_eq("4.4", "", u4.getPassword()); - assert_eq("4.5", "host", u4.getHost()); - assert_eq("4.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); - assert_eq("4.7", "/path/", u4.getPath()); - - vmime::utility::url u5("", ""); - - assert_eq("5.1", true, parseHelper(u5, "protocol://host/")); - assert_eq("5.2", "protocol", u5.getProtocol()); - assert_eq("5.3", "", u5.getUsername()); - assert_eq("5.4", "", u5.getPassword()); - assert_eq("5.5", "host", u5.getHost()); - assert_eq("5.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); - assert_eq("5.7", "", u5.getPath()); - - vmime::utility::url u6("", ""); - - assert_eq("6.1", true, parseHelper(u4, "protocol://host/path/file")); - assert_eq("6.2", "protocol", u4.getProtocol()); - assert_eq("6.3", "", u4.getUsername()); - assert_eq("6.4", "", u4.getPassword()); - assert_eq("6.5", "host", u4.getHost()); - assert_eq("6.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort()); - assert_eq("6.7", "/path/file", u4.getPath()); + VASSERT_EQ(ossNum.str(), res, + vmime::utility::urlUtils::decode(ossTest.str())); } - void testParse2() - { - // Now, test some ill-formed URLs + } - // -- missing protocol - vmime::utility::url u1("", ""); - assert_eq("1", false, parseHelper(u1, "://host")); +VMIME_TEST_SUITE_END - // -- port can contain only digits - vmime::utility::url u2("", ""); - assert_eq("2", false, parseHelper(u2, "proto://host:abc123")); - - // -- no host specified - vmime::utility::url u3("", ""); - assert_eq("3", false, parseHelper(u3, "proto:///path")); - - // -- no protocol separator (://) - vmime::utility::url u4("", ""); - assert_eq("4", false, parseHelper(u4, "protohost/path")); - } - - void testParse3() - { - // Test decoding - vmime::utility::url u1("", ""); - - assert_eq("1.1", true, parseHelper(u1, "pro%12to://user%34:pass%56word@ho%78st:12345/pa%abth/")); - assert_eq("1.2", "pro%12to", u1.getProtocol()); // protocol should not be decoded - assert_eq("1.3", "user\x34", u1.getUsername()); - assert_eq("1.4", "pass\x56word", u1.getPassword()); - assert_eq("1.5", "ho\x78st", u1.getHost()); - assert_eq("1.6", 12345, u1.getPort()); - assert_eq("1.7", "/pa\xabth/", u1.getPath()); - } - - void testParse4() - { - // Test parameters - vmime::utility::url u1("", ""); - - assert_eq("1.1", true, parseHelper(u1, "proto://host/path?p1=v1&p2=v2")); - assert_eq("1.2", "v1", u1.getParams().getProperty ("p1")); - assert_eq("1.3", "v2", u1.getParams().getProperty ("p2")); - assert_eq("1.4", "/path", u1.getPath()); - - vmime::utility::url u2("", ""); - - assert_eq("2.1", true, parseHelper(u2, "proto://host/path?p1=v1&p2")); - assert_eq("2.2", "v1", u2.getParams().getProperty ("p1")); - assert_eq("2.3", "p2", u2.getParams().getProperty ("p2")); - assert_eq("2.4", "/path", u2.getPath()); - - vmime::utility::url u3("", ""); - - assert_eq("3.1", true, parseHelper(u3, "proto://host/?p1=v1&p2=v2")); - assert_eq("3.2", "v1", u3.getParams().getProperty ("p1")); - assert_eq("3.3", "v2", u3.getParams().getProperty ("p2")); - assert_eq("3.4", "", u3.getPath()); - - vmime::utility::url u4("", ""); - - assert_eq("4.1", true, parseHelper(u4, "proto://host/path?p1=%3D&%3D=v2")); - assert_eq("4.2", "=", u4.getParams().getProperty ("p1")); - assert_eq("4.3", "v2", u4.getParams().getProperty ("=")); - assert_eq("4.4", "/path", u4.getPath()); - } - - void testGenerate() - { - vmime::utility::url u1("proto", "host", 12345, "path", "user", "password"); - assert_eq("1", "proto://user:password@host:12345/path", - static_cast (u1)); - - vmime::utility::url u2("proto", "host"); - assert_eq("2", "proto://host", static_cast (u2)); - - vmime::utility::url u3("proto", "host"); - u3.getParams().setProperty("p1", "v1"); - assert_eq("3.1", "proto://host/?p1=v1", - static_cast (u3)); - u3.getParams().setProperty("p2", "v2"); - assert_eq("3.2", "proto://host/?p1=v1&p2=v2", - static_cast (u3)); - u3.getParams().setProperty("&", "="); - assert_eq("3.3", "proto://host/?p1=v1&p2=v2&%26=%3D", - static_cast (u3)); - } - - void testUtilsEncode() - { - assert_eq("1", "%01", vmime::utility::urlUtils::encode("\x01")); - assert_eq("2", "%20", vmime::utility::urlUtils::encode(" ")); - assert_eq("3", "%FF", vmime::utility::urlUtils::encode("\xff")); - assert_eq("4", "a", vmime::utility::urlUtils::encode("a")); - } - - void testUtilsDecode() - { - for (int i = 0 ; i < 255 ; ++i) - { - std::ostringstream ossTest; - ossTest << "%" << "0123456789ABCDEF"[i / 16] - << "0123456789ABCDEF"[i % 16]; - - std::ostringstream ossNum; - ossNum << i; - - vmime::string res; - res += static_cast (i); - - assert_eq(ossNum.str(), res, - vmime::utility::urlUtils::decode(ossTest.str())); - } - - } - - public: - - urlTest() : suite("vmime::utility::url") - { - // VMime initialization - vmime::platformDependant::setHandler(); - - add("Parse1", testcase(this, "Parse1", &urlTest::testParse1)); - add("Parse2", testcase(this, "Parse2", &urlTest::testParse2)); - add("Parse3", testcase(this, "Parse3", &urlTest::testParse3)); - add("Parse4", testcase(this, "Parse4", &urlTest::testParse4)); - add("Generate", testcase(this, "Generate", &urlTest::testGenerate)); - add("UtilsEncode", testcase(this, "UtilsEncode", &urlTest::testUtilsEncode)); - add("UtilsDecode", testcase(this, "UtilsDecode", &urlTest::testUtilsDecode)); - - suite::main().add("vmime::utility::url", this); - } - - }; - - urlTest* theTest = new urlTest(); -}