diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
commit | b2d661b508a7fc7a2592c13bc6bdc175551f075d (patch) | |
tree | 13baeb0d83a7c2a4c6299993c182b1227c2f6114 /hl/c++ | |
parent | 29ab58b58dce556639ea3154e262895773a8a8df (diff) | |
download | hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2 |
Clang-format of source files
Diffstat (limited to 'hl/c++')
-rw-r--r-- | hl/c++/examples/ptExampleFL.cpp | 51 | ||||
-rw-r--r-- | hl/c++/src/H5PacketTable.cpp | 512 | ||||
-rw-r--r-- | hl/c++/src/H5PacketTable.h | 52 | ||||
-rw-r--r-- | hl/c++/test/ptableTest.cpp | 552 |
4 files changed, 592 insertions, 575 deletions
diff --git a/hl/c++/examples/ptExampleFL.cpp b/hl/c++/examples/ptExampleFL.cpp index 26cbf09..d0b62da 100644 --- a/hl/c++/examples/ptExampleFL.cpp +++ b/hl/c++/examples/ptExampleFL.cpp @@ -22,56 +22,55 @@ *------------------------------------------------------------------------- */ -const char* FILE_NAME("PTcppexampleFL.h5"); -const char* PT_NAME("/examplePacketTable"); +const char *FILE_NAME("PTcppexampleFL.h5"); +const char *PT_NAME("/examplePacketTable"); -int main(void) +int +main(void) { - herr_t err; /* Return value from function calls */ - hid_t fileID; /* HDF5 identifier for file */ - hid_t plistID; /* HDF5 identifier for property list to use compression */ - hsize_t count; /* Number of records in table */ - int x; /* Temporary counter variable */ + herr_t err; /* Return value from function calls */ + hid_t fileID; /* HDF5 identifier for file */ + hid_t plistID; /* HDF5 identifier for property list to use compression */ + hsize_t count; /* Number of records in table */ + int x; /* Temporary counter variable */ /* Buffers to hold data */ int readBuffer[5]; int writeBuffer[5]; /* Initialize buffers */ - for(x=0; x<5; x++) - { - writeBuffer[x]=x; - readBuffer[x] = -1; + for (x = 0; x < 5; x++) { + writeBuffer[x] = x; + readBuffer[x] = -1; } /* Create a new HDF5 file */ fileID = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(fileID <0) + if (fileID < 0) fprintf(stderr, "Couldn't create file.\n"); /* Prepare property list to set compression, randomly use deflate with compression level 5. */ plistID = H5Pcreate(H5P_DATASET_CREATE); - err = H5Pset_deflate(plistID, 5); - if(err < 0) + err = H5Pset_deflate(plistID, 5); + if (err < 0) fprintf(stderr, "Error setting compression level."); /* Create a fixed-length packet table. */ FL_PacketTable ptable(fileID, plistID, PT_NAME, H5T_NATIVE_INT, 100); - if(! ptable.IsValid()) + if (!ptable.IsValid()) fprintf(stderr, "Unable to create packet table."); /* Append five packets to the packet table, one at a time */ - for(x=0; x<5; x++) - { - err = ptable.AppendPacket( &(writeBuffer[x]) ); - if(err<0) + for (x = 0; x < 5; x++) { + err = ptable.AppendPacket(&(writeBuffer[x])); + if (err < 0) fprintf(stderr, "Error adding record."); } /* Get the number of packets in the packet table. This should be five. */ count = ptable.GetPacketCount(err); - if(err < 0) + if (err < 0) fprintf(stderr, "Error getting packet count."); printf("Number of packets in packet table after five appends: %d\n", count); @@ -80,10 +79,9 @@ int main(void) ptable.ResetIndex(); /* Iterate through packets, read each one back */ - for(x=0; x<5; x++) - { - err = ptable.GetNextPacket( &(readBuffer[x]) ); - if(err < 0) + for (x = 0; x < 5; x++) { + err = ptable.GetNextPacket(&(readBuffer[x])); + if (err < 0) fprintf(stderr, "Error reading record."); printf("Packet %d's value is %d.\n", x, readBuffer[x]); @@ -93,9 +91,8 @@ int main(void) /* out of scope. */ err = H5Fclose(fileID); - if( err < 0 ) + if (err < 0) fprintf(stderr, "Failed to close file.\n"); return 0; } - diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp index 544df0b..1409048 100644 --- a/hl/c++/src/H5PacketTable.cpp +++ b/hl/c++/src/H5PacketTable.cpp @@ -24,257 +24,265 @@ #include "H5PacketTable.h" - /********************************/ - /* PacketTable superclass */ - /********************************/ - - /* "Open" Constructor - * Opens an existing packet table, which can contain either fixed-length or - * variable-length packets. - */ - PacketTable::PacketTable(hid_t fileID, const char* name) - { - table_id = H5PTopen( fileID, name); - } - - /* "Open" Constructor - will be deprecated because of char* name */ - PacketTable::PacketTable(hid_t fileID, char* name) - { - table_id = H5PTopen( fileID, name); - } - - /* Destructor - * Cleans up the packet table - */ - PacketTable::~PacketTable() - { - H5PTclose( table_id); - } - - /* IsValid - * Returns true if this packet table is valid, false otherwise. - * Use this after the constructor to ensure HDF did not have - * any trouble making or opening the packet table. - */ - bool PacketTable::IsValid() - { - if (H5PTis_valid(table_id) == 0) - return true; - else - return false; - } - - /* IsVariableLength - * Return 1 if this packet table uses variable-length datatype, - * and 0, otherwise. Returns -1 if the table is invalid (not open). - */ - int PacketTable::IsVariableLength() - { - return H5PTis_varlen(table_id); - } - - /* ResetIndex - * Sets the index to point to the first packet in the packet table - */ - void PacketTable::ResetIndex() - { - H5PTcreate_index(table_id); - } - - /* SetIndex - * Sets the index to point to the packet specified by index. - * Returns 0 on success, negative on failure (if index is out of bounds) - */ - int PacketTable::SetIndex(hsize_t index) - { - return H5PTset_index(table_id, index); - } - - /* SetIndex - * Sets the index to point to the packet specified by index. - * Returns 0 on success, negative on failure (if index is out of bounds) - */ - hsize_t PacketTable::GetIndex(int &error) - { - hsize_t index; - - error = H5PTget_index(table_id, &index); - if(error < 0) - return 0; - else - return index; - } - - /* GetPacketCount - * Returns the number of packets in the packet table. Error - * is set to 0 on success. On failure, returns 0 and - * error is set to negative. - */ - hsize_t PacketTable::GetPacketCount(int& error) - { - hsize_t npackets; - - error = H5PTget_num_packets(table_id, &npackets); - return npackets; - } - - /* GetTableId - * Returns the identifier of the packet table - */ - hid_t PacketTable::GetTableId() - { - return table_id; - } - - /* GetDatatype - * Returns the datatype identifier used by the packet table, on success, - * or H5I_INVALID_HID, on failure. - * Note: it is best to avoid using this identifier in applications, unless - * the desired functionality cannot be performed via the packet table ID. - */ - hid_t PacketTable::GetDatatype() - { - return H5PTget_type(table_id); - } - - /* GetDataset - * Returns the dataset identifier associated with the packet table, on - * success, or H5I_INVALID_HID, on failure. - * Note: it is best to avoid using this identifier in applications, unless - * the desired functionality cannot be performed via the packet table ID. - */ - hid_t PacketTable::GetDataset() - { - return H5PTget_dataset(table_id); - } - - /* FreeBuff - * Frees the buffers created when variable-length packets are read. - * Takes the number of hvl_t structs to be freed and a pointer to their - * location in memory. - * Returns 0 on success, negative on error. - */ - int PacketTable::FreeBuff(size_t numStructs, hvl_t * buffer) - { - return H5PTfree_vlen_buff( table_id, numStructs, buffer); - } - - - /********************************/ - /* Fixed-Length Packet Table */ - /********************************/ - - /* Constructor - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the ID of - * the property list to specify compression, the name of the packet table, - * the ID of the datatype, and the size of a memory chunk used in chunking. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t chunkSize, hid_t plistID) - { - table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); - } - - /* Constructor - deprecated - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the ID of - * the property list to specify compression, the name of the packet table, - * the ID of the datatype, and the size of a memory chunk used in chunking. - * Note: The above constructor has a better prototype, which allows default - * values to be used. This constructor was only released in 1.10.0. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, hid_t plistID, const char* name, hid_t dtypeID, hsize_t chunkSize) - { - table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); - } - - /* Constructor - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the name of - * the packet table, the ID of the datatype of the set, and the size - * of a memory chunk used in chunking. - * Note: this overload will be deprecated in favor of the constructor above. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression) - { - table_id = H5PTcreate_fl(fileID, name, dtypeID, chunkSize, compression); - } - - /* "Open" Constructor - * Opens an existing fixed-length packet table. - * Fails if the packet table specified is variable-length. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name) : PacketTable(fileID, name) {} - - /* "Open" Constructor - will be deprecated because of char* name */ - FL_PacketTable::FL_PacketTable(hid_t fileID, char* name) : PacketTable(fileID, name) {} - - /* AppendPacket - * Adds a single packet to the packet table. Takes a pointer - * to the location of the data in memory. - * Returns 0 on success, negative on failure - */ - int FL_PacketTable::AppendPacket(void * data) - { - return H5PTappend(table_id, 1, data); - } - - /* AppendPackets (multiple packets) - * Adds multiple packets to the packet table. Takes the number of packets - * to be added and a pointer to their location in memory. - * Returns 0 on success, -1 on failure. - */ - int FL_PacketTable::AppendPackets(size_t numPackets, void * data) - { - return H5PTappend(table_id, numPackets, data); - } - - /* GetPacket (indexed) - * Gets a single packet from the packet table. Takes the index - * of the packet (with 0 being the first packet) and a pointer - * to memory where the data should be stored. - * Returns 0 on success, negative on failure - */ - int FL_PacketTable::GetPacket(hsize_t index, void * data) - { - return H5PTread_packets(table_id, index, 1, data); - } - - /* GetPackets (multiple packets) - * Gets multiple packets at once, all packets between - * startIndex and endIndex inclusive. Also takes a pointer to - * the memory where these packets should be stored. - * Returns 0 on success, negative on failure. - */ - int FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void * data) - { - // Make sure the range of indexes is valid - if (startIndex > endIndex) - return -1; - - return H5PTread_packets(table_id, startIndex, (size_t)(endIndex-startIndex+1), data); - } - - /* GetNextPacket (single packet) - * Gets the next packet in the packet table. Takes a pointer to - * memory where the packet should be stored. - * Returns 0 on success, negative on failure. Index - * is not advanced to the next packet on failure. - */ - int FL_PacketTable::GetNextPacket(void * data) - { - return H5PTget_next(table_id, 1, data); - } - - /* GetNextPackets (multiple packets) - * Gets the next numPackets packets in the packet table. Takes a - * pointer to memory where these packets should be stored. - * Returns 0 on success, negative on failure. Index - * is not advanced on failure. - */ - int FL_PacketTable::GetNextPackets(size_t numPackets, void * data) - { - return H5PTget_next(table_id, numPackets, data); - } +/********************************/ +/* PacketTable superclass */ +/********************************/ + +/* "Open" Constructor + * Opens an existing packet table, which can contain either fixed-length or + * variable-length packets. + */ +PacketTable::PacketTable(hid_t fileID, const char *name) { table_id = H5PTopen(fileID, name); } + +/* "Open" Constructor - will be deprecated because of char* name */ +PacketTable::PacketTable(hid_t fileID, char *name) { table_id = H5PTopen(fileID, name); } + +/* Destructor + * Cleans up the packet table + */ +PacketTable::~PacketTable() { H5PTclose(table_id); } + +/* IsValid + * Returns true if this packet table is valid, false otherwise. + * Use this after the constructor to ensure HDF did not have + * any trouble making or opening the packet table. + */ +bool +PacketTable::IsValid() +{ + if (H5PTis_valid(table_id) == 0) + return true; + else + return false; +} + +/* IsVariableLength + * Return 1 if this packet table uses variable-length datatype, + * and 0, otherwise. Returns -1 if the table is invalid (not open). + */ +int +PacketTable::IsVariableLength() +{ + return H5PTis_varlen(table_id); +} + +/* ResetIndex + * Sets the index to point to the first packet in the packet table + */ +void +PacketTable::ResetIndex() +{ + H5PTcreate_index(table_id); +} + +/* SetIndex + * Sets the index to point to the packet specified by index. + * Returns 0 on success, negative on failure (if index is out of bounds) + */ +int +PacketTable::SetIndex(hsize_t index) +{ + return H5PTset_index(table_id, index); +} + +/* SetIndex + * Sets the index to point to the packet specified by index. + * Returns 0 on success, negative on failure (if index is out of bounds) + */ +hsize_t +PacketTable::GetIndex(int &error) +{ + hsize_t index; + + error = H5PTget_index(table_id, &index); + if (error < 0) + return 0; + else + return index; +} + +/* GetPacketCount + * Returns the number of packets in the packet table. Error + * is set to 0 on success. On failure, returns 0 and + * error is set to negative. + */ +hsize_t +PacketTable::GetPacketCount(int &error) +{ + hsize_t npackets; + + error = H5PTget_num_packets(table_id, &npackets); + return npackets; +} + +/* GetTableId + * Returns the identifier of the packet table + */ +hid_t +PacketTable::GetTableId() +{ + return table_id; +} + +/* GetDatatype + * Returns the datatype identifier used by the packet table, on success, + * or H5I_INVALID_HID, on failure. + * Note: it is best to avoid using this identifier in applications, unless + * the desired functionality cannot be performed via the packet table ID. + */ +hid_t +PacketTable::GetDatatype() +{ + return H5PTget_type(table_id); +} + +/* GetDataset + * Returns the dataset identifier associated with the packet table, on + * success, or H5I_INVALID_HID, on failure. + * Note: it is best to avoid using this identifier in applications, unless + * the desired functionality cannot be performed via the packet table ID. + */ +hid_t +PacketTable::GetDataset() +{ + return H5PTget_dataset(table_id); +} + +/* FreeBuff + * Frees the buffers created when variable-length packets are read. + * Takes the number of hvl_t structs to be freed and a pointer to their + * location in memory. + * Returns 0 on success, negative on error. + */ +int +PacketTable::FreeBuff(size_t numStructs, hvl_t *buffer) +{ + return H5PTfree_vlen_buff(table_id, numStructs, buffer); +} + +/********************************/ +/* Fixed-Length Packet Table */ +/********************************/ + +/* Constructor + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the ID of + * the property list to specify compression, the name of the packet table, + * the ID of the datatype, and the size of a memory chunk used in chunking. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, const char *name, hid_t dtypeID, hsize_t chunkSize, + hid_t plistID) +{ + table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); +} + +/* Constructor - deprecated + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the ID of + * the property list to specify compression, the name of the packet table, + * the ID of the datatype, and the size of a memory chunk used in chunking. + * Note: The above constructor has a better prototype, which allows default + * values to be used. This constructor was only released in 1.10.0. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, hid_t plistID, const char *name, hid_t dtypeID, + hsize_t chunkSize) +{ + table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); +} + +/* Constructor + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the name of + * the packet table, the ID of the datatype of the set, and the size + * of a memory chunk used in chunking. + * Note: this overload will be deprecated in favor of the constructor above. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, char *name, hid_t dtypeID, hsize_t chunkSize, int compression) +{ + table_id = H5PTcreate_fl(fileID, name, dtypeID, chunkSize, compression); +} + +/* "Open" Constructor + * Opens an existing fixed-length packet table. + * Fails if the packet table specified is variable-length. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, const char *name) : PacketTable(fileID, name) {} + +/* "Open" Constructor - will be deprecated because of char* name */ +FL_PacketTable::FL_PacketTable(hid_t fileID, char *name) : PacketTable(fileID, name) {} + +/* AppendPacket + * Adds a single packet to the packet table. Takes a pointer + * to the location of the data in memory. + * Returns 0 on success, negative on failure + */ +int +FL_PacketTable::AppendPacket(void *data) +{ + return H5PTappend(table_id, 1, data); +} + +/* AppendPackets (multiple packets) + * Adds multiple packets to the packet table. Takes the number of packets + * to be added and a pointer to their location in memory. + * Returns 0 on success, -1 on failure. + */ +int +FL_PacketTable::AppendPackets(size_t numPackets, void *data) +{ + return H5PTappend(table_id, numPackets, data); +} + +/* GetPacket (indexed) + * Gets a single packet from the packet table. Takes the index + * of the packet (with 0 being the first packet) and a pointer + * to memory where the data should be stored. + * Returns 0 on success, negative on failure + */ +int +FL_PacketTable::GetPacket(hsize_t index, void *data) +{ + return H5PTread_packets(table_id, index, 1, data); +} + +/* GetPackets (multiple packets) + * Gets multiple packets at once, all packets between + * startIndex and endIndex inclusive. Also takes a pointer to + * the memory where these packets should be stored. + * Returns 0 on success, negative on failure. + */ +int +FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void *data) +{ + // Make sure the range of indexes is valid + if (startIndex > endIndex) + return -1; + + return H5PTread_packets(table_id, startIndex, (size_t)(endIndex - startIndex + 1), data); +} + +/* GetNextPacket (single packet) + * Gets the next packet in the packet table. Takes a pointer to + * memory where the packet should be stored. + * Returns 0 on success, negative on failure. Index + * is not advanced to the next packet on failure. + */ +int +FL_PacketTable::GetNextPacket(void *data) +{ + return H5PTget_next(table_id, 1, data); +} + +/* GetNextPackets (multiple packets) + * Gets the next numPackets packets in the packet table. Takes a + * pointer to memory where these packets should be stored. + * Returns 0 on success, negative on failure. Index + * is not advanced on failure. + */ +int +FL_PacketTable::GetNextPackets(size_t numPackets, void *data) +{ + return H5PTget_next(table_id, numPackets, data); +} /* Removed "ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */ diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h index 2665984..400ea52 100644 --- a/hl/c++/src/H5PacketTable.h +++ b/hl/c++/src/H5PacketTable.h @@ -28,22 +28,21 @@ #include "H5PTpublic.h" #include "H5api_adpt.h" -class H5_HLCPPDLL PacketTable -{ -public: +class H5_HLCPPDLL PacketTable { + public: /* Null constructor * Sets table_id to "invalid" */ - PacketTable() {table_id = H5I_BADID;} + PacketTable() { table_id = H5I_BADID; } /* "Open" Constructor * Opens an existing packet table, which can contain either fixed-length or * variable-length packets. */ - PacketTable(hid_t fileID, const char* name); + PacketTable(hid_t fileID, const char *name); /* "Open" Constructor - will be deprecated because of char* name */ - PacketTable(hid_t fileID, char* name); + PacketTable(hid_t fileID, char *name); /* Destructor * Cleans up the packet table @@ -80,16 +79,17 @@ public: * Returns the position of the current packet. * On failure, returns 0 and error is set to negative. */ - hsize_t GetIndex(int& error); + hsize_t GetIndex(int &error); /* GetPacketCount * Returns the number of packets in the packet table. Error * is set to 0 on success. On failure, returns 0 and * error is set to negative. */ - hsize_t GetPacketCount(int& error); + hsize_t GetPacketCount(int &error); - hsize_t GetPacketCount() + hsize_t + GetPacketCount() { int ignoreError; return GetPacketCount(ignoreError); @@ -122,22 +122,22 @@ public: * location in memory. * Returns 0 on success, negative on error. */ - int FreeBuff(size_t numStructs, hvl_t * buffer); + int FreeBuff(size_t numStructs, hvl_t *buffer); -protected: + protected: hid_t table_id; }; -class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable -{ -public: +class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable { + public: /* Constructor * Creates a packet table to store either fixed- or variable-length packets. * Takes the ID of the file the packet table will be created in, the ID of * the property list to specify compression, the name of the packet table, * the ID of the datatype, and the size of a memory chunk used in chunking. */ - FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t chunkSize = 0, hid_t plistID = H5P_DEFAULT); + FL_PacketTable(hid_t fileID, const char *name, hid_t dtypeID, hsize_t chunkSize = 0, + hid_t plistID = H5P_DEFAULT); /* Constructors - deprecated * Creates a packet table in which to store fixed length packets. @@ -148,36 +148,36 @@ public: * Note: these overloaded constructors will be deprecated in favor of the * constructor above. */ - FL_PacketTable(hid_t fileID, hid_t plist_id, const char* name, hid_t dtypeID, hsize_t chunkSize); - FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression = 0); + FL_PacketTable(hid_t fileID, hid_t plist_id, const char *name, hid_t dtypeID, hsize_t chunkSize); + FL_PacketTable(hid_t fileID, char *name, hid_t dtypeID, hsize_t chunkSize, int compression = 0); /* "Open" Constructor * Opens an existing fixed-length packet table. * Fails if the packet table specified is variable-length. */ - FL_PacketTable(hid_t fileID, const char* name); + FL_PacketTable(hid_t fileID, const char *name); /* "Open" Constructor - will be deprecated because of char* name */ - FL_PacketTable(hid_t fileID, char* name); + FL_PacketTable(hid_t fileID, char *name); /* Destructor * Cleans up the packet table */ - virtual ~FL_PacketTable() {}; + virtual ~FL_PacketTable(){}; /* AppendPacket * Adds a single packet to the packet table. Takes a pointer * to the location of the data in memory. * Returns 0 on success, negative on failure */ - int AppendPacket(void * data); + int AppendPacket(void *data); /* AppendPackets (multiple packets) * Adds multiple packets to the packet table. Takes the number of packets * to be added and a pointer to their location in memory. * Returns 0 on success, -1 on failure. */ - int AppendPackets(size_t numPackets, void * data); + int AppendPackets(size_t numPackets, void *data); /* GetPacket (indexed) * Gets a single packet from the packet table. Takes the index @@ -185,7 +185,7 @@ public: * to memory where the data should be stored. * Returns 0 on success, negative on failure */ - int GetPacket(hsize_t index, void * data); + int GetPacket(hsize_t index, void *data); /* GetPackets (multiple packets) * Gets multiple packets at once, all packets between @@ -193,7 +193,7 @@ public: * the memory where these packets should be stored. * Returns 0 on success, negative on failure. */ - int GetPackets(hsize_t startIndex, hsize_t endIndex, void * data); + int GetPackets(hsize_t startIndex, hsize_t endIndex, void *data); /* GetNextPacket (single packet) * Gets the next packet in the packet table. Takes a pointer to @@ -201,7 +201,7 @@ public: * Returns 0 on success, negative on failure. Index * is not advanced to the next packet on failure. */ - int GetNextPacket(void * data); + int GetNextPacket(void *data); /* GetNextPackets (multiple packets) * Gets the next numPackets packets in the packet table. Takes a @@ -209,7 +209,7 @@ public: * Returns 0 on success, negative on failure. Index * is not advanced on failure. */ - int GetNextPackets(size_t numPackets, void * data); + int GetNextPackets(size_t numPackets, void *data); }; /* Removed "#ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */ diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp index 52f3a6b..57a28b8 100644 --- a/hl/c++/test/ptableTest.cpp +++ b/hl/c++/test/ptableTest.cpp @@ -22,41 +22,40 @@ using namespace std; #define TEST_FILE "packettest.h5" /* Main test function */ -int main(void) +int +main(void) { herr_t err; herr_t num_errors = 0; /* Create new HDF5 file */ fileID = H5Fcreate(TEST_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if(fileID <0) - { + if (fileID < 0) { fprintf(stderr, "Couldn't create file.\n"); num_errors = 1; } else { - num_errors += BasicTest(); + num_errors += BasicTest(); - num_errors += TestCompoundDatatype(); + num_errors += TestCompoundDatatype(); - num_errors += TestGetPacket(); + num_errors += TestGetPacket(); - num_errors += TestGetNext(); + num_errors += TestGetNext(); - num_errors += TestCompress(); + num_errors += TestCompress(); - num_errors += TestErrors(); + num_errors += TestErrors(); - num_errors += SystemTest(); + num_errors += SystemTest(); - /* Test data corruption in packed structs */ - num_errors += TestHDFFV_9758(); + /* Test data corruption in packed structs */ + num_errors += TestHDFFV_9758(); /* Terminate access to the file. */ err = H5Fclose(fileID); - if( err < 0 ) - { + if (err < 0) { fprintf(stderr, "Failed to close file.\n"); num_errors++; } @@ -66,38 +65,39 @@ int main(void) } if (num_errors == 0) - /* ALL TESTS PASSED */ - return 0; + /* ALL TESTS PASSED */ + return 0; else - /* ERRORS */ - return -1; + /* ERRORS */ + return -1; } -const char* BASICTEST_PT("/basicTest"); -int BasicTest() +const char *BASICTEST_PT("/basicTest"); +int +BasicTest() { - herr_t err; - int myRecord; + herr_t err; + int myRecord; hsize_t count; - int error; + int error; printf("Testing %-62s", "basic functionality"); HDfflush(stdout); FL_PacketTable wrapper(fileID, H5P_DEFAULT, BASICTEST_PT, H5T_NATIVE_INT, 1); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; /* Ensure initial count is zero */ count = wrapper.GetPacketCount(error); - if(count != 0 || error != 0) - goto error; + if (count != 0 || error != 0) + goto error; myRecord = 1; /* add some records test */ err = wrapper.AppendPacket(&myRecord); - if(err < 0) + if (err < 0) goto error; myRecord = 2; @@ -106,22 +106,22 @@ int BasicTest() /* get number of records test */ count = wrapper.GetPacketCount(); - if(count != 2) - goto error; + if (count != 2) + goto error; /* get records test */ err = wrapper.GetPacket(0, &myRecord); - if(err < 0) - goto error; + if (err < 0) + goto error; - if(myRecord != 1) - goto error; + if (myRecord != 1) + goto error; err = wrapper.GetPacket(1, &myRecord); - if(err < 0) - goto error; - if(myRecord != 2) - goto error; + if (err < 0) + goto error; + if (myRecord != 2) + goto error; PASSED(); return 0; @@ -131,58 +131,58 @@ error: return 1; } -const char* CMPDTEST_PT("/compoundTest"); -int TestCompoundDatatype() +const char *CMPDTEST_PT("/compoundTest"); +int +TestCompoundDatatype() { - hid_t dtypeID; + hid_t dtypeID; hsize_t count; - int error; + int error; printf("Testing %-62s", "compound datatypes"); HDfflush(stdout); /* Create compound datatype */ - typedef struct - { + typedef struct { short a, b, c; - int e; + int e; } compoundType; - dtypeID = H5Tcreate( H5T_COMPOUND, sizeof(compoundType)); + dtypeID = H5Tcreate(H5T_COMPOUND, sizeof(compoundType)); - H5Tinsert(dtypeID, "abbey", HOFFSET( compoundType, a ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID, "bert", HOFFSET( compoundType, b ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID, "charlie", HOFFSET( compoundType, c ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID, "ebert", HOFFSET( compoundType, e ), H5T_NATIVE_INT); + H5Tinsert(dtypeID, "abbey", HOFFSET(compoundType, a), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID, "bert", HOFFSET(compoundType, b), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID, "charlie", HOFFSET(compoundType, c), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID, "ebert", HOFFSET(compoundType, e), H5T_NATIVE_INT); /* Create packet table using default property list. */ FL_PacketTable wrapper(fileID, H5P_DEFAULT, CMPDTEST_PT, dtypeID, 1); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; compoundType first; first.a = 1; first.b = first.c = 3; - first.e = 5; + first.e = 5; /* Write packet */ wrapper.AppendPacket(&first); count = wrapper.GetPacketCount(error); - if(count != 1) - goto error; + if (count != 1) + goto error; first.a = first.b = first.c = 0; - first.e = 0; + first.e = 0; /* Read packet back */ wrapper.GetPacket(0, &first); - if(first.a != 1) - goto error; - if(first.e != 5) - goto error; + if (first.a != 1) + goto error; + if (first.e != 5) + goto error; PASSED(); @@ -191,17 +191,16 @@ int TestCompoundDatatype() error: - H5E_BEGIN_TRY { - H5Tclose(dtypeID); - } H5E_END_TRY; - + H5E_BEGIN_TRY { H5Tclose(dtypeID); } + H5E_END_TRY; H5_FAILED(); return 1; } -const char* GETNEXT_PT("/TestGetNext"); -int TestGetNext() +const char *GETNEXT_PT("/TestGetNext"); +int +TestGetNext() { int error; int record; @@ -214,47 +213,49 @@ int TestGetNext() /* Create a dataset */ FL_PacketTable wrapper(fileID, H5P_DEFAULT, GETNEXT_PT, H5T_NATIVE_INT, 500); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; /* Append 5 records to the dataset */ - for(record = 1; record < 6; record++) + for (record = 1; record < 6; record++) wrapper.AppendPacket(&record); /* Ensure that we can interate through the records and get the right ones */ - for(i = 1; i < 6; i++) - { + for (i = 1; i < 6; i++) { wrapper.GetNextPacket(&record); - if(record != i) - goto error; + if (record != i) + goto error; } /* Reset the index and check that it worked */ wrapper.ResetIndex(); - if(wrapper.GetIndex(error) != 0) goto error; - if(error < 0) goto error; + if (wrapper.GetIndex(error) != 0) + goto error; + if (error < 0) + goto error; /* Ensure that we can interate through the records and get the right ones */ - for(i = 1; i < 6; i++) - { + for (i = 1; i < 6; i++) { error = wrapper.GetNextPacket(&record); - if(record != i || error <0) - goto error; + if (record != i || error < 0) + goto error; } wrapper.SetIndex(1); - if(wrapper.GetIndex(error) != 1) goto error; - if(error < 0) goto error; + if (wrapper.GetIndex(error) != 1) + goto error; + if (error < 0) + goto error; /* Ensure we can get multiple records with our index pointer */ wrapper.GetNextPackets(2, records); - if(records[0] != 2 || records[1] != 3) - goto error; + if (records[0] != 2 || records[1] != 3) + goto error; /* Ensure our pointer was updated correctly */ wrapper.GetNextPacket(&record); - if(record != 4) - goto error; + if (record != 4) + goto error; PASSED(); return 0; @@ -264,28 +265,29 @@ error: return 1; } -const char* COMPRESS_PT("/compressTest"); -int TestCompress() +const char *COMPRESS_PT("/compressTest"); +int +TestCompress() { #ifdef H5_HAVE_FILTER_DEFLATE - unsigned int flags = 0; - unsigned int config = 0; - size_t cd_nelemts = 0; + unsigned int flags = 0; + unsigned int config = 0; + size_t cd_nelemts = 0; printf("Testing %-62s", "compression"); HDfflush(stdout); try { - /* Prepare property list to set compression, randomly use deflate */ - DSetCreatPropList dscreatplist; - dscreatplist.setDeflate(6); + /* Prepare property list to set compression, randomly use deflate */ + DSetCreatPropList dscreatplist; + dscreatplist.setDeflate(6); /* Create packet table with compression. */ FL_PacketTable wrapper(fileID, COMPRESS_PT, H5T_NATIVE_CHAR, 100, dscreatplist.getId()); - /* Close the property list */ - dscreatplist.close(); + /* Close the property list */ + dscreatplist.close(); - /* Verify that the deflate filter is set */ + /* Verify that the deflate filter is set */ /* Create an HDF5 C++ file object */ H5File file; @@ -297,13 +299,14 @@ int TestCompress() DSetCreatPropList dcpl = dset.getCreatePlist(); - char filter_name[8]; + char filter_name[8]; dcpl.getFilterById(H5Z_FILTER_DEFLATE, flags, cd_nelemts, NULL, 8, filter_name, config); - if (HDstrncmp(filter_name, "deflate", 7) != 0) - H5_FAILED() - } catch (Exception e) { - H5_FAILED(); - return 1; + if (HDstrncmp(filter_name, "deflate", 7) != 0) + H5_FAILED() + } + catch (Exception e) { + H5_FAILED(); + return 1; } PASSED(); #else @@ -313,8 +316,9 @@ int TestCompress() return 0; } -const char* PT_TESTGETPT = "/TestGetPacket"; -int TestGetPacket() +const char *PT_TESTGETPT = "/TestGetPacket"; +int +TestGetPacket() { int record; int theRecs[3]; @@ -326,24 +330,23 @@ int TestGetPacket() there is no compression. */ FL_PacketTable wrapper(fileID, PT_TESTGETPT, H5T_NATIVE_INT, 1); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; /* Append 5 records to the dataset */ - for(record = 1; record < 6; record++) + for (record = 1; record < 6; record++) wrapper.AppendPacket(&record); /* Ensure that the records were written properly */ wrapper.GetPacket(1, &record); - if(record != 2) - goto error; + if (record != 2) + goto error; /* Ensure that we can retrieve multiple records */ wrapper.GetPackets(1, 3, theRecs); - for(i = 0; i < 3; i++) - { - if(theRecs[i] != i+2) - goto error; + for (i = 0; i < 3; i++) { + if (theRecs[i] != i + 2) + goto error; } PASSED(); @@ -354,9 +357,10 @@ error: return 1; } -const char* PT_TESTERROR = "/TestErrors"; +const char *PT_TESTERROR = "/TestErrors"; -int TestErrors() +int +TestErrors() { printf("Testing %-62s", "error conditions"); HDfflush(stdout); @@ -364,99 +368,105 @@ int TestErrors() /* Create a dataset */ FL_PacketTable wrapper(fileID, PT_TESTERROR, H5T_NATIVE_INT, 1); - if(! wrapper.IsValid()) - goto error; + if (!wrapper.IsValid()) + goto error; int record; int records[3]; int error; /* Append 4 records to the dataset */ - for(record = 1; record < 5; record++) + for (record = 1; record < 5; record++) wrapper.AppendPacket(&record); /* Try to confuse functions with bad indexes */ error = wrapper.GetPacket(static_cast<unsigned>(-1), &record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPacket(4, &record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPacket(static_cast<unsigned>(-250), &record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPacket(3000, &record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPacket(1, &record); - if(error < 0) - goto error; + if (error < 0) + goto error; error = wrapper.GetPackets(static_cast<unsigned>(-1), 1, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(2, 4, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(static_cast<unsigned>(-60), static_cast<unsigned>(-62), records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(10, 12, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(0, 2, records); - if(error < 0) - goto error; + if (error < 0) + goto error; error = wrapper.GetPackets(2, 0, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetPackets(1, 1, records); - if(error < 0) - goto error; + if (error < 0) + goto error; error = wrapper.GetPackets(1, 3, records); - if(error < 0) - goto error; + if (error < 0) + goto error; wrapper.ResetIndex(); error = wrapper.SetIndex(static_cast<unsigned>(-1)); - if(error >= 0) - goto error; - if(wrapper.GetIndex(error) != 0) goto error; - if(error < 0) goto error; + if (error >= 0) + goto error; + if (wrapper.GetIndex(error) != 0) + goto error; + if (error < 0) + goto error; error = wrapper.GetNextPacket(&record); - if(error < 0) - goto error; - if(record != 1) - goto error; - if(wrapper.GetIndex(error) != 1) goto error; - if(error < 0) goto error; + if (error < 0) + goto error; + if (record != 1) + goto error; + if (wrapper.GetIndex(error) != 1) + goto error; + if (error < 0) + goto error; error = wrapper.SetIndex(20); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetNextPacket(&record); - if(error < 0) - goto error; - if(record != 2) - goto error; + if (error < 0) + goto error; + if (record != 2) + goto error; wrapper.SetIndex(3); error = wrapper.GetNextPacket(&record); - if(error < 0) - goto error; - if(record != 4) - goto error; - if(wrapper.GetIndex(error) != 4) goto error; - if(error < 0) goto error; + if (error < 0) + goto error; + if (record != 4) + goto error; + if (wrapper.GetIndex(error) != 4) + goto error; + if (error < 0) + goto error; error = wrapper.GetNextPacket(&record); - if(error >= 0) - goto error; + if (error >= 0) + goto error; wrapper.ResetIndex(); error = wrapper.GetNextPackets(10, records); - if(error >= 0) - goto error; + if (error >= 0) + goto error; error = wrapper.GetNextPackets(0, records); - if(error < 0) - goto error; + if (error < 0) + goto error; PASSED(); return 0; @@ -466,45 +476,44 @@ error: return 1; } -const char* PT_SYSTEMTST1 = "/SystemTest1"; -const char* PT_SYSTEMTST2 = "/SystemTest2"; -int SystemTest() +const char *PT_SYSTEMTST1 = "/SystemTest1"; +const char *PT_SYSTEMTST2 = "/SystemTest2"; +int +SystemTest() { printf("Testing %-62s", "multiple datatypes"); HDfflush(stdout); - hid_t dtypeID1, dtypeID2; + hid_t dtypeID1, dtypeID2; hsize_t count; - int error; + int error; /* Creating two inter-related datatypes. Create two datasets and put * one datatype in each. */ - typedef struct - { + typedef struct { short a, b, c; - int e; + int e; } compoundType; dtypeID1 = H5Tcreate(H5T_COMPOUND, sizeof(compoundType)); - H5Tinsert(dtypeID1, "abbey", HOFFSET( compoundType, a ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID1, "bert", HOFFSET( compoundType, b ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID1, "charlie", HOFFSET( compoundType, c ), H5T_NATIVE_SHORT); - H5Tinsert(dtypeID1, "ebert", HOFFSET( compoundType, e ), H5T_NATIVE_INT); + H5Tinsert(dtypeID1, "abbey", HOFFSET(compoundType, a), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID1, "bert", HOFFSET(compoundType, b), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID1, "charlie", HOFFSET(compoundType, c), H5T_NATIVE_SHORT); + H5Tinsert(dtypeID1, "ebert", HOFFSET(compoundType, e), H5T_NATIVE_INT); - typedef struct - { - char f; + typedef struct { + char f; compoundType g; } cType2; dtypeID2 = H5Tcreate(H5T_COMPOUND, sizeof(cType2)); - H5Tinsert(dtypeID2, "f", HOFFSET( cType2, f ), H5T_NATIVE_CHAR); - H5Tinsert(dtypeID2, "g", HOFFSET( cType2, g ), dtypeID1); + H5Tinsert(dtypeID2, "f", HOFFSET(cType2, f), H5T_NATIVE_CHAR); + H5Tinsert(dtypeID2, "g", HOFFSET(cType2, g), dtypeID1); cType2 ct2[10]; - ct2[0].f = 'h'; + ct2[0].f = 'h'; ct2[0].g.a = 9; ct2[0].g.b = -13; ct2[0].g.c = 0; @@ -514,17 +523,17 @@ int SystemTest() FL_PacketTable wrapper1(fileID, PT_SYSTEMTST1, dtypeID1, 1); FL_PacketTable wrapper2(fileID, H5P_DEFAULT, PT_SYSTEMTST2, dtypeID2, 1); - if(! wrapper1.IsValid()) - goto error; - if(! wrapper2.IsValid()) - goto error; + if (!wrapper1.IsValid()) + goto error; + if (!wrapper2.IsValid()) + goto error; /* Write and read packets, ensure that nothing is unusual */ wrapper2.AppendPacket(ct2); count = wrapper1.GetPacketCount(); - if(count != 0) - goto error; + if (count != 0) + goto error; compoundType ct1[10]; ct1[0].a = 31; @@ -541,13 +550,17 @@ int SystemTest() wrapper1.ResetIndex(); wrapper1.GetNextPacket(&ct1[1]); wrapper2.GetPacket(1, &ct2[2]); - if(wrapper1.GetIndex(error) != 1) goto error; - if(error < 0) goto error; - if(wrapper2.GetIndex(error) != 0) goto error; - if(error < 0) goto error; + if (wrapper1.GetIndex(error) != 1) + goto error; + if (error < 0) + goto error; + if (wrapper2.GetIndex(error) != 0) + goto error; + if (error < 0) + goto error; - if(ct1[1].b != ct2[2].g.b) - goto error; + if (ct1[1].b != ct2[2].g.b) + goto error; H5Tclose(dtypeID1); H5Tclose(dtypeID2); @@ -556,10 +569,12 @@ int SystemTest() return 0; error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(dtypeID1); H5Tclose(dtypeID2); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return 1; @@ -580,33 +595,32 @@ error: * 2016/10/25 -BMR *------------------------------------------------------------------------- */ -#pragma pack() // default alignment -const char* ABHI_PT("/abhiTest"); -const hsize_t NUM_PACKETS = 5; -const int STRING_LENGTH = 19; // including terminating NULL -int TestHDFFV_9758() +#pragma pack() // default alignment +const char * ABHI_PT("/abhiTest"); +const hsize_t NUM_PACKETS = 5; +const int STRING_LENGTH = 19; // including terminating NULL +int +TestHDFFV_9758() { - hid_t strtype; - hid_t compound_type; + hid_t strtype; + hid_t compound_type; herr_t err; - struct s1_t - { - int a; - float b; + struct s1_t { + int a; + float b; double c; - char d[STRING_LENGTH]; // null terminated string - int e; + char d[STRING_LENGTH]; // null terminated string + int e; }; s1_t s1[NUM_PACKETS]; - for (hsize_t i = 0; i < NUM_PACKETS; i++) - { + for (hsize_t i = 0; i < NUM_PACKETS; i++) { s1[i].a = i; s1[i].b = 1.f * static_cast<float>(i * i); s1[i].c = 1. / (i + 1); HDsprintf(s1[i].d, "string%d", (int)i); - s1[i].e = 100+i; + s1[i].e = 100 + i; } printf("Testing %-62s", "data corruption in packed structs (HDFFV-9758)"); @@ -615,73 +629,70 @@ int TestHDFFV_9758() // Build a compound datatype compound_type = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); if (compound_type < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT); if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); if (err < 0) - goto error; + goto error; - strtype = H5Tcopy (H5T_C_S1); + strtype = H5Tcopy(H5T_C_S1); if (compound_type < 0) - goto error; - err = H5Tset_size (strtype, STRING_LENGTH); /* create string */ + goto error; + err = H5Tset_size(strtype, STRING_LENGTH); /* create string */ if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "d_name", HOFFSET(s1_t, d), strtype); if (err < 0) - goto error; + goto error; err = H5Tinsert(compound_type, "e_name", HOFFSET(s1_t, e), H5T_NATIVE_INT); if (err < 0) - goto error; + goto error; { // so ptable will go out of scope before PASSED - // Create a packet table - FL_PacketTable ptable(fileID, "/examplePacketTable", compound_type, 1); - if (!ptable.IsValid()) - goto error; - - // Add packets to the table - for (size_t i = 0; i < NUM_PACKETS; i++) - { - /* Appends one packet at the current position */ - err = ptable.AppendPacket(s1 + i); - if (err < 0) goto error; - } - - // Check packet count - const hsize_t count = ptable.GetPacketCount(err); - if (err < 0) - goto error; + // Create a packet table + FL_PacketTable ptable(fileID, "/examplePacketTable", compound_type, 1); + if (!ptable.IsValid()) + goto error; + + // Add packets to the table + for (size_t i = 0; i < NUM_PACKETS; i++) { + /* Appends one packet at the current position */ + err = ptable.AppendPacket(s1 + i); + if (err < 0) + goto error; + } - if (count != NUM_PACKETS) - { - std::cerr - << "Number of packets in packet table should be " << NUM_PACKETS - << " but is " << count << endl; - } + // Check packet count + const hsize_t count = ptable.GetPacketCount(err); + if (err < 0) + goto error; - // Read and verify the data - ptable.ResetIndex(); - for (size_t i = 0; i < NUM_PACKETS; i++) - { - s1_t s2; - HDmemset(&s2, 0, sizeof(s1_t)); - err = ptable.GetNextPacket(&s2); - if (err < 0) - goto error; + if (count != NUM_PACKETS) { + std::cerr << "Number of packets in packet table should be " << NUM_PACKETS << " but is " << count + << endl; + } - if (s2.a != s1[i].a || s2.e != s1[i].e) - goto error; - else if (HDstrcmp(s2.d, s1[i].d)) - goto error; - } + // Read and verify the data + ptable.ResetIndex(); + for (size_t i = 0; i < NUM_PACKETS; i++) { + s1_t s2; + HDmemset(&s2, 0, sizeof(s1_t)); + err = ptable.GetNextPacket(&s2); + if (err < 0) + goto error; + + if (s2.a != s1[i].a || s2.e != s1[i].e) + goto error; + else if (HDstrcmp(s2.d, s1[i].d)) + goto error; + } } // end of ptable block PASSED(); @@ -689,13 +700,14 @@ int TestHDFFV_9758() error: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(strtype); H5Tclose(compound_type); H5Fclose(fileID); - } H5E_END_TRY; + } + H5E_END_TRY; H5_FAILED(); return 1; } - |