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
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
2017-04-18 03:32:16 +08:00
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
2021-02-17 22:52:36 +08:00
|
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
2017-04-18 03:32:16 +08:00
|
|
|
* 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:
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
2021-02-23 12:29:56 +08:00
|
|
|
#ifndef H5cpputil_H
|
|
|
|
#define H5cpputil_H
|
2003-06-10 01:42:02 +08:00
|
|
|
|
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
|
|
|
|
2020-09-30 22:27:10 +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
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
int check_values(hsize_t i, hsize_t j, int apoint, int acheck);
|
|
|
|
void check_values(const char *value, const char *msg, int line, const char *file_name);
|
|
|
|
int test_report(int, const H5std_string &);
|
|
|
|
void issue_fail_msg(const char *where, int line, const char *file_name, const char *message = "");
|
|
|
|
void issue_fail_msg(const char *where, int line, const char *file_name, 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 {
|
2020-09-30 22:27:10 +08:00
|
|
|
public:
|
2021-03-11 02:41:34 +08:00
|
|
|
InvalidActionException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
|
2020-09-30 22:27:10 +08:00
|
|
|
InvalidActionException();
|
2022-06-23 00:16:30 +08:00
|
|
|
~InvalidActionException() throw() override;
|
2007-03-18 00:26:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class TestFailedException : public Exception {
|
2020-09-30 22:27:10 +08:00
|
|
|
public:
|
2021-03-11 02:41:34 +08:00
|
|
|
TestFailedException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
|
2020-09-30 22:27:10 +08:00
|
|
|
TestFailedException();
|
2022-06-23 00:16:30 +08:00
|
|
|
~TestFailedException() throw() override;
|
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
|
|
|
|
2020-04-21 07:12:00 +08:00
|
|
|
// Verifies
|
2020-09-30 22:27:10 +08:00
|
|
|
void verify_val(const char *x, const char *value, const char *where, int line, const char *file_name);
|
2010-05-03 03:15:43 +08:00
|
|
|
|
2004-12-21 04:01:46 +08:00
|
|
|
template <class Type1, class Type2>
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
verify_val(Type1 x, Type2 value, const char *where, int line, const char *file_name)
|
2004-12-21 04:01:46 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
if (GetTestVerbosity() >= VERBO_HI) {
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2020-09-30 22:27:10 +08:00
|
|
|
cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value "
|
|
|
|
<< x << endl;
|
2004-12-21 04:01:46 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
if (x != value) {
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2020-09-30 22:27:10 +08:00
|
|
|
cerr << "*** UNEXPECTED VALUE from " << where << " should be " << value << ", but is " << x
|
|
|
|
<< " at line " << line << " in " << file_name << endl;
|
2017-03-03 22:45:57 +08:00
|
|
|
IncTestNumErrs();
|
|
|
|
throw TestFailedException(where, "");
|
2005-03-20 12:01:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Type1, class Type2>
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
verify_val(Type1 x, Type2 value, const char *msg, const char *file_name, int line)
|
2005-03-20 12:01:25 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
if (x != value) {
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2020-09-30 22:27:10 +08:00
|
|
|
cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line << ": " << msg
|
|
|
|
<< " different: " << x << ", should be " << value << endl;
|
2017-03-03 22:45:57 +08:00
|
|
|
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>
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
verify_val_noteq(Type1 x, Type2 value, const char *where, int line, const char *file_name)
|
2007-01-26 13:40:17 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
if (GetTestVerbosity() >= VERBO_HI) {
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2020-09-30 22:27:10 +08:00
|
|
|
cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value "
|
|
|
|
<< x << endl;
|
2007-01-26 13:40:17 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
if (x == value) {
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2020-09-30 22:27:10 +08:00
|
|
|
cerr << "*** UNEXPECTED VALUE from " << where << " should not be " << value << " at line " << line
|
|
|
|
<< " in " << file_name << endl;
|
2017-03-03 22:45:57 +08:00
|
|
|
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>
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
CHECK(Type1 x, Type2 value, const char *msg, int line, const char *file_name)
|
2014-04-09 12:03:03 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
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>
|
2020-09-30 22:27:10 +08:00
|
|
|
void
|
|
|
|
verify_val(Type1 x, Type2 value, float epsilon, const char *msg, int line, const char *file_name)
|
2016-09-02 11:14:22 +08:00
|
|
|
{
|
2020-09-30 22:27:10 +08:00
|
|
|
if (x == value) {
|
2017-03-03 22:45:57 +08:00
|
|
|
cerr << endl;
|
2020-09-30 22:27:10 +08:00
|
|
|
cerr << "*** UNEXPECTED FLOAT VALUE: " << file_name << ":line " << line << ": " << msg
|
|
|
|
<< " different: " << x << ", should be " << value << " (epsilon=" << epsilon << ")" << endl;
|
2017-03-03 22:45:57 +08:00
|
|
|
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
|