diff options
Diffstat (limited to 'c++/test/trefer.cpp')
-rw-r--r-- | c++/test/trefer.cpp | 385 |
1 files changed, 194 insertions, 191 deletions
diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index b46ae29..beba36a 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -26,22 +26,22 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" -#include "h5cpputil.h" // C++ utilility header file +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILE1("trefer1.h5"); -const H5std_string FILE2("trefer2.h5"); +const H5std_string FILE1("trefer1.h5"); +const H5std_string FILE2("trefer2.h5"); // Dataset 1 -const H5std_string DSET1_NAME("Dataset1"); -const H5std_string DSET2_NAME("Dataset2"); +const H5std_string DSET1_NAME("Dataset1"); +const H5std_string DSET2_NAME("Dataset2"); -const H5std_string MEMBER1( "a_name" ); -const H5std_string MEMBER2( "b_name" ); -const H5std_string MEMBER3( "c_name" ); +const H5std_string MEMBER1("a_name"); +const H5std_string MEMBER2("b_name"); +const H5std_string MEMBER3("c_name"); // 1-D dataset with fixed dimensions const int SPACE1_RANK = 1; @@ -58,10 +58,9 @@ const int POINT1_NPOINTS = 10; typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; - /*------------------------------------------------------------------------- * Function: test_reference_params * @@ -70,30 +69,31 @@ typedef struct s1_t { * Return None *------------------------------------------------------------------------- */ -static void test_reference_params() +static void +test_reference_params() { const char *write_comment = "Foo!"; /* Comments for group */ // Output message about test being performed SUBTEST("Object Reference Parameters"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + hobj_ref_t *wbuf, // buffer to write to disk + *rbuf, // buffer read from disk + *tbuf; // temp. buffer read from disk // Allocate write & read buffers - int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); - wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t)); + wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a group @@ -105,10 +105,10 @@ static void test_reference_params() // Create a dataset (inside /Group1) DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); - unsigned *tu32; // Temporary pointer to uint32 data - int i; - for (tu32=(unsigned *)wbuf, i=0; i<SPACE1_DIM1; i++) - *tu32++=i*3; // from C test + unsigned *tu32; // Temporary pointer to uint32 data + int i; + for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) + *tu32++ = i * 3; // from C test // Write selection to disk dataset.write(wbuf, PredType::NATIVE_UINT); @@ -143,19 +143,29 @@ static void test_reference_params() /* Test parameters to H5Location::reference */ try { file1->reference(NULL, "/Group1/Dataset1"); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], NULL); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], ""); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_MAXTYPE); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_DATASET_REGION); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail // Close resources dataset.close(); @@ -169,17 +179,14 @@ static void test_reference_params() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_param()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_param()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} /* test_reference_param() */ +} /* test_reference_param() */ - /*------------------------------------------------------------------------- * Function: test_reference_obj * @@ -189,31 +196,32 @@ static void test_reference_params() * Return None *------------------------------------------------------------------------- */ -static void test_reference_obj() +static void +test_reference_obj() { - int i; // counting variables - const H5std_string write_comment="Foo!"; // Comments for group + int i; // counting variables + const H5std_string write_comment = "Foo!"; // Comments for group // Output message about test being performed SUBTEST("Object Reference Functions"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + hobj_ref_t *wbuf, // buffer to write to disk + *rbuf, // buffer read from disk + *tbuf; // temp. buffer read from disk // Allocate write & read buffers - int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); - wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t)); + wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create dataset access property list @@ -228,9 +236,9 @@ static void test_reference_obj() // Create a dataset (inside /Group1) DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); - unsigned *tu32; // Temporary pointer to uint32 data + unsigned *tu32; // Temporary pointer to uint32 data for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++=i*3; // from C test + *tu32++ = i * 3; // from C test // Write selection to disk dataset.write(wbuf, PredType::NATIVE_UINT); @@ -265,22 +273,22 @@ static void test_reference_obj() // Create reference to dataset and test getRefObjType file1->reference(&wbuf[0], "/Group1/Dataset1"); H5O_type_t refobj_type = dataset.getRefObjType(&wbuf[0], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to dataset and test getRefObjType file1->reference(&wbuf[1], "/Group1/Dataset2"); refobj_type = dataset.getRefObjType(&wbuf[1], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to group file1->reference(&wbuf[2], "/Group1"); refobj_type = dataset.getRefObjType(&wbuf[2], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to named datatype file1->reference(&wbuf[3], "/Group1/Datatype1"); refobj_type = dataset.getRefObjType(&wbuf[3], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType", __LINE__, __FILE__); // Write selection to disk dataset.write(wbuf, PredType::STD_REF_OBJ); @@ -304,15 +312,15 @@ static void test_reference_obj() DataSet dset2(dataset, &rbuf[0], H5R_OBJECT, dapl); // Check information in the referenced dataset - sid1 = dset2.getSpace(); + sid1 = dset2.getSpace(); hssize_t n_elements = sid1.getSimpleExtentNpoints(); - verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Read from disk dset2.read(tbuf, PredType::NATIVE_UINT); - for(tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - verify_val(*tu32, (uint32_t)(i*3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + for (tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) + verify_val(*tu32, (uint32_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Close dereferenced dataset dset2.close(); @@ -323,18 +331,19 @@ static void test_reference_obj() // Get group's comment using // H5std_string getComment(const char* name, <buf_size=0 by default>) H5std_string read_comment1 = group.getComment(".", 10); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__); // Test with the old default value read_comment1 = group.getComment(".", 256); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__); // Test that getComment handles failures gracefully, using // H5std_string getComment(const char* name, <buf_size=0 by default>) try { H5std_string read_comment_tmp = group.getComment(NULL); } - catch (Exception& E) {} // We expect this to fail + catch (Exception &E) { + } // We expect this to fail // Close group group.close(); @@ -349,9 +358,9 @@ static void test_reference_obj() H5T_class_t tclass; tclass = dtype1.getClass(); - verify_val(tclass, H5T_COMPOUND, "DataType::getClass",__LINE__,__FILE__); + verify_val(tclass, H5T_COMPOUND, "DataType::getClass", __LINE__, __FILE__); int n_members = dtype1.getNmembers(); - verify_val(n_members, 3, "CompType::getNmembers",__LINE__,__FILE__); + verify_val(n_members, 3, "CompType::getNmembers", __LINE__, __FILE__); // Close all objects and file dtype1.close(); @@ -365,17 +374,14 @@ static void test_reference_obj() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_obj()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_obj()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} // test_reference_obj() +} // test_reference_obj() - /*------------------------------------------------------------------------- * Function: test_reference_group * @@ -384,23 +390,24 @@ static void test_reference_obj() * Return None *------------------------------------------------------------------------- */ -#define GROUPNAME "/group" -#define GROUPNAME2 "group2" -#define GROUPNAME3 "group3" -#define DSETNAME "/dset" -#define DSETNAME2 "dset2" -#define NAME_SIZE 16 - -static void test_reference_group() +#define GROUPNAME "/group" +#define GROUPNAME2 "group2" +#define GROUPNAME3 "group3" +#define DSETNAME "/dset" +#define DSETNAME2 "dset2" +#define NAME_SIZE 16 + +static void +test_reference_group() { - hobj_ref_t wref; /* Reference to write */ - hobj_ref_t rref; /* Reference to read */ - const H5std_string write_comment="Foo!"; // Comments for group + hobj_ref_t wref; /* Reference to write */ + hobj_ref_t rref; /* Reference to read */ + const H5std_string write_comment = "Foo!"; // Comments for group // Output message about test being performed SUBTEST("Object Reference to Group"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { /* * Create file with a group and a dataset containing an object @@ -408,7 +415,7 @@ static void test_reference_group() */ // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create scalar dataspace DataSpace sid1; @@ -467,25 +474,25 @@ static void test_reference_group() // Check number of objects in the group dereferenced by constructor hsize_t nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check number of objects in the group dereferenced by ::reference nobjs = group.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check getting file name given the group dereferenced via constructor H5std_string fname = refgroup.getFileName(); - verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); + verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__); // Check getting file name given the group dereferenced by ::reference fname = group.getFileName(); - verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); + verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__); // Check object type using Group::getObjinfo() H5O_info2_t oinfo; HDmemset(&oinfo, 0, sizeof(oinfo)); group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, oinfo); - verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo",__LINE__,__FILE__); + verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo", __LINE__, __FILE__); // Check for out of bound query by index try { @@ -494,12 +501,14 @@ static void test_reference_group() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("Group::getObjinfo", "Out of bound index."); - } catch (Exception& err) {} // do nothing, failure expected + } + catch (Exception &err) { + } // do nothing, failure expected // Unlink one of the objects in the dereferenced group, and re-check refgroup.unlink(GROUPNAME2); nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs", __LINE__, __FILE__); // Close resources group.close(); @@ -509,17 +518,14 @@ static void test_reference_group() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_group()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_group()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} /* test_reference_group() */ +} /* test_reference_group() */ - /*------------------------------------------------------------------------- * Function: test_reference_region_1D * @@ -528,30 +534,31 @@ static void test_reference_group() * Return None *------------------------------------------------------------------------- */ -static void test_reference_region_1D() +static void +test_reference_region_1D() { - hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ - hsize_t * coords; /* Coordinate buffer */ - hsize_t low[SPACE3_RANK]; /* Selection bounds */ - hsize_t high[SPACE3_RANK]; /* Selection bounds */ - int i; /* counting variables */ + hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ + hsize_t *coords; /* Coordinate buffer */ + hsize_t low[SPACE3_RANK]; /* Selection bounds */ + hsize_t high[SPACE3_RANK]; /* Selection bounds */ + int i; /* counting variables */ // Output message about test being performed SUBTEST("1-D Dataset Region Reference Functions"); try { - hdset_reg_ref_t *wbuf, // buffer to write to disk - *rbuf; // buffer read from disk - uint8_t *dwbuf, // Buffer for writing numeric data to disk - *drbuf; // Buffer for reading numeric data from disk + hdset_reg_ref_t *wbuf, // buffer to write to disk + *rbuf; // buffer read from disk + uint8_t *dwbuf, // Buffer for writing numeric data to disk + *drbuf; // Buffer for reading numeric data from disk // Allocate write & read buffers - wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1); drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); @@ -559,7 +566,7 @@ static void test_reference_region_1D() H5File file1(FILE2, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims3[] = {SPACE3_DIM1}; + hsize_t dims3[] = {SPACE3_DIM1}; DataSpace sid3(SPACE3_RANK, dims3); // Create dataset access property list @@ -568,7 +575,7 @@ static void test_reference_region_1D() // Create a dataset DataSet dset3 = file1.createDataSet(DSET2_NAME, PredType::STD_U8LE, sid3); - uint8_t *tu8; // Temporary pointer to uint8 data + uint8_t *tu8; // Temporary pointer to uint8 data for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) *tu8++ = i * 3; // from C test @@ -579,7 +586,7 @@ static void test_reference_region_1D() dset3.close(); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a dataset @@ -590,24 +597,24 @@ static void test_reference_region_1D() */ /* Select 15 2x1 hyperslabs for first reference */ - start[0] = 2; + start[0] = 2; stride[0] = 5; - count[0] = 15; - block[0] = 2; + count[0] = 15; + block[0] = 2; // Select a hyperslab region to add to the current selected region sid3.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); // Get and verify the number of elements in a dataspace selection hssize_t nelms = sid3.getSelectNpoints(); - verify_val(nelms, 30, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(nelms, 30, "DataSet::getRefObjType", __LINE__, __FILE__); // Store first dataset region file1.reference(&wbuf[0], "/Dataset2", sid3); // Get and verify object type H5O_type_t obj_type = dset1.getRefObjType(&wbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); /* Select sequence of ten points for second reference */ coord1[0][0] = 16; @@ -626,7 +633,7 @@ static void test_reference_region_1D() // Get and verify the number of elements in a dataspace selection nelms = sid3.getSelectNpoints(); - verify_val(nelms, 10, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(nelms, 10, "DataSet::getRefObjType", __LINE__, __FILE__); // Store first dataset region file1.reference(&wbuf[1], "/Dataset2", sid3); @@ -658,12 +665,12 @@ static void test_reference_region_1D() // Get and verify object type obj_type = dset1.getRefObjType(&rbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Get dataspace of dset3 the verify number of elements - sid1 = dset3.getSpace(); + sid1 = dset3.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); } // End of test DataSet::dereference { // Test DataSet constructor -by dereference @@ -672,9 +679,9 @@ static void test_reference_region_1D() DataSet newds(dset1, &rbuf[0], H5R_DATASET_REGION, dapl); // Get dataspace of newds then verify number of elements - sid1 = newds.getSpace(); + sid1 = newds.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Close objects for this mini test newds.close(); @@ -684,8 +691,8 @@ static void test_reference_region_1D() // Read from disk dset3.read(drbuf, PredType::STD_U8LE); - for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) - verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + for (tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) + verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); /* * Test getting the referenced region @@ -696,11 +703,11 @@ static void test_reference_region_1D() // Get and verify number of elements in a dataspace selection nelms = reg_sp.getSelectNpoints(); - verify_val((long)nelms, 30, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 30, "DataSpace::getSelectNpoints", __LINE__, __FILE__); // Get and verify number of hyperslab blocks nelms = reg_sp.getSelectHyperNblocks(); - verify_val((long)nelms, 15, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 15, "DataSpace::getSelectNpoints", __LINE__, __FILE__); /* Allocate space for the hyperslab blocks */ coords = (hsize_t *)HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2); @@ -709,43 +716,43 @@ static void test_reference_region_1D() reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords); // Verify values in the list - verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[4],(hsize_t)12, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[5],(hsize_t)13, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[6],(hsize_t)17, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[7],(hsize_t)18, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[8],(hsize_t)22, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[9],(hsize_t)23, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[10],(hsize_t)27, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[11],(hsize_t)28, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[12],(hsize_t)32, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[13],(hsize_t)33, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[14],(hsize_t)37, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[15],(hsize_t)38, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[16],(hsize_t)42, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[17],(hsize_t)43, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[18],(hsize_t)47, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[19],(hsize_t)48, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[20],(hsize_t)52, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[21],(hsize_t)53, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[22],(hsize_t)57, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[23],(hsize_t)58, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[24],(hsize_t)62, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[25],(hsize_t)63, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[26],(hsize_t)67, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[27],(hsize_t)68, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[28],(hsize_t)72, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[29],(hsize_t)73, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[4], (hsize_t)12, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[5], (hsize_t)13, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[6], (hsize_t)17, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[7], (hsize_t)18, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[8], (hsize_t)22, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[9], (hsize_t)23, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[10], (hsize_t)27, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[11], (hsize_t)28, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[12], (hsize_t)32, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[13], (hsize_t)33, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[14], (hsize_t)37, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[15], (hsize_t)38, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[16], (hsize_t)42, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[17], (hsize_t)43, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[18], (hsize_t)47, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[19], (hsize_t)48, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[20], (hsize_t)52, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[21], (hsize_t)53, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[22], (hsize_t)57, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[23], (hsize_t)58, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[24], (hsize_t)62, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[25], (hsize_t)63, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[26], (hsize_t)67, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[27], (hsize_t)68, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[28], (hsize_t)72, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[29], (hsize_t)73, "Hyperslab Coordinates", __LINE__, __FILE__); HDfree(coords); // Check boundaries reg_sp.getSelectBounds(low, high); - verify_val(low[0],(hsize_t)2, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)73, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0], (hsize_t)2, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(high[0], (hsize_t)73, "DataSpace::getSelectBounds", __LINE__, __FILE__); /* Close region space */ reg_sp.close(); @@ -759,7 +766,7 @@ static void test_reference_region_1D() // Get and verify number of element points in the current selection hssize_t nelmspts = elm_sp.getSelectElemNpoints(); - verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints", __LINE__, __FILE__); /* Allocate space for the hyperslab blocks */ coords = (hsize_t *)HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t)); @@ -768,23 +775,23 @@ static void test_reference_region_1D() elm_sp.getSelectElemPointlist((hsize_t)0, (hsize_t)nelmspts, coords); // Verify points - verify_val(coords[0], coord1[0][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[1], coord1[1][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[2], coord1[2][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[3], coord1[3][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[4], coord1[4][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[5], coord1[5][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[6], coord1[6][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[7], coord1[7][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[8], coord1[8][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[9], coord1[9][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[0], coord1[0][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[1], coord1[1][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[2], coord1[2][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[3], coord1[3][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[4], coord1[4][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[5], coord1[5][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[6], coord1[6][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[7], coord1[7][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[8], coord1[8][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[9], coord1[9][0], "Element Coordinates", __LINE__, __FILE__); HDfree(coords); // Check boundaries elm_sp.getSelectBounds(low, high); - verify_val(low[0],(hsize_t)3, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)97, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0], (hsize_t)3, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(high[0], (hsize_t)97, "DataSpace::getSelectBounds", __LINE__, __FILE__); // Close element space elm_sp.close(); @@ -803,12 +810,10 @@ static void test_reference_region_1D() PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_region_1D()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } -} /* test_reference_region_1D() */ +} /* test_reference_region_1D() */ /*------------------------------------------------------------------------- * @@ -816,8 +821,8 @@ static void test_reference_region_1D() * *------------------------------------------------------------------------- */ -extern "C" -void test_reference() +extern "C" void +test_reference() { // Output message about test being performed MESSAGE(5, ("Testing References\n")); @@ -827,9 +832,8 @@ void test_reference() test_reference_group(); // Test group reference functionality test_reference_region_1D(); // Test 1-D reference functionality -} // test_reference() +} // test_reference() - /*------------------------------------------------------------------------- * Function: cleanup_reference * @@ -838,10 +842,9 @@ void test_reference() * Return None *------------------------------------------------------------------------- */ -extern "C" -void cleanup_reference() +extern "C" void +cleanup_reference() { HDremove(FILE1.c_str()); HDremove(FILE2.c_str()); } - |