mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-17 16:10:24 +08:00
Purpose: Code cleanup
Description: - Used FP_EPSILON in comparing float values to verify read data - Casted C macro to fix mismatched types in verify_val calls Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test)
This commit is contained in:
parent
130e0a6638
commit
478f771243
@ -89,7 +89,7 @@ template <class Type1, class Type2>
|
||||
{
|
||||
cerr << endl;
|
||||
cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line
|
||||
<< ":" << msg << " different: " << x << ", should be " << value
|
||||
<< ": " << msg << " different: " << x << ", should be " << value
|
||||
<< endl;
|
||||
IncTestNumErrs();
|
||||
throw TestFailedException(file_name, msg);
|
||||
@ -127,6 +127,19 @@ template <class Type1, class Type2>
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Prototypes for the test routines */
|
||||
#ifdef __cplusplus
|
||||
|
@ -830,6 +830,9 @@ static void test_attr_scalar_write()
|
||||
** test_attr_scalar_read(): Test scalar attribute reading functionality.
|
||||
**
|
||||
****************************************************************/
|
||||
/* Epsilon for floating-point comparisons */
|
||||
#define FP_EPSILON 0.000001F
|
||||
|
||||
static void test_attr_scalar_read()
|
||||
{
|
||||
// Output message about test being performed
|
||||
@ -852,7 +855,8 @@ static void test_attr_scalar_read()
|
||||
// Read attribute information
|
||||
float read_data2=0.0; // Buffer for reading 1st attribute
|
||||
ds_attr.read(PredType::NATIVE_FLOAT,&read_data2);
|
||||
verify_val(read_data2, attr_data5, "Attribute::read", __LINE__, __FILE__);
|
||||
if (HDfabs(read_data2 - attr_data5) > FP_EPSILON)
|
||||
verify_val(read_data2, attr_data5, FP_EPSILON, "Attribute::read", __LINE__, __FILE__);
|
||||
|
||||
// Get the dataspace of the attribute
|
||||
DataSpace att_space = ds_attr.getSpace();
|
||||
@ -1714,7 +1718,7 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl,
|
||||
// Get creation order indexing on object
|
||||
unsigned crt_order_flags = 0;
|
||||
crt_order_flags = dcpl.getAttrCrtOrder();
|
||||
verify_val(crt_order_flags, 0, "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__);
|
||||
verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__);
|
||||
|
||||
// Setting invalid combination of a attribute order creation order
|
||||
// indexing on should fail
|
||||
@ -1731,7 +1735,7 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl,
|
||||
// verify them
|
||||
dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED);
|
||||
crt_order_flags = dcpl.getAttrCrtOrder();
|
||||
verify_val(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__);
|
||||
verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__);
|
||||
|
||||
// Create dataspace for dataset
|
||||
DataSpace ds_space(H5S_SCALAR);
|
||||
@ -1766,7 +1770,7 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl,
|
||||
|
||||
// Query the attribute creation properties
|
||||
crt_order_flags = dcpl.getAttrCrtOrder();
|
||||
verify_val(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__);
|
||||
verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__);
|
||||
|
||||
PASSED();
|
||||
} // end try block
|
||||
|
Loading…
Reference in New Issue
Block a user