diff options
Diffstat (limited to 'test/dsets.c')
-rw-r--r-- | test/dsets.c | 98 |
1 files changed, 55 insertions, 43 deletions
diff --git a/test/dsets.c b/test/dsets.c index 4d20023..c099f9e 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -1017,15 +1017,15 @@ test_conv_buffer(hid_t fid) /* Populate the data members */ for(j = 0; j < DIM1; j++) - for(k = 0; k < DIM2; k++) - for(l = 0; l < DIM3; l++) - cf->a[j][k][l] = 10*(j+1) + l + k; + for(k = 0; k < DIM2; k++) + for(l = 0; l < DIM3; l++) + cf->a[j][k][l] = 10*(j+1) + l + k; for(j = 0; j < DIM2; j++) - cf->b[j] = (float)(100.0f*(j+1) + 0.01f*j); + cf->b[j] = 100.0f * (float)(j+1) + 0.01f * (float)j; for(j = 0; j < DIM3; j++) - cf->c[j] = 100.0f*(j+1) + 0.02f*j; + cf->c[j] = 100.0f * (float)(j+1) + 0.02f * (float)j; /* Create data space */ @@ -1102,7 +1102,7 @@ test_conv_buffer(hid_t fid) HDfree(cf); HDfree(cfrR); puts(" PASSED"); - return(0); + return 0; error: return -1; @@ -2692,7 +2692,8 @@ test_nbit_int(hid_t file) int new_data[2][5]; unsigned int mask; size_t precision, offset; - size_t i, j; + double power; + size_t i, j; puts("Testing nbit filter"); TESTING(" nbit int (setup)"); @@ -2725,8 +2726,8 @@ test_nbit_int(hid_t file) /* Initialize data, assuming size of long long >= size of int */ for(i= 0;i< (size_t)size[0]; i++) for(j = 0; j < (size_t)size[1]; j++) { - orig_data[i][j] = (int)(((long long)HDrandom() % - (long long)HDpow(2.0f, (double)(precision - 1))) << offset); + power = HDpow(2.0f, (double)(precision - 1)); + orig_data[i][j] = (int)(((long long)HDrandom() % (long long)power) << offset); /* even-numbered values are negtive */ if((i*size[1]+j+1)%2 == 0) @@ -3052,7 +3053,8 @@ test_nbit_array(hid_t file) unsigned int orig_data[2][5][3][2]; unsigned int new_data[2][5][3][2]; size_t precision, offset; - size_t i, j, m, n; + double power; + size_t i, j, m, n; TESTING(" nbit array (setup)"); @@ -3091,9 +3093,11 @@ test_nbit_array(hid_t file) for(i= 0;i< (size_t)size[0]; i++) for(j = 0; j < (size_t)size[1]; j++) for(m = 0; m < (size_t)adims[0]; m++) - for(n = 0; n < (size_t)adims[1]; n++) + for(n = 0; n < (size_t)adims[1]; n++) { + power = HDpow(2.0F, (double)precision); orig_data[i][j][m][n] = (unsigned int)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)precision)) << offset); + (long long)power) << offset); + } /* end for */ PASSED(); /*---------------------------------------------------------------------- @@ -3192,7 +3196,8 @@ test_nbit_compound(hid_t file) atomic orig_data[2][5]; atomic new_data[2][5]; unsigned int i_mask, s_mask, c_mask; - size_t i, j; + double power; + size_t i, j; TESTING(" nbit compound (setup)"); @@ -3251,12 +3256,12 @@ test_nbit_compound(hid_t file) /* Initialize data, assuming size of long long >= size of member datatypes */ for(i= 0;i< (size_t)size[0]; i++) for(j = 0; j < (size_t)size[1]; j++) { - orig_data[i][j].i = (int)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[0]-1))) << offset[0]); - orig_data[i][j].c = (char)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[1]-1))) << offset[1]); - orig_data[i][j].s = (short)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[2]-1))) << offset[2]); + power = HDpow(2.0F, (double)(precision[0]-1)); + orig_data[i][j].i = (int)(((long long)HDrandom() % (long long)power) << offset[0]); + power = HDpow(2.0F, (double)(precision[1]-1)); + orig_data[i][j].c = (char)(((long long)HDrandom() % (long long)power) << offset[1]); + power = HDpow(2.0F, (double)(precision[2]-1)); + orig_data[i][j].s = (short)(((long long)HDrandom() % (long long)power) << offset[2]); orig_data[i][j].f = float_val[i][j]; /* some even-numbered integer values are negtive */ @@ -3386,7 +3391,8 @@ test_nbit_compound_2(hid_t file) complex orig_data[2][5]; complex new_data[2][5]; unsigned int i_mask, s_mask, c_mask, b_mask; - size_t i, j, m, n, b_failed, d_failed; + double power; + size_t i, j, m, n, b_failed, d_failed; TESTING(" nbit compound complex (setup)"); @@ -3477,33 +3483,34 @@ test_nbit_compound_2(hid_t file) /* Initialize data, assuming size of long long >= size of member datatypes */ for(i= 0;i< (size_t)size[0]; i++) for(j = 0; j < (size_t)size[1]; j++) { - orig_data[i][j].a.i = (int)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[0]-1))) << offset[0]); - orig_data[i][j].a.c = (char)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[1]-1))) << offset[1]); - orig_data[i][j].a.s = (short)(-((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[2]-1))) << offset[2]); + power = HDpow(2.0F, (double)(precision[0]-1)); + orig_data[i][j].a.i = (int)(((long long)HDrandom() % (long long)power) << offset[0]); + power = HDpow(2.0F, (double)(precision[1]-1)); + orig_data[i][j].a.c = (char)(((long long)HDrandom() % (long long)power) << offset[1]); + power = HDpow(2.0F, (double)(precision[2]-1)); + orig_data[i][j].a.s = (short)(-((long long)HDrandom() % (long long)power) << offset[2]); orig_data[i][j].a.f = float_val[i][j]; - orig_data[i][j].v = (unsigned int)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)precision[3])) << offset[3]); + power = HDpow(2.0F, (double)precision[3]); + orig_data[i][j].v = (unsigned int)(((long long)HDrandom() % (long long)power) << offset[3]); for(m = 0; m < (size_t)array_dims[0]; m++) - for(n = 0; n < (size_t)array_dims[1]; n++) - orig_data[i][j].b[m][n] = (char)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[4]-1))) << offset[4]); + for(n = 0; n < (size_t)array_dims[1]; n++) { + power = HDpow(2.0F, (double)(precision[4]-1)); + orig_data[i][j].b[m][n] = (char)(((long long)HDrandom() % (long long)power) << offset[4]); + } /* end for */ for(m = 0; m < (size_t)array_dims[0]; m++) for(n = 0; n < (size_t)array_dims[1]; n++) { - orig_data[i][j].d[m][n].i = (int)(-((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[0]-1))) << offset[0]); - orig_data[i][j].d[m][n].c = (char)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[1]-1))) << offset[1]); - orig_data[i][j].d[m][n].s = (short)(((long long)HDrandom() % - (long long)HDpow(2.0F, (double)(precision[2]-1))) << offset[2]); + power = HDpow(2.0F, (double)(precision[0]-1)); + orig_data[i][j].d[m][n].i = (int)(-((long long)HDrandom() % (long long)power) << offset[0]); + power = HDpow(2.0F, (double)(precision[1]-1)); + orig_data[i][j].d[m][n].c = (char)(((long long)HDrandom() % (long long)power) << offset[1]); + power = HDpow(2.0F, (double)(precision[2]-1)); + orig_data[i][j].d[m][n].s = (short)(((long long)HDrandom() % (long long)power) << offset[2]); orig_data[i][j].d[m][n].f = float_val[i][j]; - } - } + } /* end for */ + } /* end for */ PASSED(); @@ -3648,7 +3655,8 @@ test_nbit_compound_3(hid_t file) const hsize_t chunk_size[1] = {5}; atomic orig_data[5]; atomic new_data[5]; - size_t i, k, j; + double power; + size_t i, k, j; TESTING(" nbit compound with no-op type (setup)"); @@ -3695,8 +3703,9 @@ test_nbit_compound_3(hid_t file) /* Initialize data */ for(i = 0; i < (size_t)size[0]; i++) { + power = HDpow(2.0F, 17.0F - 1.0F); HDmemset(&orig_data[i], 0, sizeof(orig_data[i])); - orig_data[i].i = HDrandom() % (long)HDpow(2.0F, 17.0F - 1.0F); + orig_data[i].i = HDrandom() % (long)power; HDstrcpy(orig_data[i].str, "fixed-length C string"); orig_data[i].vl_str = HDstrdup("variable-length C string"); @@ -3815,6 +3824,7 @@ test_nbit_int_size(hid_t file) hsize_t dims[2], chunk_size[2]; hsize_t dset_size = 0; int orig_data[DSET_DIM1][DSET_DIM2]; + double power; int i, j; size_t precision, offset; @@ -3865,8 +3875,10 @@ test_nbit_int_size(hid_t file) * corresponding to the memory datatype's precision and offset. */ for (i=0; i < DSET_DIM1; i++) - for (j=0; j < DSET_DIM2; j++) - orig_data[i][j] = rand() % (int)pow((double)2, (double)(precision-1)) << offset; + for (j=0; j < DSET_DIM2; j++) { + power = HDpow(2.0F, (double)(precision-1)); + orig_data[i][j] = HDrandom() % (int)power << offset; + } /* end for */ /* Describe the dataspace. */ |