summaryrefslogtreecommitdiffstats
path: root/hl/c++/test/ptableTest.cpp
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2006-09-26 18:25:03 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2006-09-26 18:25:03 (GMT)
commit6aeb73dd44ed126dcb3f77b9ff4ff95c2403ea62 (patch)
tree2a600b3c00b8f554d0a09f4e29e5e0f831a8b356 /hl/c++/test/ptableTest.cpp
parentfdbdaf656bc91c4802dd4c58ceb622bb51f390a9 (diff)
downloadhdf5-6aeb73dd44ed126dcb3f77b9ff4ff95c2403ea62.zip
hdf5-6aeb73dd44ed126dcb3f77b9ff4ff95c2403ea62.tar.gz
hdf5-6aeb73dd44ed126dcb3f77b9ff4ff95c2403ea62.tar.bz2
[svn-r12686] Added compression to Packet Tables. Now both C and C++ packet tables
have an extra parameter that sets the deflate filter. Added tests, made examples use the new APIs. Cleaned up include files a little and removed some casts that I hope are superfluous. If anybody encounters strange errors in the packet table tests where the chunk size is set to some extremely large value, please let me know, but I was unable to reproduce this error on any system. Tested on mir, heping, sol, juniper, VS 6.0. Looked for the chunk size error on several other systems a month or two ago.
Diffstat (limited to 'hl/c++/test/ptableTest.cpp')
-rw-r--r--hl/c++/test/ptableTest.cpp60
1 files changed, 48 insertions, 12 deletions
diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp
index 3b97d3e..d25c2ba 100644
--- a/hl/c++/test/ptableTest.cpp
+++ b/hl/c++/test/ptableTest.cpp
@@ -16,6 +16,8 @@
#include "ptableTest.h"
+using namespace H5;
+
#define TEST_FILE "packettest.h5"
/* Main test function */
@@ -41,6 +43,8 @@ int main(void)
num_errors += TestGetNext();
+ num_errors += TestCompress();
+
num_errors += TestErrors();
num_errors += SystemTest();
@@ -146,8 +150,8 @@ int TestCompoundDatatype()
H5Tinsert(dtypeID, "charlie", HOFFSET( compoundType, c ), H5T_NATIVE_SHORT);
H5Tinsert(dtypeID, "ebert", HOFFSET( compoundType, e ), H5T_NATIVE_INT);
- /* Create packet table */
- FL_PacketTable wrapper(fileID, "/compoundTest", dtypeID, 1);
+ /* Create packet table. Explicitly specify no compression */
+ FL_PacketTable wrapper(fileID, "/compoundTest", dtypeID, 1, -1);
if(! wrapper.IsValid())
goto out;
@@ -193,7 +197,7 @@ int TestGetNext()
TESTING("GetNextPacket")
/* Create a dataset */
- FL_PacketTable wrapper(fileID, "/TestGetNext", H5T_NATIVE_INT, 1);
+ FL_PacketTable wrapper(fileID, "/TestGetNext", H5T_NATIVE_INT, 500);
if(! wrapper.IsValid())
goto out;
@@ -245,6 +249,38 @@ out:
return 1;
}
+int TestCompress()
+{
+ unsigned int flags = 0;
+ unsigned int config = 0;
+ size_t cd_nelemts = 0;
+
+ TESTING("compression")
+
+ try {
+ /* Create packet table with compression. */
+ FL_PacketTable wrapper(fileID, "/compressTest", H5T_NATIVE_CHAR, 100, 8);
+
+ /* Create an HDF5 C++ file object */
+ H5File file;
+ file.setId(fileID);
+
+ /* Make sure that the deflate filter is set by opening the packet table
+ * as a dataset and getting its creation property list */
+ DataSet dsetID = file.openDataSet("/compressTest");
+
+ DSetCreatPropList dcplID = dsetID.getCreatePlist();
+
+ dcplID.getFilterById(H5Z_FILTER_DEFLATE, flags, cd_nelemts, NULL, 0, NULL, config);
+ } catch (Exception e) {
+ H5_FAILED();
+ return 1;
+ }
+
+ PASSED();
+ return 0;
+}
+
int TestGetPacket()
{
int record;
@@ -252,8 +288,8 @@ int TestGetPacket()
int i;
TESTING("GetPacket")
- /* Create a dataset */
- FL_PacketTable wrapper(fileID, "/TestGetPacket", H5T_NATIVE_INT, 1);
+ /* Create a dataset. Explicitly specify no compression */
+ FL_PacketTable wrapper(fileID, "/TestGetPacket", H5T_NATIVE_INT, 1, -1);
if(! wrapper.IsValid())
goto out;
@@ -302,13 +338,13 @@ int TestErrors()
wrapper.AppendPacket(&record);
/* Try to confuse functions with bad indexes */
- error = wrapper.GetPacket(-1, &record);
+ error = wrapper.GetPacket( (unsigned) -1, &record);
if(error >= 0)
goto out;
error = wrapper.GetPacket(4, &record);
if(error >= 0)
goto out;
- error = wrapper.GetPacket(-250, &record);
+ error = wrapper.GetPacket((unsigned) -250, &record);
if(error >= 0)
goto out;
error = wrapper.GetPacket(3000, &record);
@@ -318,13 +354,13 @@ int TestErrors()
if(error < 0)
goto out;
- error = wrapper.GetPackets(-1, 1, records);
+ error = wrapper.GetPackets((unsigned) -1, 1, records);
if(error >= 0)
goto out;
error = wrapper.GetPackets(2, 4, records);
if(error >= 0)
goto out;
- error = wrapper.GetPackets(-60, -62, records);
+ error = wrapper.GetPackets((unsigned) -60, (unsigned) -62, records);
if(error >= 0)
goto out;
error = wrapper.GetPackets(10, 12, records);
@@ -344,7 +380,7 @@ int TestErrors()
goto out;
wrapper.ResetIndex();
- error = wrapper.SetIndex(-1);
+ error = wrapper.SetIndex((unsigned) -1);
if(error >= 0)
goto out;
if(wrapper.GetIndex(error) != 0) goto out;
@@ -433,9 +469,9 @@ int SystemTest()
ct2[0].g.c = 0;
ct2[0].g.e = 3000;
- /* Create the packet table datasets */
+ /* Create the packet table datasets. Make one of them compressed. */
FL_PacketTable wrapper1(fileID, "/SystemTest1", dtypeID1, 1);
- FL_PacketTable wrapper2(fileID, "/SystemTest2", dtypeID2, 1);
+ FL_PacketTable wrapper2(fileID, "/SystemTest2", dtypeID2, 1, 5);
if(! wrapper1.IsValid())
goto out;