summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2016-03-08 12:23:54 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2016-03-08 12:23:54 (GMT)
commit116eed3ebd48bd96292af786a09bb67c124bb3e9 (patch)
treed1482a87cc7277c9705e5f53db16607fbe743e2a /c++/test
parent1b7b09b08104f05a65a0269c5c88a342dba8e972 (diff)
downloadhdf5-116eed3ebd48bd96292af786a09bb67c124bb3e9.zip
hdf5-116eed3ebd48bd96292af786a09bb67c124bb3e9.tar.gz
hdf5-116eed3ebd48bd96292af786a09bb67c124bb3e9.tar.bz2
[svn-r29340] Purpose: Code cleanup
Description: - Removed many warnings: warning: use of old-style cast warning: enumeration value ‘H5D_VIRTUAL’ not handled in switch warning: comparison between signed and unsigned There are others of the same warnings and they will be taken care of in the next release. - Made some code reuse between overloads Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test)
Diffstat (limited to 'c++/test')
-rw-r--r--c++/test/dsets.cpp56
-rw-r--r--c++/test/h5cpputil.cpp2
2 files changed, 29 insertions, 29 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index e57e50e..1837d17 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -246,10 +246,10 @@ test_simple_io( H5File& file)
DataSet dataset (file.createDataSet (DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space));
// Write the data to the dataset
- dataset.write ((void*) points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Read the dataset back
- dataset.read ((void*) check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.read (static_cast<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 < 100; i++)
@@ -395,10 +395,10 @@ test_tconv( H5File& file)
DataSet dataset (file.createDataSet (DSET_TCONV_NAME, PredType::STD_I32LE, space));
// Write the data to the dataset
- dataset.write ((void*) out, PredType::STD_I32LE);
+ dataset.write (static_cast<void*>(out), PredType::STD_I32LE);
// Read data with byte order conversion
- dataset.read ((void*) in, PredType::STD_I32BE);
+ dataset.read (static_cast<void*>(in), PredType::STD_I32BE);
// Check
for (int i = 0; i < 1000000; i++) {
@@ -501,7 +501,7 @@ test_compression(H5File& file)
for (i = n = 0; i < 100; i++)
{
for (j = 0; j < 200; j++) {
- points[i][j] = (int)n++;
+ points[i][j] = static_cast<int>(n++);
}
}
char* tconv_buf = new char [1000];
@@ -539,15 +539,15 @@ test_compression(H5File& file)
*/
SUBTEST("Compression (uninitialized read)");
- dataset->read ((void*) check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
if (0!=check[i][j]) {
H5_FAILED();
cerr << " Read a non-zero value." << endl;
- cerr << " At index " << (unsigned long)i << "," <<
- (unsigned long)j << endl;
+ cerr << " At index " << static_cast<unsigned long>(i) << "," <<
+ static_cast<unsigned long>(j) << endl;
throw Exception("test_compression", "Failed in uninitialized read");
}
}
@@ -565,11 +565,11 @@ test_compression(H5File& file)
{
for (j=0; j<size[1]; j++)
{
- points[i][j] = (int)n++;
+ points[i][j] = static_cast<int>(n++);
}
}
- dataset->write ((void*) points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
PASSED();
@@ -580,7 +580,7 @@ test_compression(H5File& file)
SUBTEST("Compression (read)");
// Read the dataset back
- dataset->read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<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++)
@@ -609,10 +609,10 @@ test_compression(H5File& file)
points[i][j] = rand ();
}
}
- dataset->write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
// Read the dataset back and check it
- dataset->read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<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++)
@@ -637,7 +637,7 @@ test_compression(H5File& file)
delete dataset;
dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME));
- dataset->read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<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++)
@@ -667,8 +667,8 @@ test_compression(H5File& file)
}
}
space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset );
- dataset->write ((void*)points, PredType::NATIVE_INT, space1, space1, xfer);
- dataset->read ((void*)check, PredType::NATIVE_INT, space1, space1, xfer);
+ dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, space1, space1, xfer);
+ dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, space1, space1, xfer);
// Check that the values read are the same as the values written
for (i=0; i<hs_size[0]; i++) {
@@ -677,11 +677,11 @@ test_compression(H5File& file)
check[hs_offset[0]+i][hs_offset[1]+j]) {
H5_FAILED();
cerr << " Read different values than written.\n" << endl;
- cerr << " At index " << (unsigned long)(hs_offset[0]+i) <<
- "," << (unsigned long)(hs_offset[1]+j) << endl;
+ cerr << " At index " << static_cast<unsigned long>((hs_offset[0]+i)) <<
+ "," << static_cast<unsigned long>((hs_offset[1]+j)) << endl;
- cerr << " At original: " << (int)points[hs_offset[0]+i][hs_offset[1]+j] << endl;
- cerr << " At returned: " << (int)check[hs_offset[0]+i][hs_offset[1]+j] << endl;
+ cerr << " At original: " << static_cast<int>(points[hs_offset[0]+i][hs_offset[1]+j]) << endl;
+ cerr << " At returned: " << static_cast<int>(check[hs_offset[0]+i][hs_offset[1]+j]) << endl;
throw Exception("test_compression", "Failed in partial I/O");
}
} // for j
@@ -714,8 +714,8 @@ test_compression(H5File& file)
DataSpace space2 (2, size, NULL);
dataset = new DataSet (file.createDataSet (DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist));
- 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 (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset->read (static_cast<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++)
@@ -812,8 +812,8 @@ test_multiopen (H5File& file)
space->getSimpleExtentDims (tmp_size);
if (cur_size[0]!=tmp_size[0])
{
- cerr << " Got " << (int)tmp_size[0] << " instead of "
- << (int)cur_size[0] << "!" << endl;
+ cerr << " Got " << static_cast<int>(tmp_size[0]) << " instead of "
+ << static_cast<int>(cur_size[0]) << "!" << endl;
throw Exception("test_multiopen", "Failed in multi-open with extending");
}
@@ -897,7 +897,7 @@ test_types(H5File& file)
// Fill buffer
for (i=0; i<sizeof buf; i++)
- buf[i] = (unsigned char)0xff ^ (unsigned char)i;
+ buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i);
// Write data from buf using all default dataspaces and property list
dset->write (buf, type);
@@ -926,7 +926,7 @@ test_types(H5File& file)
// Fill buffer
for (i=0; i<sizeof(buf); i++)
- buf[i] = (unsigned char)0xff ^ (unsigned char)i;
+ buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i);
// Write data from buf using all default dataspaces and property
// list; if writing fails, deallocate dset and return.
@@ -959,7 +959,7 @@ test_types(H5File& file)
// Fill buffer
for (i=0; i<sizeof buf; i++)
- buf[i] = (unsigned char)0xff ^ (unsigned char)i;
+ buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i);
// Write data from buf using all default dataspaces and property
// list; if writing fails, deallocate dset and return.
@@ -992,7 +992,7 @@ test_types(H5File& file)
// Fill buffer
for (i=0; i<sizeof(buf); i++)
- buf[i] = (unsigned char)0xff ^ (unsigned char)i;
+ buf[i] = static_cast<unsigned char>(0xff) ^ static_cast<unsigned char>(i);
// Write data from buf using all default dataspaces and property
// list; if writing fails, deallocate dset and return.
diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp
index 40e81cc..9bbb183 100644
--- a/c++/test/h5cpputil.cpp
+++ b/c++/test/h5cpputil.cpp
@@ -195,7 +195,7 @@ void verify_val(const char* x, const char* value, const char* where, int line, c
cerr << "*** UNEXPECTED VALUE from " << where << " should be "
<< value << ", but is " << x << " at line " << line
<< " in " << file_name << endl;
- IncTestNumErrs();
+ //IncTestNumErrs();
throw TestFailedException(where, "");
}
}