summaryrefslogtreecommitdiffstats
path: root/test/dtypes.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-06-16 19:38:26 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-06-16 19:38:26 (GMT)
commit53916f4e5935ae7c36d7dd6e04d1c5e51b7e78ea (patch)
tree76c6163d98ac715ddec1dfe4fa69f8f2753636a0 /test/dtypes.c
parenta639a5998c7bc5d9f00f95e0ee4157950b5e49eb (diff)
downloadhdf5-53916f4e5935ae7c36d7dd6e04d1c5e51b7e78ea.zip
hdf5-53916f4e5935ae7c36d7dd6e04d1c5e51b7e78ea.tar.gz
hdf5-53916f4e5935ae7c36d7dd6e04d1c5e51b7e78ea.tar.bz2
[svn-r428] Changes since 19980612
---------------------- ./src/H5Tbit.c ./MANIFEST ./test/Makefile.in ./test/bittests.c NEW Finished the bit vector operations and added test cases. ./src/H5Tconv.c ./test/dtypes.c Finished integer->integer general conversion and added test cases. Overflows and underflows are handled by substituting the closest possible value. Examples: (unsigned)0xffff -> (unsigned) 0xff ( signed)0xffff -> (unsigned)0x0000 (unsigned)0xffff -> ( signed)0x7fff ( signed)0x7fff -> ( signed) 0x7f ( signed)0xbfff -> ( signed) 0xbf ( signed)0x8000 -> ( signed) 0x80 ./src/H5private.h Added definitions for MIN and MAX that take 3 or 4 arguments: MIN3(), MIN4(), MAX3(), MAX4(). Also added MIN2() and MAX2() as aliases for MIN() and MAX(). ./test/tattr.c Removed some redundant `&' operators. ./configure.in ./src/H5config.h.in [regenerated] ./src/H5.c Fixed warnings on DEC where long double is the same as double.
Diffstat (limited to 'test/dtypes.c')
-rw-r--r--test/dtypes.c94
1 files changed, 89 insertions, 5 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index e3d300f..a2f9a76 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -517,14 +517,100 @@ test_named (void)
static herr_t
test_conv_num (void)
{
- const size_t ntests=1;
- const size_t nelmts=1;
+ const size_t ntests=100;
+ const size_t nelmts=2000;
size_t i, j;
void *buf=NULL, *saved=NULL;
+ unsigned char byte[4];
- printf ("%-70s", "Testing atomic number conversions");
+ /*---------------------------------------------------------------------
+ * Test some specific overflow/underflow cases.
+ *---------------------------------------------------------------------
+ */
+ printf ("%-70s", "Testing atomic number overflow conversions");
+ fflush (stdout);
+
+ /* (unsigned)0x80000000 -> (unsigned)0xffff */
+ byte[0] = byte[1] = byte[2] = 0;
+ byte[3] = 0x80;
+ if (H5Tconvert (H5T_NATIVE_UINT32, H5T_NATIVE_UINT16, 1, byte, NULL)<0) {
+ goto error;
+ }
+ if (byte[0]!=0xff || byte[1]!=0xff) {
+ puts ("*FAILED*");
+ puts (" (unsigned)0x80000000 -> (unsigned)0xffff");
+ goto error;
+ }
+
+ /* (unsigned)0xffffffff -> (signed)0x7fff */
+ byte[0] = byte[1] = byte[2] = byte[3] = 0xff;
+ if (H5Tconvert (H5T_NATIVE_UINT32, H5T_NATIVE_INT16, 1, byte, NULL)<0) {
+ goto error;
+ }
+ if (byte[0]!=0xff || byte[1]!=0x7f) {
+ puts ("*FAILED*");
+ puts (" (unsigned)0xffffffff -> (signed)0x7f");
+ goto error;
+ }
+ /* (signed)0xffffffff -> (unsigned)0x0000 */
+ byte[0] = byte[1] = byte[2] = byte[3] = 0xff;
+ if (H5Tconvert (H5T_NATIVE_INT32, H5T_NATIVE_UINT16, 1, byte, NULL)<0) {
+ goto error;
+ }
+ if (byte[0]!=0x00 || byte[1]!=0x00) {
+ puts ("*FAILED*");
+ puts (" (signed)0xffffffff -> (unsigned)0x00");
+ goto error;
+ }
+
+ /* (signed)0x7fffffff -> (unsigned)0xffff */
+ byte[0] = byte[1] = byte[2] = 0xff;
+ byte[3] = 0x7f;
+ if (H5Tconvert (H5T_NATIVE_INT32, H5T_NATIVE_UINT16, 1, byte, NULL)<0) {
+ goto error;
+ }
+ if (byte[0]!=0xff || byte[1]!=0xff) {
+ puts ("*FAILED*");
+ puts (" (signed)0x7fffffff -> (unsigned)0xffff");
+ goto error;
+ }
+
+ /* (signed)0x7fffffff -> (signed)0x7fff */
+ byte[0] = byte[1] = byte[2] = 0xff;
+ byte[3] = 0x7f;
+ if (H5Tconvert (H5T_NATIVE_INT32, H5T_NATIVE_INT16, 1, byte, NULL)<0) {
+ goto error;
+ }
+ if (byte[0]!=0xff || byte[1]!=0x7f) {
+ puts ("*FAILED*");
+ puts (" (signed)0x7fffffff -> (signed)0x7fff");
+ goto error;
+ }
+
+ /* (signed)0xbfffffff -> (signed)0x8000 */
+ byte[0] = byte[1] = byte[2] = 0xff;
+ byte[3] = 0xbf;
+ if (H5Tconvert (H5T_NATIVE_INT32, H5T_NATIVE_INT16, 1, byte, NULL)<0) {
+ goto error;
+ }
+ if (byte[0]!=0x00 || byte[1]!=0x80) {
+ puts ("*FAILED*");
+ puts (" (signed)0xbfffffff -> (signed)0x8000");
+ goto error;
+ }
+
+ puts (" PASSED");
+
+
+ /*-----------------------------------------------------------------------
+ * Test random cases.
+ *-----------------------------------------------------------------------
+ */
+ printf ("%-70s", "Testing atomic number random conversions");
+ fflush (stdout);
+
/* Allocate buffers */
buf = malloc (nelmts*8);
saved = malloc (nelmts*8);
@@ -597,9 +683,7 @@ main(void)
nerrors += test_compound()<0 ? 1 : 0;
nerrors += test_transient ()<0 ? 1 : 0;
nerrors += test_named ()<0 ? 1 : 0;
-#if 0
nerrors += test_conv_num ()<0 ? 1 : 0;
-#endif
if (nerrors) {
printf("***** %d DATA TYPE TEST%s FAILED! *****\n",