diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-01-14 19:42:59 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-01-14 19:42:59 (GMT) |
commit | d70c7d7a64b821f9d3532cc01c7a7fa934f2a17d (patch) | |
tree | 5b7750fffd98153d874bb28daad40c49ac977eeb /test/dsets.c | |
parent | 1063eb8a1ea0cbdbdc4244f0627b94b3096d65ab (diff) | |
download | hdf5-d70c7d7a64b821f9d3532cc01c7a7fa934f2a17d.zip hdf5-d70c7d7a64b821f9d3532cc01c7a7fa934f2a17d.tar.gz hdf5-d70c7d7a64b821f9d3532cc01c7a7fa934f2a17d.tar.bz2 |
[svn-r153] Changes since 19980108
----------------------
./MANIFEST
./src/H5Dconv.c [REMOVED]
./src/H5Tconv.c [NEW]
./src/Makefile.in
Changed H5Dconv.c to H5Tconv.c
./html/Datatypes.html
Updated data type conversion section.
./html/H5.apiv2.html
Removed sections about datasets and data types since they're
covered in their own chapters.
./src/H5D.c
Supports data type conversion.
./src/H5Odtype.c
./src/H5Tpkg.h
Changed `lo_pad' and `hi_pad' to `lsb_pad' and `msb_pad'.
./src/H5T.c
./src/H5Tpkg.h
./src/H5Tprivate.h
./src/H5Tpublic.h
./src/H5detect.c
Added predefined data types. Added query/set more
properties. Added type conversion infrastructure.
./test/dsets.c
Tests data type conversion during read.
Diffstat (limited to 'test/dsets.c')
-rw-r--r-- | test/dsets.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/test/dsets.c b/test/dsets.c index c5ad49c..45aff80 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -22,6 +22,7 @@ #define DSET_DEFAULT_NAME "default" #define DSET_CHUNKED_NAME "chunked" #define DSET_SIMPLE_IO_NAME "simple_io" +#define DSET_TCONV_NAME "tconv" /*------------------------------------------------------------------------- @@ -277,6 +278,89 @@ test_simple_io (hid_t file) /*------------------------------------------------------------------------- + * Function: test_tconv + * + * Purpose: Test some simple data type conversion stuff. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 14, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_tconv (hid_t file) +{ + uint8 out[4*1000000]; + uint8 in[4*1000000]; + intn i; + size_t dims[1]; + hid_t space, dataset, type; + herr_t status; + + printf ("%-70s", "Testing data type conversion"); + + /* Initialize the dataset */ + for (i=0; i<1000000; i++) ((int32*)out)[i] = 0x11223344; + + /* Create the data space */ + space = H5Pcreate (H5P_SIMPLE); + assert (space>=0); + dims[0] = 1000000; + status = H5Pset_space (space, 1, dims); + assert (status>=0); + + /* Create the data set */ + dataset = H5Dcreate (file, DSET_TCONV_NAME, H5T_NATIVE_INT32, space, + H5C_DEFAULT); + assert (dataset>=0); + + /* Write the data to the dataset */ + status = H5Dwrite (dataset, H5T_NATIVE_INT32, H5P_ALL, H5C_DEFAULT, out); + assert (status>=0); + + /* Create a new type with the opposite byte order */ + type = H5Tcopy (H5T_NATIVE_INT32); + switch (H5Tget_order (type)) { + case H5T_ORDER_BE: + H5Tset_order (type, H5T_ORDER_LE); + break; + case H5T_ORDER_LE: + H5Tset_order (type, H5T_ORDER_BE); + break; + default: + assert ("funny byte order" && 0); + break; + } + + /* Read data with byte order conversion */ + status = H5Dread (dataset, type, H5P_ALL, H5C_DEFAULT, in); + assert (status>=0); + + /* Check */ + for (i=0; i<1000000; i++) { + assert (in[4*i+0] == out[4*i+3]); + assert (in[4*i+1] == out[4*i+2]); + assert (in[4*i+2] == out[4*i+1]); + assert (in[4*i+3] == out[4*i+0]); + } + + H5Dclose (dataset); + H5Tclose (type); + + puts (" PASSED"); + return SUCCEED; +} + + + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests the dataset interface (H5D) @@ -310,6 +394,9 @@ main (void) status = test_simple_io (file); nerrors += status<0 ? 1 : 0; + status = test_tconv (file); + nerrors += status<0 ? 1 : 0; + status = H5Fclose (file); if (nerrors) { |