diff options
Diffstat (limited to 'c++/test/dsets.cpp')
-rw-r--r-- | c++/test/dsets.cpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index a16061b..53b56fc 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -23,6 +23,8 @@ ***************************************************************************/ +#include <cfloat> +#include <cmath> #include <iostream> using std::cerr; using std::endl; @@ -189,9 +191,9 @@ test_simple_io(H5File &file) SUBTEST("Simple I/O"); - int points[100][200]; - int check[100][200]; - int i, j, n; + auto points = new int[100][200]; + auto check = new int[100][200](); + int i, j, n; // Initialize the dataset for (i = n = 0; i < 100; i++) { @@ -233,6 +235,8 @@ test_simple_io(H5File &file) // clean up and return with success delete[] tconv_buf; + delete[] points; + delete[] check; PASSED(); return 0; } // end try @@ -244,6 +248,8 @@ test_simple_io(H5File &file) // clean up and return with failure delete[] tconv_buf; + delete[] points; + delete[] check; return -1; } } // test_simple_io @@ -408,6 +414,13 @@ filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[ size_t *buf_size, void **buf) // H5_ATTR_UNUSED variables caused warning, but taking them out caused failure. { + // Unused + (void)flags; + (void)cd_nelmts; + (void)cd_values; + (void)buf_size; + (void)buf; + return nbytes; } @@ -431,8 +444,8 @@ test_compression(H5File &file) const char *not_supported; not_supported = " Deflate compression is not enabled."; #endif /* H5_HAVE_FILTER_DEFLATE */ - int points[100][200]; - int check[100][200]; + auto points = new int[100][200]; + auto check = new int[100][200]; hsize_t i, j, n; // Initialize the dataset @@ -667,6 +680,8 @@ test_compression(H5File &file) */ delete dataset; delete[] tconv_buf; + delete[] points; + delete[] check; return 0; } // end try @@ -678,6 +693,8 @@ test_compression(H5File &file) // clean up and return with failure delete dataset; delete[] tconv_buf; + delete[] points; + delete[] check; return -1; } } // test_compression @@ -713,6 +730,9 @@ test_nbit_compression(H5File &file) SUBTEST("N-bit compression (setup)"); + HDmemset(orig_data, 0, DIM1 * DIM2 * sizeof(s1_t)); + HDmemset(new_data, 0, DIM1 * DIM2 * sizeof(s1_t)); + try { // Define datatypes of members of compound datatype IntType i_type(PredType::NATIVE_INT); @@ -1079,7 +1099,7 @@ test_getnativeinfo(H5File &file) H5O_native_info_t ninfo; HDmemset(&ninfo, 0, sizeof(ninfo)); dataset.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR); - verify_val(ninfo.hdr.nchunks, 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__); + verify_val(static_cast<long>(ninfo.hdr.nchunks), 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__); dataset.close(); // Open the dataset we created above and then close it. This is one @@ -1087,7 +1107,7 @@ test_getnativeinfo(H5File &file) dataset = file.openDataSet(DSET_DEFAULT_NAME); HDmemset(&ninfo, 0, sizeof(ninfo)); dataset.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_ALL); - verify_val(ninfo.hdr.nchunks, 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__); + verify_val(static_cast<long>(ninfo.hdr.nchunks), 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__); dataset.close(); PASSED(); @@ -1139,12 +1159,15 @@ test_chunk_cache(const FileAccPropList &fapl) dapl.getChunkCache(nslots_4, nbytes_4, w0_4); verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); - verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__); + if (abs(w0_1 - w0_4) > DBL_EPSILON) + TestErrPrintf("%d: w0_1 and w0_4 different: w0_1=%f, " + "w0_4=%f\n", + __LINE__, w0_1, w0_4); // Set a link access property on dapl to verify property list inheritance - dapl.setNumLinks((size_t)134); + dapl.setNumLinks(134); size_t nlinks = dapl.getNumLinks(); - verify_val(nlinks, (size_t)134, "DSetAccPropList::getNumLinks", __LINE__, __FILE__); + verify_val(static_cast<long>(nlinks), 134, "DSetAccPropList::getNumLinks", __LINE__, __FILE__); // Make a copy of the external fapl FileAccPropList fapl_local(fapl); @@ -1255,7 +1278,8 @@ test_virtual() // Get the current layout, should be default, H5D_CONTIGUOUS H5D_layout_t layout = dcpl.getLayout(); - verify_val(layout, H5D_CONTIGUOUS, "DSetCreatPropList::getLayout", __LINE__, __FILE__); + verify_val(static_cast<long>(layout), static_cast<long>(H5D_CONTIGUOUS), + "DSetCreatPropList::getLayout", __LINE__, __FILE__); // Create fixed mapping hsize_t dims[RANK]; @@ -1277,7 +1301,8 @@ test_virtual() // Get and verify the new layout layout = dcpl.getLayout(); - verify_val(layout, H5D_VIRTUAL, "DSetCreatPropList::getLayout", __LINE__, __FILE__); + verify_val(static_cast<long>(layout), static_cast<long>(H5D_VIRTUAL), "DSetCreatPropList::getLayout", + __LINE__, __FILE__); PASSED(); return 0; |