summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/.distdep17
-rw-r--r--test/Makefile.in16
-rw-r--r--test/bittests.c524
-rw-r--r--test/dtypes.c94
-rw-r--r--test/tattr.c24
5 files changed, 653 insertions, 22 deletions
diff --git a/test/.distdep b/test/.distdep
index 991f255..b2dc049 100644
--- a/test/.distdep
+++ b/test/.distdep
@@ -423,3 +423,20 @@ chunk.o: \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
+bittests.o: \
+ bittests.c \
+ ../src/H5Tpkg.h \
+ ../src/H5HGprivate.h \
+ ../src/H5HGpublic.h \
+ ../src/H5public.h \
+ ../src/H5config.h \
+ ../src/H5Fprivate.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Ipublic.h \
+ ../src/H5private.h \
+ ../src/H5Dpublic.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Tpublic.h \
+ ../src/H5Gprivate.h \
+ ../src/H5Gpublic.h \
+ ../src/H5Bprivate.h
diff --git a/test/Makefile.in b/test/Makefile.in
index 37a01ac..3a68a67 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -11,10 +11,10 @@ CPPFLAGS=-I. -I../src @CPPFLAGS@
# These are our main targets. They should be listed in the order to be
# executed, generally most specific tests to least specific tests.
-PROGS=testhdf5 gheap hyperslab istore dtypes dsets cmpd_dset extend external \
- shtype iopipe big links chunk
-TESTS=testhdf5 gheap hyperslab istore dtypes dsets cmpd_dset extend external \
- shtype links
+PROGS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset extend \
+ external shtype iopipe big links chunk
+TESTS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset extend \
+ external shtype links
TIMINGS=iopipe chunk
# Temporary files
@@ -32,7 +32,7 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
# overlap with other tests.
PROG_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c \
dtypes.c hyperslab.c istore.c dsets.c cmpd_dset.c extend.c external.c \
- iopipe.c gheap.c shtype.c big.c links.c chunk.c
+ iopipe.c gheap.c shtype.c big.c links.c chunk.c bittests.c
PROG_OBJ=$(PROG_SRC:.c=.o)
TESTHDF5_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c
@@ -44,6 +44,9 @@ GHEAP_OBJ=$(GHEAP_SRC:.c=.o)
DSETS_SRC=dsets.c
DSETS_OBJ=$(DSETS_SRC:.c=.o)
+BITTESTS_SRC=bittests.c
+BITTESTS_OBJ=$(BITTESTS_SRC:.c=.o)
+
DTYPES_SRC=dtypes.c
DTYPES_OBJ=$(DTYPES_SRC:.c=.o)
@@ -103,6 +106,9 @@ gheap: $(GHEAP_OBJ) ../src/libhdf5.a
dsets: $(DSETS_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(DSETS_OBJ) ../src/libhdf5.a $(LIBS)
+bittests: $(BITTESTS_OBJ) ../src/libhdf5.a
+ $(CC) $(CFLAGS) -o $@ $(BITTESTS_OBJ) ../src/libhdf5.a $(LIBS)
+
dtypes: $(DTYPES_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(DTYPES_OBJ) ../src/libhdf5.a $(LIBS)
diff --git a/test/bittests.c b/test/bittests.c
new file mode 100644
index 0000000..88c48dc
--- /dev/null
+++ b/test/bittests.c
@@ -0,0 +1,524 @@
+/*
+ * Copyright (C) 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Tuesday, June 16, 1998
+ *
+ * Purpose: Tests functions in H5Tbit.c
+ */
+#define H5T_PACKAGE
+#include <H5Tpkg.h>
+
+#define NTESTS 100000
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_find
+ *
+ * Purpose: Test bit find operations. This is just the basic stuff; more
+ * rigorous testing will be performed by the other test
+ * functions.
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, June 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_find (void)
+{
+ uint8 v1[8];
+ intn i;
+ ssize_t n;
+
+ printf ("%-70s", "Testing bit search operations");
+ fflush (stdout);
+
+ /* The zero length buffer */
+ memset (v1, 0xaa, sizeof v1);
+ n = H5T_bit_find (v1, 0, 0, H5T_BIT_LSB, TRUE);
+ if (-1!=n) {
+ puts ("*FAILED*");
+ puts (" Zero length test failed (lsb)!");
+ goto failed;
+ }
+ n = H5T_bit_find (v1, 0, 0, H5T_BIT_MSB, TRUE);
+ if (-1!=n) {
+ puts ("*FAILED*");
+ puts (" Zero length test failed (msb)!");
+ goto failed;
+ }
+
+
+ /* The zero buffer */
+ memset (v1, 0, sizeof v1);
+ n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, TRUE);
+ if (-1!=n) {
+ puts ("*FAILED*");
+ puts (" Zero buffer test failed (lsb)!");
+ goto failed;
+ }
+ n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, TRUE);
+ if (-1!=n) {
+ puts ("*FAILED*");
+ puts (" Zero buffer test failed (msb)!");
+ goto failed;
+ }
+
+ /* Try all combinations of one byte */
+ for (i=0; i<8*(int)sizeof(v1); i++) {
+ memset (v1, 0, sizeof v1);
+ v1[i/8] = 1<<(i%8);
+ n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, TRUE);
+ if ((ssize_t)i!=n) {
+ puts ("*FAILED*");
+ printf (" Test for set bit %d failed (lsb)!\n", i);
+ goto failed;
+ }
+ n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, TRUE);
+ if ((ssize_t)i!=n) {
+ puts ("*FAILED*");
+ printf (" Test for set bit %d failed (msb)!\n", i);
+ goto failed;
+ }
+ }
+
+ /* The one buffer */
+ memset (v1, 0xff, sizeof v1);
+ n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, FALSE);
+ if (-1!=n) {
+ puts ("*FAILED*");
+ puts (" One buffer test failed (lsb)!");
+ goto failed;
+ }
+ n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, FALSE);
+ if (-1!=n) {
+ puts ("*FAILED*");
+ puts (" One buffer test failed (msb)!");
+ goto failed;
+ }
+
+ /* Try all combinations of one byte */
+ for (i=0; i<8*(int)sizeof(v1); i++) {
+ memset (v1, 0xff, sizeof v1);
+ v1[i/8] &= ~(1<<(i%8));
+ n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, FALSE);
+ if ((ssize_t)i!=n) {
+ puts ("*FAILED*");
+ printf (" Test for clear bit %d failed (lsb)!\n", i);
+ goto failed;
+ }
+ n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, FALSE);
+ if ((ssize_t)i!=n) {
+ puts ("*FAILED*");
+ printf (" Test for clear bit %d failed (lsb)!\n", i);
+ goto failed;
+ }
+ }
+
+
+ puts (" PASSED");
+ return 0;
+
+ failed:
+ printf (" v = 0x");
+ for (i=0; i<(int)sizeof(v1); i++) printf ("%02x", v1[i]);
+ printf ("\n");
+ return -1;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy
+ *
+ * Purpose: Test bit copy operations.
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, June 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_copy (void)
+{
+ uint8 v1[8], v2[8];
+ size_t s_offset, d_offset, size;
+ intn i, j;
+ ssize_t n;
+
+ printf ("%-70s", "Testing bit copy operations");
+ fflush (stdout);
+
+ for (i=0; i<NTESTS; i++) {
+ s_offset = rand() % (8*sizeof v1);
+ d_offset = rand() % (8*sizeof v2);
+ size = (unsigned)rand() % MIN (8*sizeof(v1), 8*sizeof(v2));
+ size = MIN3 (size, 8*sizeof(v1)-s_offset, 8*sizeof(v2)-d_offset);
+ memset (v1, 0xff, sizeof v1);
+ memset (v2, 0x00, sizeof v2);
+
+ /* Copy some bits to v2 and make sure something was copied */
+ H5T_bit_copy (v2, d_offset, v1, s_offset, size);
+ for (j=0; j<(intn)sizeof(v2); j++) if (v2[j]) break;
+ if (size>0 && j>=(intn)sizeof(v2)) {
+ puts ("*FAILED*");
+ puts (" Unabled to find copied region in destination");
+ goto failed;
+ }
+ if (0==size && j<(intn)sizeof(v2)) {
+ puts ("*FAILED*");
+ puts (" Found copied bits when we shouldn't have");
+ goto failed;
+ }
+
+
+ /* Look for the zeros and ones */
+ n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 1);
+ if (size>0 && n!=(ssize_t)d_offset) {
+ puts ("*FAILED*");
+ printf (" Unable to find first copied bit in destination "
+ "(n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (0==size && n>=0) {
+ puts ("*FAILED*");
+ puts (" Found copied bits and shouldn't have!");
+ goto failed;
+ }
+ n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0);
+ if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) {
+ puts ("*FAILED*");
+ printf (" Unable to find last copied bit in destination "
+ "(n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (d_offset+size==8*sizeof(v2) && n>=0) {
+ puts ("*FAILED*");
+ puts (" High-order zeros are present and shouldn't be!");
+ goto failed;
+ }
+
+ /*
+ * Look for zeros and ones in reverse order. This is only to test
+ * that reverse searches work as expected.
+ */
+ n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 1);
+ if (size>0 && (size_t)(n+1)!=d_offset+size) {
+ puts ("*FAILED*");
+ printf (" Unable to find last copied bit in destination "
+ "(reverse, n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (0==size && n>=0) {
+ puts ("*FAILED*");
+ puts (" Found copied bits but shouldn't have (reverse)!");
+ goto failed;
+ }
+ n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 0);
+ if (d_offset>0 && n+1!=(ssize_t)d_offset) {
+ puts ("*FAILED*");
+ printf (" Unable to find beginning of copied data "
+ "(reverse, n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (0==d_offset && n>=0) {
+ puts ("*FAILED*");
+ puts (" Found leading original data but shouldn't have!");
+ goto failed;
+ }
+
+ }
+
+ puts (" PASSED");
+ return 0;
+
+ failed:
+ printf (" i=%d, s_offset=%lu, d_offset=%lu, size=%lu\n",
+ i, (unsigned long)s_offset, (unsigned long)d_offset,
+ (unsigned long)size);
+ printf (" s = 0x");
+ for (j=sizeof(v1)-1; j>=0; --j) printf ("%02x", v1[j]);
+ printf ("\n d = 0x");
+ for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]);
+ printf ("\n");
+ return -1;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_set
+ *
+ * Purpose: Test bit set operations
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, June 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_set (void)
+{
+ uint8 v2[8];
+ size_t d_offset, size;
+ intn i, j;
+ ssize_t n;
+
+ printf ("%-70s", "Testing bit set operations");
+ fflush (stdout);
+
+ for (i=0; i<NTESTS; i++) {
+ d_offset = rand() % (8*sizeof v2);
+ size = (unsigned)rand() % (8*sizeof(v2));
+ size = MIN (size, 8*sizeof(v2)-d_offset);
+ memset (v2, 0x00, sizeof v2);
+
+ /* Set some bits in v2 */
+ H5T_bit_set (v2, d_offset, size, TRUE);
+ for (j=0; j<(intn)sizeof(v2); j++) if (v2[j]) break;
+ if (size>0 && j>=(intn)sizeof(v2)) {
+ puts ("*FAILED*");
+ puts (" Unabled to find set region in buffer");
+ goto failed;
+ }
+ if (0==size && j<(intn)sizeof(v2)) {
+ puts ("*FAILED*");
+ puts (" Found set bits when we shouldn't have");
+ goto failed;
+ }
+
+
+ /* Look for the zeros and ones */
+ n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 1);
+ if (size>0 && n!=(ssize_t)d_offset) {
+ puts ("*FAILED*");
+ printf (" Unable to find first set bit in destination "
+ "(n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (0==size && n>=0) {
+ puts ("*FAILED*");
+ puts (" Found set bits and shouldn't have!");
+ goto failed;
+ }
+ n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0);
+ if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) {
+ puts ("*FAILED*");
+ printf (" Unable to find last set bit in destination "
+ "(n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (d_offset+size==8*sizeof(v2) && n>=0) {
+ puts ("*FAILED*");
+ puts (" High-order zeros are present and shouldn't be!");
+ goto failed;
+ }
+
+ /*
+ * Look for zeros and ones in reverse order. This is only to test
+ * that reverse searches work as expected.
+ */
+ n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 1);
+ if (size>0 && (size_t)(n+1)!=d_offset+size) {
+ puts ("*FAILED*");
+ printf (" Unable to find last set bit in destination "
+ "(reverse, n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (0==size && n>=0) {
+ puts ("*FAILED*");
+ puts (" Found set bits but shouldn't have (reverse)!");
+ goto failed;
+ }
+ n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 0);
+ if (d_offset>0 && n+1!=(ssize_t)d_offset) {
+ puts ("*FAILED*");
+ printf (" Unable to find beginning of set bit region "
+ "(reverse, n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (0==d_offset && n>=0) {
+ puts ("*FAILED*");
+ puts (" Found leading zeros but shouldn't have!");
+ goto failed;
+ }
+
+ }
+
+ puts (" PASSED");
+ return 0;
+
+ failed:
+ printf (" i=%d, d_offset=%lu, size=%lu\n",
+ i, (unsigned long)d_offset, (unsigned long)size);
+ printf (" d = 0x");
+ for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]);
+ printf ("\n");
+ return -1;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_clear
+ *
+ * Purpose: Test bit clear operations
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, June 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_clear (void)
+{
+ uint8 v2[8];
+ size_t d_offset, size;
+ intn i, j;
+ ssize_t n;
+
+ printf ("%-70s", "Testing bit clear operations");
+ fflush (stdout);
+
+ for (i=0; i<NTESTS; i++) {
+ d_offset = rand() % (8*sizeof v2);
+ size = (unsigned)rand() % (8*sizeof(v2));
+ size = MIN (size, 8*sizeof(v2)-d_offset);
+ memset (v2, 0xff, sizeof v2);
+
+ /* Clear some bits in v2 */
+ H5T_bit_set (v2, d_offset, size, FALSE);
+ for (j=0; j<(intn)sizeof(v2); j++) if (0xff!=v2[j]) break;
+ if (size>0 && j>=(intn)sizeof(v2)) {
+ puts ("*FAILED*");
+ puts (" Unabled to find cleared region in buffer");
+ goto failed;
+ }
+ if (0==size && j<(intn)sizeof(v2)) {
+ puts ("*FAILED*");
+ puts (" Found cleared bits when we shouldn't have");
+ goto failed;
+ }
+
+
+ /* Look for the zeros and ones */
+ n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 0);
+ if (size>0 && n!=(ssize_t)d_offset) {
+ puts ("*FAILED*");
+ printf (" Unable to find first cleared bit in destination "
+ "(n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (0==size && n>=0) {
+ puts ("*FAILED*");
+ puts (" Found cleared bits and shouldn't have!");
+ goto failed;
+ }
+ n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 1);
+ if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) {
+ puts ("*FAILED*");
+ printf (" Unable to find last cleared bit in destination "
+ "(n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (d_offset+size==8*sizeof(v2) && n>=0) {
+ puts ("*FAILED*");
+ puts (" High-order ones are present and shouldn't be!");
+ goto failed;
+ }
+
+ /*
+ * Look for zeros and ones in reverse order. This is only to test
+ * that reverse searches work as expected.
+ */
+ n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 0);
+ if (size>0 && (size_t)(n+1)!=d_offset+size) {
+ puts ("*FAILED*");
+ printf (" Unable to find last cleared bit in destination "
+ "(reverse, n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (0==size && n>=0) {
+ puts ("*FAILED*");
+ puts (" Found cleared bits but shouldn't have (reverse)!");
+ goto failed;
+ }
+ n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 1);
+ if (d_offset>0 && n+1!=(ssize_t)d_offset) {
+ puts ("*FAILED*");
+ printf (" Unable to find beginning of cleared bit region "
+ "(reverse, n=%d)\n", (int)n);
+ goto failed;
+ }
+ if (0==d_offset && n>=0) {
+ puts ("*FAILED*");
+ puts (" Found leading ones but shouldn't have!");
+ goto failed;
+ }
+
+ }
+
+ puts (" PASSED");
+ return 0;
+
+ failed:
+ printf (" i=%d, d_offset=%lu, size=%lu\n",
+ i, (unsigned long)d_offset, (unsigned long)size);
+ printf (" d = 0x");
+ for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]);
+ printf ("\n");
+ return -1;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose:
+ *
+ * Return: Success:
+ *
+ * Failure:
+ *
+ * Programmer: Robb Matzke
+ * Tuesday, June 16, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main (void)
+{
+ intn nerrors=0;
+
+ nerrors += test_find ()<0?1:0;
+ nerrors += test_set ()<0?1:0;
+ nerrors += test_clear()<0?1:0;
+ nerrors += test_copy ()<0?1:0;
+
+ return nerrors?1:0;
+}
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",
diff --git a/test/tattr.c b/test/tattr.c
index 16cfdf3..1eae9b5 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -134,7 +134,7 @@ test_attr_basic_write(void)
VERIFY(ret, FAIL, "H5Acreate");
/* Write attribute information */
- ret=H5Awrite(attr,H5T_NATIVE_INT32,&attr_data1);
+ ret=H5Awrite(attr,H5T_NATIVE_INT32,attr_data1);
CHECK(ret, FAIL, "H5Awrite");
/* Close attribute */
@@ -167,7 +167,7 @@ test_attr_basic_write(void)
VERIFY(ret, FAIL, "H5Acreate");
/* Write attribute information */
- ret=H5Awrite(attr,H5T_NATIVE_INT32,&attr_data2);
+ ret=H5Awrite(attr,H5T_NATIVE_INT32,attr_data2);
CHECK(ret, FAIL, "H5Awrite");
/* Close attribute */
@@ -224,7 +224,7 @@ test_attr_basic_read(void)
CHECK(attr, FAIL, "H5Aopen_name");
/* Read attribute information */
- ret=H5Aread(attr,H5T_NATIVE_INT32,&read_data1);
+ ret=H5Aread(attr,H5T_NATIVE_INT32,read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
@@ -253,7 +253,7 @@ test_attr_basic_read(void)
CHECK(attr, FAIL, "H5Aopen_name");
/* Read attribute information */
- ret=H5Aread(attr,H5T_NATIVE_INT32,&read_data2);
+ ret=H5Aread(attr,H5T_NATIVE_INT32,read_data2);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
@@ -339,7 +339,7 @@ test_attr_compound_write(void)
VERIFY(ret, FAIL, "H5Acreate");
/* Write complex attribute data */
- ret=H5Awrite(attr,tid1,&attr_data4);
+ ret=H5Awrite(attr,tid1,attr_data4);
CHECK(ret, FAIL, "H5Awrite");
/* Close attribute */
@@ -480,7 +480,7 @@ test_attr_compound_read(void)
H5Tclose(field);
/* Read attribute information */
- ret=H5Aread(attr,type,&read_data4);
+ ret=H5Aread(attr,type,read_data4);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
@@ -681,7 +681,7 @@ test_attr_mult_write(void)
VERIFY(ret, FAIL, "H5Acreate");
/* Write 1st attribute data */
- ret=H5Awrite(attr,H5T_NATIVE_INT32,&attr_data1);
+ ret=H5Awrite(attr,H5T_NATIVE_INT32,attr_data1);
CHECK(ret, FAIL, "H5Awrite");
/* Close 1st attribute */
@@ -705,7 +705,7 @@ test_attr_mult_write(void)
VERIFY(ret, FAIL, "H5Acreate");
/* Write 2nd attribute information */
- ret=H5Awrite(attr,H5T_NATIVE_INT32,&attr_data2);
+ ret=H5Awrite(attr,H5T_NATIVE_INT32,attr_data2);
CHECK(ret, FAIL, "H5Awrite");
/* Close 2nd attribute */
@@ -729,7 +729,7 @@ test_attr_mult_write(void)
VERIFY(ret, FAIL, "H5Acreate");
/* Write 3rd attribute information */
- ret=H5Awrite(attr,H5T_NATIVE_DOUBLE,&attr_data3);
+ ret=H5Awrite(attr,H5T_NATIVE_DOUBLE,attr_data3);
CHECK(ret, FAIL, "H5Awrite");
/* Close 3rd attribute */
@@ -819,7 +819,7 @@ test_attr_mult_read(void)
H5Tclose(type);
/* Read attribute information */
- ret=H5Aread(attr,H5T_NATIVE_INT32,&read_data1);
+ ret=H5Aread(attr,H5T_NATIVE_INT32,read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
@@ -884,7 +884,7 @@ test_attr_mult_read(void)
H5Tclose(type);
/* Read attribute information */
- ret=H5Aread(attr,H5T_NATIVE_INT32,&read_data2);
+ ret=H5Aread(attr,H5T_NATIVE_INT32,read_data2);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
@@ -954,7 +954,7 @@ test_attr_mult_read(void)
H5Tclose(type);
/* Read attribute information */
- ret=H5Aread(attr,H5T_NATIVE_DOUBLE,&read_data3);
+ ret=H5Aread(attr,H5T_NATIVE_DOUBLE,read_data3);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */