diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2012-04-06 02:57:06 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2012-04-06 02:57:06 (GMT) |
commit | d5a62239587f7cc5de301fa5c6b0919807689818 (patch) | |
tree | 40a36d60dd8ac2d10a45886869cc53d3fdc9181e /c++/test | |
parent | ebf3d99b955c705217227fb7f8ae4405e941399a (diff) | |
download | hdf5-d5a62239587f7cc5de301fa5c6b0919807689818.zip hdf5-d5a62239587f7cc5de301fa5c6b0919807689818.tar.gz hdf5-d5a62239587f7cc5de301fa5c6b0919807689818.tar.bz2 |
[svn-r22254] Description:
Bring r22085:22251 from trunk to revise_chunks branch.
Also tackle some testing issues in test/objcopy.c test and clean up
some warnings.
Tested on:
FreeBSD/32 8.2 (loyalty) w/gcc4.6, w/C++ & FORTRAN, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (koala) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (ostrich) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-ia64 2.6 (ember) w/Intel compilers, w/paralle, C++ & FORTRAN,
in production mode
Mac OS X/32 10.7.3 (amazon) in debug mode
Mac OS X/32 10.7.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.7.3 (amazon) w/parallel, in debug mode
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/dsets.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index ee1a206..26abace 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -268,6 +268,77 @@ test_simple_io( H5File& file) } // test_simple_io /*------------------------------------------------------------------------- + * Function: test_datasize + * + * Purpose: Tests DataSet::getInMemDataSize(). + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Binh-Minh Ribler + * Thursday, March 22, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_datasize() +{ + + SUBTEST("DataSet::getInMemDataSize()"); + + int points[100][200]; + int check[100][200]; + int i, j, n; + + try + { + // Open FILE1. + H5File file(FILE1, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, FileAccPropList::DEFAULT); + + // Open dataset DSET_SIMPLE_IO_NAME. + DataSet dset = file.openDataSet (DSET_SIMPLE_IO_NAME); + + // Get the dataset's dataspace to calculate the size for verification. + DataSpace space(dset.getSpace()); + + // Get the dimension sizes. + hsize_t dims[2]; + int n_dims = space.getSimpleExtentDims(dims); + + // Calculate the supposed size. Size of each value is int (4), from + // test_simple_io. + int expected_size = 4 * dims[0] * dims[1]; + + // getInMemDataSize() returns the in memory size of the data. + size_t ds_size = dset.getInMemDataSize(); + + // Verify the data size. + if (ds_size != expected_size) + { + H5_FAILED(); + cerr << " Expected data size = " << expected_size; + cerr << " but dset.getInMemDataSize() returned " << ds_size << endl; + throw Exception("test_compression", "Failed in testing DataSet::getInMemDataSize()"); + } + + PASSED(); + return 0; + } // end try + + // catch all dataset, space, plist exceptions + catch (Exception E) + { + cerr << " FAILED" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + + return -1; + } +} // test_datasize + +/*------------------------------------------------------------------------- * Function: test_tconv * * Purpose: Test some simple data type conversion stuff. @@ -1004,6 +1075,10 @@ void test_dset() nerrors += test_compression(file)<0 ?1:0; nerrors += test_multiopen (file)<0 ?1:0; nerrors += test_types(file)<0 ?1:0; + + // Close the file before testing data size. + file.close(); + nerrors += test_datasize() <0 ? 1:0; } catch (Exception E) { |