2003-06-10 01:42:02 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2005-10-01 23:29:18 +08:00
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2005-10-01 23:29:18 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
2003-06-10 01:42:02 +08:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
FILE
|
|
|
|
h5cpputil.h - Header file of the utilities/misc for HDF5 C++ tests.
|
|
|
|
|
|
|
|
EXTERNAL ROUTINES/VARIABLES:
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _h5cpputil_h
|
|
|
|
#define _h5cpputil_h
|
|
|
|
|
2005-03-20 12:01:25 +08:00
|
|
|
#include "h5test.h"
|
|
|
|
|
2005-02-26 11:43:26 +08:00
|
|
|
using namespace H5;
|
2004-12-21 04:01:46 +08:00
|
|
|
using std::cerr;
|
|
|
|
using std::endl;
|
2003-06-10 01:42:02 +08:00
|
|
|
|
2010-02-27 00:55:49 +08:00
|
|
|
#define MESSAGE(V,A) {if (HDGetTestVerbosity()>(V)) print_func A;}
|
|
|
|
#define SUBTEST(TEST) {printf(" Subtest: %-52s",TEST); fflush(stdout);}
|
2006-03-31 02:06:58 +08:00
|
|
|
|
2007-01-29 10:41:27 +08:00
|
|
|
int check_values (hsize_t i, hsize_t j, int apoint, int acheck);
|
2016-09-22 03:53:17 +08:00
|
|
|
void check_values(const char *value, const char* msg, int line, const char* file_name);
|
2007-01-26 13:40:17 +08:00
|
|
|
int test_report (int, const H5std_string&);
|
2005-01-31 12:03:36 +08:00
|
|
|
void issue_fail_msg(const char* where, int line, const char* file_name,
|
2017-03-03 22:45:57 +08:00
|
|
|
const char* message="");
|
2013-09-23 08:39:44 +08:00
|
|
|
void issue_fail_msg(const char* where, int line, const char* file_name,
|
2017-03-03 22:45:57 +08:00
|
|
|
const char* func_name, const char* message);
|
2004-12-21 04:01:46 +08:00
|
|
|
|
2007-03-18 00:26:53 +08:00
|
|
|
class InvalidActionException : public Exception {
|
|
|
|
public:
|
2017-03-03 22:45:57 +08:00
|
|
|
InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
|
|
|
|
InvalidActionException();
|
|
|
|
virtual ~InvalidActionException() throw();
|
2007-03-18 00:26:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class TestFailedException : public Exception {
|
|
|
|
public:
|
2017-03-03 22:45:57 +08:00
|
|
|
TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
|
|
|
|
TestFailedException();
|
|
|
|
virtual ~TestFailedException() throw();
|
2007-03-18 00:26:53 +08:00
|
|
|
};
|
|
|
|
|
2010-05-03 03:15:43 +08:00
|
|
|
// Overloaded/Template functions to verify values and display proper info
|
2016-09-22 03:53:17 +08:00
|
|
|
|
|
|
|
// Verifies
|
2010-05-03 03:15:43 +08:00
|
|
|
void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name);
|
|
|
|
|
2004-12-21 04:01:46 +08:00
|
|
|
template <class Type1, class Type2>
|
|
|
|
void verify_val(Type1 x, Type2 value, const char* where, int line, const char* file_name)
|
|
|
|
{
|
|
|
|
if (GetTestVerbosity()>=VERBO_HI)
|
|
|
|
{
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2004-12-21 04:01:46 +08:00
|
|
|
cerr << " Call to routine: " << where << " at line " << line
|
2017-03-03 22:45:57 +08:00
|
|
|
<< " in " << file_name << " had value " << x << endl;
|
2004-12-21 04:01:46 +08:00
|
|
|
}
|
|
|
|
if (x != value)
|
|
|
|
{
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2004-12-21 04:01:46 +08:00
|
|
|
cerr << "*** UNEXPECTED VALUE from " << where << " should be "
|
2017-03-03 22:45:57 +08:00
|
|
|
<< value << ", but is " << x << " at line " << line
|
|
|
|
<< " in " << file_name << endl;
|
|
|
|
IncTestNumErrs();
|
|
|
|
throw TestFailedException(where, "");
|
2005-03-20 12:01:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Type1, class Type2>
|
|
|
|
void verify_val(Type1 x, Type2 value, const char* msg, const char* file_name, int line)
|
|
|
|
{
|
|
|
|
if (x != value)
|
|
|
|
{
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2005-08-14 04:53:35 +08:00
|
|
|
cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line
|
2017-03-03 22:45:57 +08:00
|
|
|
<< ": " << msg << " different: " << x << ", should be " << value
|
|
|
|
<< endl;
|
|
|
|
IncTestNumErrs();
|
|
|
|
throw TestFailedException(file_name, msg);
|
2004-12-21 04:01:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-26 13:40:17 +08:00
|
|
|
template <class Type1, class Type2>
|
|
|
|
void verify_val_noteq(Type1 x, Type2 value, const char* where, int line, const char* file_name)
|
|
|
|
{
|
|
|
|
if (GetTestVerbosity()>=VERBO_HI)
|
|
|
|
{
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2007-01-26 13:40:17 +08:00
|
|
|
cerr << " Call to routine: " << where << " at line " << line
|
2017-03-03 22:45:57 +08:00
|
|
|
<< " in " << file_name << " had value " << x << endl;
|
2007-01-26 13:40:17 +08:00
|
|
|
}
|
|
|
|
if (x == value)
|
|
|
|
{
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2007-01-26 13:40:17 +08:00
|
|
|
cerr << "*** UNEXPECTED VALUE from " << where << " should not be "
|
2017-03-03 22:45:57 +08:00
|
|
|
<< value << " at line " << line << " in " << file_name << endl;
|
|
|
|
IncTestNumErrs();
|
|
|
|
throw TestFailedException(where, "");
|
2007-01-26 13:40:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-09 12:03:03 +08:00
|
|
|
template <class Type1, class Type2>
|
|
|
|
void CHECK(Type1 x, Type2 value, const char* msg, int line, const char* file_name)
|
|
|
|
{
|
|
|
|
if (x == value)
|
|
|
|
{
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2014-04-09 12:03:03 +08:00
|
|
|
cerr << "*** Function " << msg << " FAILED at line " << line << endl;
|
2017-03-03 22:45:57 +08:00
|
|
|
IncTestNumErrs();
|
|
|
|
throw TestFailedException(file_name, msg);
|
2014-04-09 12:03:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-02 11:14:22 +08:00
|
|
|
template <class Type1, class Type2>
|
|
|
|
void verify_val(Type1 x, Type2 value, float epsilon, const char* msg, int line, const char* file_name)
|
|
|
|
{
|
|
|
|
if (x == value)
|
|
|
|
{
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
|
|
|
cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line
|
|
|
|
<< ": " << msg << " different: " << x << ", should be " << value
|
|
|
|
<< " (epsilon=" << epsilon << ")" << endl;
|
|
|
|
IncTestNumErrs();
|
|
|
|
throw TestFailedException(file_name, msg);
|
2016-09-02 11:14:22 +08:00
|
|
|
}
|
|
|
|
}
|
2014-04-09 12:03:03 +08:00
|
|
|
|
2007-01-26 13:40:17 +08:00
|
|
|
/* Prototypes for the test routines */
|
2007-03-08 17:50:55 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2016-01-15 23:53:33 +08:00
|
|
|
void test_array();
|
2009-10-21 02:14:34 +08:00
|
|
|
void test_attr();
|
|
|
|
void test_compound();
|
2014-03-31 00:15:11 +08:00
|
|
|
void test_dsproplist();
|
2009-10-21 02:14:34 +08:00
|
|
|
void test_file();
|
|
|
|
void test_filters();
|
|
|
|
void test_links();
|
|
|
|
void test_h5s();
|
2016-09-22 03:53:17 +08:00
|
|
|
void test_iterate();
|
2014-04-07 06:36:15 +08:00
|
|
|
void test_object();
|
2009-10-21 02:14:34 +08:00
|
|
|
void test_reference();
|
|
|
|
void test_types();
|
|
|
|
void test_vlstrings();
|
2010-02-27 00:55:49 +08:00
|
|
|
void test_dset();
|
2007-01-26 13:40:17 +08:00
|
|
|
|
|
|
|
/* Prototypes for the cleanup routines */
|
2016-01-15 23:53:33 +08:00
|
|
|
void cleanup_array();
|
2009-10-21 02:14:34 +08:00
|
|
|
void cleanup_attr();
|
|
|
|
void cleanup_compound();
|
2014-03-31 00:15:11 +08:00
|
|
|
void cleanup_dsproplist();
|
2009-10-21 02:14:34 +08:00
|
|
|
void cleanup_dsets();
|
|
|
|
void cleanup_file();
|
|
|
|
void cleanup_filters();
|
|
|
|
void cleanup_h5s();
|
2016-09-22 03:53:17 +08:00
|
|
|
void cleanup_iterate();
|
|
|
|
void cleanup_links();
|
2014-04-07 06:36:15 +08:00
|
|
|
void cleanup_object();
|
2009-10-21 02:14:34 +08:00
|
|
|
void cleanup_reference();
|
|
|
|
void cleanup_types();
|
|
|
|
void cleanup_vlstrings();
|
2007-03-08 17:50:55 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-01-26 13:40:17 +08:00
|
|
|
/* not yet
|
|
|
|
void cleanup_select(void);
|
|
|
|
void cleanup_time(void);
|
|
|
|
void cleanup_vltypes(void);
|
|
|
|
void cleanup_array(void);
|
|
|
|
void cleanup_genprop(void);
|
|
|
|
void cleanup_misc(void);
|
|
|
|
*/
|
|
|
|
|
2003-06-10 01:42:02 +08:00
|
|
|
#endif
|