summaryrefslogtreecommitdiffstats
path: root/c++/test/tfilter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++/test/tfilter.cpp')
-rw-r--r--c++/test/tfilter.cpp102
1 files changed, 46 insertions, 56 deletions
diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp
index 5a493ac..e7788e5 100644
--- a/c++/test/tfilter.cpp
+++ b/c++/test/tfilter.cpp
@@ -25,14 +25,14 @@ 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
-#define DSET_DIM1 100
-#define DSET_DIM2 200
+#define DSET_DIM1 100
+#define DSET_DIM2 200
#define FILTER_CHUNK_DIM1 2
#define FILTER_CHUNK_DIM2 25
@@ -56,16 +56,15 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts,
static size_t filter_bogus(size_t nbytes);
/* This message derives from H5Z */
const H5Z_class2_t H5Z_BOGUS[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version */
- H5Z_FILTER_BOGUS, /* Filter id number */
- 1, 1, /* Encoding and decoding enabled */
- "bogus", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- (H5Z_func_t)filter_bogus, /* The actual filter function */
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_BOGUS, /* Filter id number */
+ 1, 1, /* Encoding and decoding enabled */
+ "bogus", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ (H5Z_func_t)filter_bogus, /* The actual filter function */
}};
-
/*-------------------------------------------------------------------------
* Function: filter_bogus
*
@@ -90,7 +89,6 @@ filter_bogus(size_t nbytes)
return nbytes;
}
-
/*-------------------------------------------------------------------------
* Function: test_null_filter
*
@@ -107,25 +105,26 @@ filter_bogus(size_t nbytes)
*/
const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2};
-static void test_null_filter()
+static void
+test_null_filter()
{
// Output message about test being performed
SUBTEST("'Null' filter");
try {
- //hsize_t null_size; // Size of dataset with null filter
+ // hsize_t null_size; // Size of dataset with null filter
// Prepare dataset create property list
DSetCreatPropList dsplist;
dsplist.setChunk(2, chunk_size);
- if (H5Zregister (H5Z_BOGUS)<0)
+ if (H5Zregister(H5Z_BOGUS) < 0)
throw Exception("test_null_filter", "H5Zregister failed");
// Set some pretent filter
dsplist.setFilter(H5Z_FILTER_BOGUS);
// this function is just a stub right now; will work on it later - BMR
- //if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0)
+ // if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0)
// throw Exception("test_null_filter", "test_filter_internal failed");
// Close objects.
@@ -134,13 +133,11 @@ static void test_null_filter()
} // end of try
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_null_filter()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_null_filter
+} // test_null_filter
-
/*-------------------------------------------------------------------------
* Function: test_szip_filter
*
@@ -157,28 +154,29 @@ static void test_null_filter()
*/
const H5std_string DSET_SZIP_NAME("szipped dataset");
-static void test_szip_filter(H5File& file1)
+static void
+test_szip_filter(H5File &file1)
{
#ifdef H5_HAVE_FILTER_SZIP
int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2];
- unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK;
- unsigned szip_pixels_per_block=4;
+ unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK;
+ unsigned szip_pixels_per_block = 4;
// Output message about test being performed
SUBTEST("szip filter (with encoder)");
- if ( h5_szip_can_encode() == 1) {
- char* tconv_buf = new char [1000];
+ if (h5_szip_can_encode() == 1) {
+ char *tconv_buf = new char[1000];
try {
- const hsize_t size[2] = {DSET_DIM1, DSET_DIM2};
+ const hsize_t size[2] = {DSET_DIM1, DSET_DIM2};
// Create the data space
DataSpace space1(2, size, NULL);
// Create a small conversion buffer to test strip mining (?)
DSetMemXferPropList xfer;
- xfer.setBuffer (1000, tconv_buf, NULL);
+ xfer.setBuffer(1000, tconv_buf, NULL);
// Prepare dataset create property list
DSetCreatPropList dsplist;
@@ -188,27 +186,24 @@ static void test_szip_filter(H5File& file1)
dsplist.setSzip(szip_options_mask, szip_pixels_per_block);
// Create a dataset with szip compression
- DataSpace space2 (2, size, NULL);
- DataSet dataset(file1.createDataSet (DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist));
+ DataSpace space2(2, size, NULL);
+ DataSet dataset(file1.createDataSet(DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist));
hsize_t i, j, n;
- for (i=n=0; i<size[0]; i++)
- {
- for (j=0; j<size[1]; j++)
- {
+ for (i = n = 0; i < size[0]; i++) {
+ for (j = 0; j < size[1]; j++) {
points[i][j] = (int)n++;
}
}
// Write to the dataset then read back the values
- dataset.write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
- dataset.read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.write((void *)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.read((void *)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Check that the values read are the same as the values written
for (i = 0; i < size[0]; i++)
- for (j = 0; j < size[1]; j++)
- {
- int status = check_values (i, j, points[i][j], check[i][j]);
+ for (j = 0; j < size[1]; j++) {
+ int status = check_values(i, j, points[i][j], check[i][j]);
if (status == -1)
throw Exception("test_szip_filter", "Failed in testing szip method");
}
@@ -217,8 +212,7 @@ static void test_szip_filter(H5File& file1)
} // end of try
// catch all other exceptions
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg());
}
@@ -228,15 +222,14 @@ static void test_szip_filter(H5File& file1)
SKIPPED();
}
-#else /* H5_HAVE_FILTER_SZIP */
+#else /* H5_HAVE_FILTER_SZIP */
SUBTEST("szip filter");
SKIPPED();
H5std_string fname = file1.getFileName();
cerr << " Szip filter not enabled for file '" << fname << "'" << endl;
#endif /* H5_HAVE_FILTER_SZIP */
-} // test_szip_filter
+} // test_szip_filter
-
/*-------------------------------------------------------------------------
* Function: test_filters
*
@@ -245,18 +238,17 @@ static void test_szip_filter(H5File& file1)
* Return None
*-------------------------------------------------------------------------
*/
-const H5std_string FILE1("tfilters.h5");
-extern "C"
-void test_filters()
+const H5std_string FILE1("tfilters.h5");
+extern "C" void
+test_filters()
{
// Output message about test being performed
MESSAGE(5, ("Testing Various Filters\n"));
- hid_t fapl_id;
+ hid_t fapl_id;
fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template
- try
- {
+ try {
// Use the file access template id to create a file access prop. list
FileAccPropList fapl(fapl_id);
@@ -266,13 +258,11 @@ void test_filters()
test_null_filter();
test_szip_filter(file1);
}
- catch (Exception& E)
- {
+ catch (Exception &E) {
issue_fail_msg("test_filters()", __LINE__, __FILE__, E.getCDetailMsg());
}
-} // test_filters()
+} // test_filters()
-
/*-------------------------------------------------------------------------
* Function: cleanup_filters
*
@@ -281,8 +271,8 @@ void test_filters()
* Return none
*-------------------------------------------------------------------------
*/
-extern "C"
-void cleanup_filters()
+extern "C" void
+cleanup_filters()
{
HDremove(FILE1.c_str());
}