diff options
Diffstat (limited to 'test/ntypes.c')
-rw-r--r-- | test/ntypes.c | 84 |
1 files changed, 56 insertions, 28 deletions
diff --git a/test/ntypes.c b/test/ntypes.c index 781dfef..fa208e3 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -298,6 +298,7 @@ test_compound_dtype2(hid_t file) typedef struct s2 { short c2; long l2; + long long ll2; } s2; typedef struct s1 { char c; @@ -329,7 +330,8 @@ test_compound_dtype2(hid_t file) temp_point->i = n++; temp_point->st.c2 = (short)(i + j); temp_point->st.l2 = (i * 5 + j * 50) * n; - temp_point->l = (unsigned long long)((i * 10 + j * 100) * n); + temp_point->st.ll2 = (i * 10 + j * 100) * n; + temp_point->l = (unsigned long long)((i * 100 + j * 1000) * n); } /* end for */ } /* end for */ @@ -339,37 +341,40 @@ test_compound_dtype2(hid_t file) if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; /* Create compound datatype for disk storage */ -#if H5_SIZEOF_LONG==4 - if((tid2=H5Tcreate(H5T_COMPOUND, 6)) < 0) TEST_ERROR; - if((tid=H5Tcreate(H5T_COMPOUND, 19)) < 0) TEST_ERROR; -#elif H5_SIZEOF_LONG==8 - if((tid2=H5Tcreate(H5T_COMPOUND, 10)) < 0) TEST_ERROR; - if((tid=H5Tcreate(H5T_COMPOUND, 23)) < 0) TEST_ERROR; -#else -#error "Unknown 'long' size" -#endif + if((tid2=H5Tcreate(H5T_COMPOUND, sizeof(s2))) < 0) TEST_ERROR; + if((tid=H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR; /* Insert and pack members */ - if(H5Tinsert(tid2, "c2", 0, H5T_STD_I16BE) < 0) TEST_ERROR; + if(H5Tinsert(tid2, "c2", HOFFSET(s2, c2), H5T_STD_I16BE) < 0) TEST_ERROR; #if H5_SIZEOF_LONG == 4 - if(H5Tinsert(tid2, "l2", 2, H5T_STD_I32LE) < 0) TEST_ERROR; + if(H5Tinsert(tid2, "l2", HOFFSET(s2, l2), H5T_STD_I32LE) < 0) TEST_ERROR; #elif H5_SIZEOF_LONG == 8 - if(H5Tinsert(tid2, "l2", 2, H5T_STD_I64LE) < 0) TEST_ERROR; + if(H5Tinsert(tid2, "l2", HOFFSET(s2, l2), H5T_STD_I64LE) < 0) TEST_ERROR; #else #error "Unknown 'long' size" #endif +#if H5_SIZEOF_LONG_LONG == 4 + if(H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I32BE) < 0) TEST_ERROR; +#elif H5_SIZEOF_LONG_LONG == 8 + if(H5Tinsert(tid2, "ll2", HOFFSET(s2, ll2), H5T_STD_I64BE) < 0) TEST_ERROR; +#else +#error "Unknown 'long long' size" +#endif - if(H5Tinsert(tid, "c", 0, H5T_STD_U8LE) < 0) TEST_ERROR; - if(H5Tinsert(tid, "i", 1, H5T_STD_I32LE) < 0) TEST_ERROR; - if(H5Tinsert(tid, "st", 5, tid2) < 0) TEST_ERROR; -#if H5_SIZEOF_LONG == 4 - if(H5Tinsert(tid, "l", 11, H5T_STD_U64BE) < 0) TEST_ERROR; -#elif H5_SIZEOF_LONG == 8 - if(H5Tinsert(tid, "l", 15, H5T_STD_U64BE) < 0) TEST_ERROR; + if(H5Tinsert(tid, "c", HOFFSET(s1, c), H5T_STD_U8LE) < 0) TEST_ERROR; + if(H5Tinsert(tid, "i", HOFFSET(s1, i), H5T_STD_I32LE) < 0) TEST_ERROR; + if(H5Tinsert(tid, "st", HOFFSET(s1, st), tid2) < 0) TEST_ERROR; +#if H5_SIZEOF_LONG_LONG == 4 + if(H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U32BE) < 0) TEST_ERROR; +#elif H5_SIZEOF_LONG_LONG == 8 + if(H5Tinsert(tid, "l", HOFFSET(s1, l), H5T_STD_U64BE) < 0) TEST_ERROR; #else -#error "Unknown 'long' size" +#error "Unknown 'long long' size" #endif + /* Take away the paddings */ + if(H5Tpack(tid) < 0) TEST_ERROR; + /* Create the dataset */ if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_2, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -382,6 +387,7 @@ test_compound_dtype2(hid_t file) /* Insert members */ if(H5Tinsert(tid_m2, "c2", HOFFSET(s2, c2), H5T_NATIVE_SHORT) < 0) TEST_ERROR; if(H5Tinsert(tid_m2, "l2", HOFFSET(s2, l2), H5T_NATIVE_LONG) < 0) TEST_ERROR; + if(H5Tinsert(tid_m2, "ll2", HOFFSET(s2, ll2), H5T_NATIVE_LLONG) < 0) TEST_ERROR; if(H5Tinsert(tid_m, "c", HOFFSET(s1, c), H5T_NATIVE_UCHAR) < 0) TEST_ERROR; if(H5Tinsert(tid_m, "i", HOFFSET(s1, i), H5T_NATIVE_INT) < 0) TEST_ERROR; if(H5Tinsert(tid_m, "st", HOFFSET(s1, st), tid_m2) < 0) TEST_ERROR; @@ -406,13 +412,16 @@ test_compound_dtype2(hid_t file) if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; + if(H5Tequal(native_type, tid_m) != TRUE) + TEST_ERROR; + /* Verify the datatype of each field retrieved and converted */ /* check the char member */ if((mem_id = H5Tget_member_type(native_type, 0)) < 0) TEST_ERROR; - if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_UCHAR)) + if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_SCHAR)) TEST_ERROR; - if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_U8LE)) + if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I8LE)) TEST_ERROR; if(H5T_INTEGER != H5Tget_class(mem_id)) TEST_ERROR; @@ -429,7 +438,7 @@ test_compound_dtype2(hid_t file) TEST_ERROR; H5Tclose(mem_id); - /* check the long long member */ + /* check the unsigned long long member */ if((mem_id = H5Tget_member_type(native_type, 3)) < 0) TEST_ERROR; if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_ULLONG)) @@ -469,6 +478,21 @@ test_compound_dtype2(hid_t file) TEST_ERROR; H5Tclose(mem_id); + if((mem_id = H5Tget_member_type(nest_mem_id, 2)) < 0) + TEST_ERROR; + if(H5Tget_order(mem_id) != H5Tget_order(H5T_NATIVE_LLONG)) + TEST_ERROR; +#if H5_SIZEOF_LONG_LONG==4 + if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I32LE)) TEST_ERROR; +#elif H5_SIZEOF_LONG_LONG==8 + if(H5Tget_size(mem_id) < H5Tget_size(H5T_STD_I64LE)) TEST_ERROR; +#else +#error "Unknown 'long long' size" +#endif + if(H5T_INTEGER!=H5Tget_class(mem_id)) + TEST_ERROR; + H5Tclose(mem_id); + /* Read the dataset back. Temporary buffer is for special platforms like * Cray */ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type)))) @@ -496,6 +520,7 @@ test_compound_dtype2(hid_t file) temp_point->i != temp_check->i || temp_point->st.c2 != temp_check->st.c2 || temp_point->st.l2 != temp_check->st.l2 || + temp_point->st.ll2 != temp_check->st.ll2 || temp_point->l != temp_check->l ) { H5_FAILED(); printf(" Read different values than written.\n"); @@ -644,6 +669,9 @@ test_compound_dtype(hid_t file) if((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) TEST_ERROR; + if(H5Tequal(native_type, tid2) != TRUE) + TEST_ERROR; + /* Verify the datatype of each field retrieved and converted */ if((mem_id = H5Tget_member_type(native_type, 0)) < 0) TEST_ERROR; @@ -2550,7 +2578,7 @@ test_bitfield_dtype(hid_t file) H5P_DEFAULT)) < 0) TEST_ERROR; for(i = 0; i < BITFIELD_ENUMB*sizeof(int); i++) - wbuf[i] = (unsigned int)0xff ^ (unsigned int)i; + wbuf[i] = (unsigned char)((unsigned int)0xff ^ (unsigned int)i); if(H5Dwrite(dset1, H5T_NATIVE_B32, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; if(H5Dclose(dset1) < 0) TEST_ERROR; @@ -2581,12 +2609,12 @@ test_bitfield_dtype(hid_t file) /* Read the data and compare them */ if(H5Dread(dataset1, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR; - p = (unsigned int*)rbuf; + p = (unsigned char *)rbuf; for(i = 0; i < BITFIELD_ENUMB*4; i++) { if(*p != wbuf[i]) { H5_FAILED(); printf(" Read different values than written.\n"); - printf(" At index %d\n", i); + printf(" At index %zu\n", i); TEST_ERROR; } p++; @@ -2611,7 +2639,7 @@ test_bitfield_dtype(hid_t file) if(intr[i] != intw[i]) { H5_FAILED(); printf(" Read different values than written.\n"); - printf(" At index %d\n", i); + printf(" At index %zu\n", i); TEST_ERROR; } } |