summaryrefslogtreecommitdiffstats
path: root/test/fillval.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-10-08 17:13:14 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-10-08 17:13:14 (GMT)
commit19ec99786adba12a7517f633888c3976738135ce (patch)
tree8d40536cf23cbded60afb3133c1cefd1aebeb3ed /test/fillval.c
parent1fddd40b8b45e8ced68d2192e10baf000deb0857 (diff)
downloadhdf5-19ec99786adba12a7517f633888c3976738135ce.zip
hdf5-19ec99786adba12a7517f633888c3976738135ce.tar.gz
hdf5-19ec99786adba12a7517f633888c3976738135ce.tar.bz2
[svn-r745] Changes since 19981002
---------------------- ./doc/html/H5.format.html ./src/H5HG.c Fixed a bug in the global heap that caused H5HG_read() to write past the end of the buffer in certain cases. ./test/big.c The test is skipped if hdf5 was configured with `--disable-hsizet'. ./src/H5Ofill.c Data type conversions are implemented for the fill value. ./src/H5.c Tracing prints one of H5P_FILE_CREATE, H5P_FILE_ACCESS, H5P_DATASET_CREATE, H5P_DATASET_XFER, or H5P_MOUNT instead of the more cryptic H5I_TEMPLATE_* constants. ./src/H5D.c Removed prototype for H5D_find_name(). ./src/H5I.c The GROUP_MASK and ID_MASK are both calculated from GROUP_BITS instead of being set by hand. We don't use the sign bit of hid_t; all valid hid_t values are positive so we can say things like `if ((file=H5Fopen(...))<0)'. Changed `(int)pow(2.0,x)' to `1<<x' so we don't have to worry about rounding. Fixed H5I_get_type() so it doesn't always fail an assertion. ./src/H5E.c ./src/H5Epublic.h Added minor error H5E_MOUNT ./src/H5F.c ./src/H5Fprivate.h Added H5Fmount() and H5Funmount(). Mounting and unmounting works as documented but some of the other things aren't implemented yet, the biggest being current working groups always acting on the root of the mount tree, and H5Fclose() closing the entire tree. The rest of the stuff will be added shortly... ./src/H5P.c ./src/H5Ppublic.h Added the H5P_MOUNT property list but haven't implemented any particular properties for it yet. ./src/H5Gstab.c Hard links across files return an error instead of failing an assertion.
Diffstat (limited to 'test/fillval.c')
-rw-r--r--test/fillval.c90
1 files changed, 76 insertions, 14 deletions
diff --git a/test/fillval.c b/test/fillval.c
index 3880e23..061e9a8 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -228,10 +228,11 @@ test_getset(void)
static int
test_create(const char *filename, H5D_layout_t layout)
{
- hid_t file, space, dcpl, dset;
+ hid_t file, space, dcpl, dset1, dset2, dset3;
hsize_t cur_size[5] = {32, 16, 8, 4, 2};
hsize_t ch_size[5] = {1, 1, 1, 4, 2};
- int fillval = 0x4c70f1cd, fillval_rd=0;
+ short rd_s, fill_s = 0x1234;
+ long rd_l, fill_l = 0x4321;
char test[256];
if (H5D_CHUNKED==layout) {
@@ -242,7 +243,11 @@ test_create(const char *filename, H5D_layout_t layout)
printf("%-70s", test);
fflush(stdout);
- /* Create a file and dataset */
+ /*
+ * Create a file and three datasets. The three datasets test three fill
+ * conversion paths: small to large, large to small, and no conversion.
+ * They depend on `short' being smaller than `long'.
+ */
if ((file=H5Fcreate(filename, H5F_ACC_TRUNC,
H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
if ((space=H5Screate_simple(5, cur_size, cur_size))<0) goto error;
@@ -250,33 +255,88 @@ test_create(const char *filename, H5D_layout_t layout)
if (H5D_CHUNKED==layout) {
if (H5Pset_chunk(dcpl, 5, ch_size)<0) goto error;
}
+
+ /* Small to large fill conversion */
#ifndef NO_FILLING
- if (H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval)<0) goto error;
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_SHORT, &fill_s)<0) goto error;
#endif
- if ((dset=H5Dcreate(file, "dset", H5T_NATIVE_INT, space, dcpl))<0)
+ if ((dset1=H5Dcreate(file, "dset1", H5T_NATIVE_LONG, space, dcpl))<0)
goto error;
- if (H5Dclose(dset)<0) goto error;
+
+ /* Large to small fill conversion */
+#ifndef NO_FILLING
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l)<0) goto error;
+#endif
+ if ((dset2=H5Dcreate(file, "dset2", H5T_NATIVE_SHORT, space, dcpl))<0)
+ goto error;
+
+ /* No conversion */
+#ifndef NO_FILLING
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_LONG, &fill_l)<0) goto error;
+#endif
+ if ((dset3=H5Dcreate(file, "dset3", H5T_NATIVE_LONG, space, dcpl))<0)
+ goto error;
+
+ /* Close everything */
+ if (H5Dclose(dset1)<0) goto error;
+ if (H5Dclose(dset2)<0) goto error;
+ if (H5Dclose(dset3)<0) goto error;
if (H5Sclose(space)<0) goto error;
if (H5Pclose(dcpl)<0) goto error;
if (H5Fclose(file)<0) goto error;
- /* Open the file and get the dataset fill value */
+ /* Open the file and get the dataset fill value from each dataset */
if ((file=H5Fopen(FILE_NAME_1, H5F_ACC_RDONLY, H5P_DEFAULT))<0)
goto error;
- if ((dset=H5Dopen(file, "dset"))<0) goto error;
- if ((dcpl=H5Dget_create_plist(dset))<0) goto error;
+
+ /* Large to small conversion */
+ if ((dset1=H5Dopen(file, "dset1"))<0) goto error;
+ if ((dcpl=H5Dget_create_plist(dset1))<0) goto error;
+ if (H5Dclose(dset1)<0) goto error;
#ifndef NO_FILLING
- if (H5Pget_fill_value(dcpl, H5T_NATIVE_INT, &fillval_rd)<0) goto error;
- if (fillval_rd!=fillval) {
+ if (H5Pget_fill_value(dcpl, H5T_NATIVE_SHORT, &rd_s)<0) goto error;
+ if (rd_s!=fill_s) {
puts("*FAILED*");
puts(" Got a different fill value than what was set.");
+ printf(" Got %d, set %d\n", rd_s, fill_s);
goto error;
}
#endif
if (H5Pclose(dcpl)<0) goto error;
- if (H5Dclose(dset)<0) goto error;
- if (H5Fclose(file)<0) goto error;
+ /* Small to large conversion */
+ if ((dset2=H5Dopen(file, "dset2"))<0) goto error;
+ if ((dcpl=H5Dget_create_plist(dset2))<0) goto error;
+ if (H5Dclose(dset2)<0) goto error;
+#ifndef NO_FILLING
+ if (H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l)<0) goto error;
+ if (rd_l!=fill_l) {
+ puts("*FAILED*");
+ puts(" Got a different fill value than what was set.");
+ printf(" Got %ld, set %ld\n", rd_l, fill_l);
+ goto error;
+ }
+#endif
+ if (H5Pclose(dcpl)<0) goto error;
+
+ /* No conversion */
+ if ((dset3=H5Dopen(file, "dset3"))<0) goto error;
+ if ((dcpl=H5Dget_create_plist(dset3))<0) goto error;
+ if (H5Dclose(dset3)<0) goto error;
+#ifndef NO_FILLING
+ if (H5Pget_fill_value(dcpl, H5T_NATIVE_LONG, &rd_l)<0) goto error;
+ if (rd_l!=fill_l) {
+ puts("*FAILED*");
+ puts(" Got a different fill value than what was set.");
+ printf(" Got %ld, set %ld\n", rd_l, fill_l);
+ goto error;
+ }
+#endif
+ if (H5Pclose(dcpl)<0) goto error;
+
+
+
+ if (H5Fclose(file)<0) goto error;
puts(" PASSED");
return 0;
@@ -284,7 +344,9 @@ test_create(const char *filename, H5D_layout_t layout)
H5E_BEGIN_TRY {
H5Pclose(dcpl);
H5Sclose(space);
- H5Dclose(dset);
+ H5Dclose(dset1);
+ H5Dclose(dset2);
+ H5Dclose(dset3);
H5Fclose(file);
} H5E_END_TRY;
return 1;