h5cpputil.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 /*****************************************************************************
00017    FILE
00018    h5cpputil.h - Header file of the utilities/misc for HDF5 C++ tests.
00019 
00020    EXTERNAL ROUTINES/VARIABLES:
00021 
00022  ***************************************************************************/
00023 
00024 #ifndef _h5cpputil_h
00025 #define _h5cpputil_h
00026 
00027 #include "h5test.h"
00028 
00029 #ifndef H5_NO_NAMESPACE
00030 using namespace H5;
00031 #endif
00032 
00033 #ifndef H5_NO_STD
00034 using std::cerr;
00035 using std::endl;
00036 #endif
00037 
00038 #define MESSAGE(V,A) {if (HDGetTestVerbosity()>(V)) print_func A;}
00039 #define SUBTEST(TEST) {printf("   Subtest: %-52s",TEST); fflush(stdout);}
00040 
00041 int check_values (hsize_t i, hsize_t j, int apoint, int acheck);
00042 int test_report (int, const H5std_string&);
00043 void issue_fail_msg(const char* where, int line, const char* file_name,
00044                     const char* message="");
00045 
00046 class InvalidActionException : public Exception {
00047    public:
00048         InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
00049         InvalidActionException();
00050         virtual ~InvalidActionException();
00051 };
00052 
00053 class TestFailedException : public Exception {
00054    public:
00055         TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
00056         TestFailedException();
00057         virtual ~TestFailedException();
00058 };
00059 
00060 template <class Type1, class Type2>
00061     void verify_val(Type1 x, Type2 value, const char* where, int line, const char* file_name)
00062 {
00063     if (GetTestVerbosity()>=VERBO_HI)
00064     {
00065         cerr << endl;
00066         cerr << "   Call to routine: " << where << " at line " << line
00067              << " in " << file_name <<  " had value " << x << endl;
00068     }
00069     if (x != value)
00070     {
00071         cerr << endl;
00072         cerr << "*** UNEXPECTED VALUE from " << where << " should be "
00073              << value << ", but is " << x << " at line " << line
00074              << " in " << file_name << endl;
00075         IncTestNumErrs();
00076         throw TestFailedException(where, "");
00077     }
00078 }
00079 
00080 template <class Type1, class Type2>
00081     void verify_val(Type1 x, Type2 value, const char* msg, const char* file_name, int line)
00082 {
00083     if (x != value)
00084     {
00085         cerr << endl;
00086         cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line
00087              << ":" << msg << " different: " << x << ", should be " << value
00088              << endl;
00089         IncTestNumErrs();
00090         throw TestFailedException(file_name, msg);
00091     }
00092 }
00093 
00094 template <class Type1, class Type2>
00095     void verify_val_noteq(Type1 x, Type2 value, const char* where, int line, const char* file_name)
00096 {
00097     if (GetTestVerbosity()>=VERBO_HI)
00098     {
00099         cerr << endl;
00100         cerr << "   Call to routine: " << where << " at line " << line
00101              << " in " << file_name <<  " had value " << x << endl;
00102     }
00103     if (x == value)
00104     {
00105         cerr << endl;
00106         cerr << "*** UNEXPECTED VALUE from " << where << " should not be "
00107              << value << " at line " << line << " in " << file_name << endl;
00108         IncTestNumErrs();
00109         throw TestFailedException(where, "");
00110     }
00111 }
00112 
00113 /* Prototypes for the test routines */
00114 #ifdef __cplusplus
00115 extern "C" {
00116 #endif
00117 void test_attr();
00118 void test_compound();
00119 void test_file();
00120 void test_filters();
00121 void test_links();
00122 void test_h5s();
00123 void test_reference();
00124 void test_types();
00125 void test_vlstrings();
00126 void test_dset();
00127 
00128 /* Prototypes for the cleanup routines */
00129 void cleanup_attr();
00130 void cleanup_compound();
00131 void cleanup_dsets();
00132 void cleanup_file();
00133 void cleanup_filters();
00134 void cleanup_links();
00135 void cleanup_h5s();
00136 void cleanup_reference();
00137 void cleanup_types();
00138 void cleanup_vlstrings();
00139 
00140 #ifdef __cplusplus
00141 }
00142 #endif
00143 
00144 /* not yet
00145 void cleanup_select(void);
00146 void cleanup_time(void);
00147 void cleanup_vltypes(void);
00148 void cleanup_iterate(void);
00149 void cleanup_array(void);
00150 void cleanup_genprop(void);
00151 void cleanup_misc(void);
00152 */
00153 
00154 #endif