summaryrefslogtreecommitdiffstats
path: root/test/set_extend.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2002-02-13 19:28:37 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2002-02-13 19:28:37 (GMT)
commit93ac2c571b77aec3882d65478d5d33febee0d9ed (patch)
tree7b329b99250dbd5959793e157fb5babdb0eef3a3 /test/set_extend.c
parent6e209992eebb1ee91ccc8e1eff31fca67ded227e (diff)
downloadhdf5-93ac2c571b77aec3882d65478d5d33febee0d9ed.zip
hdf5-93ac2c571b77aec3882d65478d5d33febee0d9ed.tar.gz
hdf5-93ac2c571b77aec3882d65478d5d33febee0d9ed.tar.bz2
[svn-r4950]
Purpose: fixed a bug that made a failure on H5Screate_simple, a 1D dimemsion array was declared instead of a 2D array Platforms tested: w2000 octopus linux eirene sun arabica IRIX64 modi4
Diffstat (limited to 'test/set_extend.c')
-rw-r--r--test/set_extend.c67
1 files changed, 60 insertions, 7 deletions
diff --git a/test/set_extend.c b/test/set_extend.c
index 9cb2cb6..29ff9a5 100644
--- a/test/set_extend.c
+++ b/test/set_extend.c
@@ -1,6 +1,8 @@
#include "hdf5.h"
+#include "h5test.h"
+
/*-------------------------------------------------------------------------
*
@@ -25,11 +27,14 @@ int main( void )
hsize_t dims_new[2] = { 2, 2};
hsize_t dims_chunk[2] = { 3, 3};
hsize_t dims_out[2];
- hsize_t maxdims[1] = { H5S_UNLIMITED };
+ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
int data1[3][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
- int buf[2][2];
+ int buf1[3][3];
+ int buf2[2][2];
herr_t status;
int i, j;
+
+ TESTING("extend dataset");
/* Create a new file using default properties. */
file_id = H5Fcreate( "set_extend.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
@@ -48,7 +53,7 @@ int main( void )
status = H5Dwrite( dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data1 );
/*-------------------------------------------------------------------------
- * Set new dimensions for the array
+ * Set new dimensions for the array; shrink it to (2,2)
*-------------------------------------------------------------------------
*/
@@ -74,18 +79,66 @@ int main( void )
*/
/* Read the new dataset. */
- status = H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf );
+ status = H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 );
/* Compare the read array with the original array */
for( i = 0; i < dims_out[0]; i++ )
for( j = 0; j < dims_out[1]; j++ )
{
- if ( buf[i][j] != data1[i][j] ) {
+ if ( buf2[i][j] != data1[i][j] ) {
goto out;
}
}
+#if 0
+
+/*-------------------------------------------------------------------------
+ * Set new dimensions for the array; expand it again to (3,3)
+ *-------------------------------------------------------------------------
+ */
+
+ /* Set new dimensions for the array. */
+ status = H5Dset_extend( dataset_id , dims );
+
+ /* Get the space. */
+ space_id = H5Dget_space( dataset_id );
+
+ /* Get dimensions. */
+ status = H5Sget_simple_extent_dims( space_id, dims_out, NULL);
+
+ for( i = 0; i < 2; i++ )
+ {
+ if ( dims_out[i] != dims[i] )
+ goto out;
+ }
+
+
+/*-------------------------------------------------------------------------
+ * Read
+ *-------------------------------------------------------------------------
+ */
+
+ /* Read the new dataset. */
+ status = H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 );
+
+ /* Compare the read array with the original array */
+ for( i = 0; i < dims_out[0]; i++ )
+ for( j = 0; j < dims_out[1]; j++ )
+ {
+ if ( i > 1 || j > 1 )
+ {
+ if ( buf1[i][j] != 0 )
+ goto out;
+ }
+ else
+ {
+ if ( buf1[i][j] != data1[i][j] )
+ goto out;
+ }
+ }
+
+#endif
/*-------------------------------------------------------------------------
* end
@@ -97,7 +150,7 @@ int main( void )
H5Sclose( space_id );
H5Pclose( plist_id );
H5Fclose( file_id );
- printf("%s \n", "H5Dset_extend test PASSED" );
+ PASSED();
return 0;
@@ -106,7 +159,7 @@ out:
H5Sclose( space_id );
H5Pclose( plist_id );
H5Fclose( file_id );
- printf("%s \n", "H5Dset_extend FAILED" );
+ H5_FAILED();
return 1;
}