summaryrefslogtreecommitdiffstats
path: root/test/hyperslab.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /test/hyperslab.c
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'test/hyperslab.c')
-rw-r--r--test/hyperslab.c863
1 files changed, 411 insertions, 452 deletions
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 27b31cf..43992de 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -23,17 +23,16 @@
#include "h5test.h"
#include "H5VMprivate.h"
-#define TEST_SMALL 0x0001
-#define TEST_MEDIUM 0x0002
+#define TEST_SMALL 0x0001
+#define TEST_MEDIUM 0x0002
-#define VARIABLE_SRC 0
-#define VARIABLE_DST 1
-#define VARIABLE_BOTH 2
+#define VARIABLE_SRC 0
+#define VARIABLE_DST 1
+#define VARIABLE_BOTH 2
-#define ARRAY_FILL_SIZE 4
+#define ARRAY_FILL_SIZE 4
#define ARRAY_OFFSET_NDIMS 3
-
/*-------------------------------------------------------------------------
* Function: init_full
*
@@ -49,23 +48,22 @@
static unsigned
init_full(uint8_t *array, size_t nx, size_t ny, size_t nz)
{
- uint8_t acc = 128;
- unsigned total = 0;
- size_t i, j, k;
-
- for(i = 0; i < nx; i++)
- for(j = 0; j < ny; j++)
- for(k = 0; k < nz; k++) {
- total += acc;
- *array = acc;
- acc++;
- array++;
- } /* end for */
+ uint8_t acc = 128;
+ unsigned total = 0;
+ size_t i, j, k;
+
+ for (i = 0; i < nx; i++)
+ for (j = 0; j < ny; j++)
+ for (k = 0; k < nz; k++) {
+ total += acc;
+ *array = acc;
+ acc++;
+ array++;
+ } /* end for */
return total;
} /* end init_full() */
-
/*-------------------------------------------------------------------------
* Function: print_array
*
@@ -81,27 +79,26 @@ init_full(uint8_t *array, size_t nx, size_t ny, size_t nz)
static void
print_array(uint8_t *array, size_t nx, size_t ny, size_t nz)
{
- size_t i, j, k;
-
- for(i = 0; i < nx; i++) {
- if(nz > 1)
- HDprintf("i=%lu:\n", (unsigned long)i);
- else
- HDprintf("%03lu:", (unsigned long)i);
-
- for(j = 0; j < ny; j++) {
- if(nz > 1)
- HDprintf("%03lu:", (unsigned long)j);
- for(k = 0; k < nz; k++)
- HDprintf(" %3d", *array++);
- if(nz > 1)
+ size_t i, j, k;
+
+ for (i = 0; i < nx; i++) {
+ if (nz > 1)
+ HDprintf("i=%lu:\n", (unsigned long)i);
+ else
+ HDprintf("%03lu:", (unsigned long)i);
+
+ for (j = 0; j < ny; j++) {
+ if (nz > 1)
+ HDprintf("%03lu:", (unsigned long)j);
+ for (k = 0; k < nz; k++)
+ HDprintf(" %3d", *array++);
+ if (nz > 1)
+ HDprintf("\n");
+ } /* end for */
HDprintf("\n");
} /* end for */
- HDprintf("\n");
- } /* end for */
} /* end print_array() */
-
/*-------------------------------------------------------------------------
* Function: print_ref
*
@@ -121,7 +118,7 @@ print_ref(size_t nx, size_t ny, size_t nz)
{
uint8_t *array;
- if(NULL != (array = (uint8_t *)HDmalloc(nx * ny * nz))) {
+ if (NULL != (array = (uint8_t *)HDmalloc(nx * ny * nz))) {
HDprintf("Reference array:\n");
init_full(array, nx, ny, nz);
print_array(array, nx, ny, nz);
@@ -129,7 +126,6 @@ print_ref(size_t nx, size_t ny, size_t nz)
} /* end if */
} /* end print_ref() */
-
/*-------------------------------------------------------------------------
* Function: test_fill
*
@@ -145,79 +141,77 @@ print_ref(size_t nx, size_t ny, size_t nz)
*-------------------------------------------------------------------------
*/
static herr_t
-test_fill(size_t nx, size_t ny, size_t nz,
- size_t di, size_t dj, size_t dk,
- size_t ddx, size_t ddy, size_t ddz)
+test_fill(size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_t dk, size_t ddx, size_t ddy,
+ size_t ddz)
{
- uint8_t *dst = NULL; /*destination array */
- hsize_t hs_size[3]; /*hyperslab size */
- hsize_t dst_size[3]; /*destination total size */
- hsize_t dst_offset[3]; /*offset of hyperslab in dest */
- unsigned ref_value; /*reference value */
- unsigned acc; /*accumulator */
- size_t i, j, k, dx, dy, dz; /*counters */
- size_t u, v, w;
- unsigned ndims; /*hyperslab dimensionality */
- char dim[64], s[256]; /*temp string */
- unsigned fill_value; /*fill value */
+ uint8_t *dst = NULL; /*destination array */
+ hsize_t hs_size[3]; /*hyperslab size */
+ hsize_t dst_size[3]; /*destination total size */
+ hsize_t dst_offset[3]; /*offset of hyperslab in dest */
+ unsigned ref_value; /*reference value */
+ unsigned acc; /*accumulator */
+ size_t i, j, k, dx, dy, dz; /*counters */
+ size_t u, v, w;
+ unsigned ndims; /*hyperslab dimensionality */
+ char dim[64], s[256]; /*temp string */
+ unsigned fill_value; /*fill value */
/*
* Dimensionality.
*/
- if(0 == nz) {
- if(0 == ny) {
+ if (0 == nz) {
+ if (0 == ny) {
ndims = 1;
ny = nz = 1;
- HDsprintf(dim, "%lu", (unsigned long) nx);
+ HDsprintf(dim, "%lu", (unsigned long)nx);
} /* end if */
else {
ndims = 2;
- nz = 1;
- HDsprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ nz = 1;
+ HDsprintf(dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
} /* end else */
- } /* end if */
+ } /* end if */
else {
ndims = 3;
- HDsprintf(dim, "%lux%lux%lu", (unsigned long) nx, (unsigned long) ny,
- (unsigned long) nz);
+ HDsprintf(dim, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
} /* end else */
HDsprintf(s, "Testing hyperslab fill %-11s variable hyperslab", dim);
HDprintf("%-70s", s);
fflush(stdout);
/* Allocate array */
- if(NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz)))
+ if (NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz)))
TEST_ERROR
init_full(dst, nx, ny, nz);
- for(i = 0; i < nx; i += di) {
- for(j = 0; j < ny; j += dj) {
- for(k = 0; k < nz; k += dk) {
- for(dx = 1; dx <= nx - i; dx += ddx) {
- for(dy = 1; dy <= ny - j; dy += ddy) {
- for(dz = 1; dz <= nz - k; dz += ddz) {
+ for (i = 0; i < nx; i += di) {
+ for (j = 0; j < ny; j += dj) {
+ for (k = 0; k < nz; k += dk) {
+ for (dx = 1; dx <= nx - i; dx += ddx) {
+ for (dy = 1; dy <= ny - j; dy += ddy) {
+ for (dz = 1; dz <= nz - k; dz += ddz) {
/* Describe the hyperslab */
- dst_size[0] = nx;
- dst_size[1] = ny;
- dst_size[2] = nz;
+ dst_size[0] = nx;
+ dst_size[1] = ny;
+ dst_size[2] = nz;
dst_offset[0] = i;
dst_offset[1] = j;
dst_offset[2] = k;
- hs_size[0] = dx;
- hs_size[1] = dy;
- hs_size[2] = dz;
+ hs_size[0] = dx;
+ hs_size[1] = dy;
+ hs_size[2] = dz;
- for(fill_value = 0; fill_value < 256; fill_value += 64) {
+ for (fill_value = 0; fill_value < 256; fill_value += 64) {
/*
* Initialize the full array, then subtract the
* original * fill values and add the new ones.
*/
ref_value = init_full(dst, nx, ny, nz);
- for(u = (size_t)dst_offset[0]; u < dst_offset[0] + dx; u++)
- for(v = (size_t)dst_offset[1]; v < dst_offset[1] + dy; v++)
- for(w = (size_t)dst_offset[2]; w < dst_offset[2] + dz; w++)
+ for (u = (size_t)dst_offset[0]; u < dst_offset[0] + dx; u++)
+ for (v = (size_t)dst_offset[1]; v < dst_offset[1] + dy; v++)
+ for (w = (size_t)dst_offset[2]; w < dst_offset[2] + dz; w++)
ref_value -= dst[u * ny * nz + v * nz + w];
ref_value += fill_value * (unsigned)dx * (unsigned)dy * (unsigned)dz;
@@ -229,14 +223,14 @@ test_fill(size_t nx, size_t ny, size_t nz,
* reference value.
*/
acc = 0;
- for(u = 0; u < nx; u++)
- for(v = 0; v < ny; v++)
- for(w = 0; w < nz; w++)
+ for (u = 0; u < nx; u++)
+ for (v = 0; v < ny; v++)
+ for (w = 0; w < nz; w++)
acc += dst[u * ny * nz + v * nz + w];
- if(acc != ref_value) {
+ if (acc != ref_value) {
H5_FAILED()
- if(!HDisatty(1)) {
+ if (!HDisatty(1)) {
/*
* Print debugging info unless output
* is going directly to a terminal.
@@ -244,26 +238,24 @@ test_fill(size_t nx, size_t ny, size_t nz,
AT();
HDprintf(" acc != ref_value\n");
HDprintf(" i=%lu, j=%lu, k=%lu, "
- "dx=%lu, dy=%lu, dz=%lu, "
- "fill=%d\n", (unsigned long)i,
- (unsigned long)j,
- (unsigned long)k,
- (unsigned long)dx,
- (unsigned long)dy,
- (unsigned long)dz, fill_value);
+ "dx=%lu, dy=%lu, dz=%lu, "
+ "fill=%d\n",
+ (unsigned long)i, (unsigned long)j, (unsigned long)k,
+ (unsigned long)dx, (unsigned long)dy, (unsigned long)dz,
+ fill_value);
print_ref(nx, ny, nz);
HDprintf("\n Result is:\n");
print_array(dst, nx, ny, nz);
} /* end if */
goto error;
} /* end if */
- } /* end for */
- } /* end for */
- } /* end for */
- } /* end for */
- } /* end for */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
PASSED();
@@ -272,12 +264,11 @@ test_fill(size_t nx, size_t ny, size_t nz,
return SUCCEED;
error:
- if(dst)
+ if (dst)
HDfree(dst);
return FAIL;
} /* end test_fill() */
-
/*-------------------------------------------------------------------------
* Function: test_copy
*
@@ -305,48 +296,45 @@ error:
*-------------------------------------------------------------------------
*/
static herr_t
-test_copy(int mode,
- size_t nx, size_t ny, size_t nz,
- size_t di, size_t dj, size_t dk,
- size_t ddx, size_t ddy, size_t ddz)
+test_copy(int mode, size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_t dk, size_t ddx, size_t ddy,
+ size_t ddz)
{
- uint8_t *src = NULL; /*source array */
- uint8_t *dst = NULL; /*destination array */
- hsize_t hs_size[3]; /*hyperslab size */
- hsize_t dst_size[3]; /*destination total size */
- hsize_t src_size[3]; /*source total size */
- hsize_t dst_offset[3]; /*offset of hyperslab in dest */
- hsize_t src_offset[3]; /*offset of hyperslab in source */
- unsigned ref_value; /*reference value */
- unsigned acc; /*accumulator */
+ uint8_t * src = NULL; /*source array */
+ uint8_t * dst = NULL; /*destination array */
+ hsize_t hs_size[3]; /*hyperslab size */
+ hsize_t dst_size[3]; /*destination total size */
+ hsize_t src_size[3]; /*source total size */
+ hsize_t dst_offset[3]; /*offset of hyperslab in dest */
+ hsize_t src_offset[3]; /*offset of hyperslab in source */
+ unsigned ref_value; /*reference value */
+ unsigned acc; /*accumulator */
hsize_t i, j, k, dx, dy, dz; /*counters */
hsize_t u, v, w;
- unsigned ndims; /*hyperslab dimensionality */
+ unsigned ndims; /*hyperslab dimensionality */
char dim[64], s[256]; /*temp string */
const char *sub;
/*
* Dimensionality.
*/
- if(0 == nz) {
- if(0 == ny) {
+ if (0 == nz) {
+ if (0 == ny) {
ndims = 1;
ny = nz = 1;
- HDsprintf(dim, "%lu", (unsigned long) nx);
+ HDsprintf(dim, "%lu", (unsigned long)nx);
} /* end if */
else {
ndims = 2;
- nz = 1;
- HDsprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny);
+ nz = 1;
+ HDsprintf(dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
} /* end else */
- } /* end if */
+ } /* end if */
else {
ndims = 3;
- HDsprintf(dim, "%lux%lux%lu", (unsigned long) nx, (unsigned long) ny,
- (unsigned long) nz);
+ HDsprintf(dim, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
} /* end else */
- switch(mode) {
+ switch (mode) {
case VARIABLE_SRC:
/*
* The hyperslab "travels" through the source array but the
@@ -383,31 +371,31 @@ test_copy(int mode,
/*
* Allocate arrays
*/
- if(NULL == (src = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz)))
+ if (NULL == (src = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz)))
TEST_ERROR
- if(NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz)))
+ if (NULL == (dst = (uint8_t *)HDcalloc((size_t)1, nx * ny * nz)))
TEST_ERROR
init_full(src, nx, ny, nz);
- for(i = 0; i < nx; i += di) {
- for(j = 0; j < ny; j += dj) {
- for(k = 0; k < nz; k += dk) {
- for(dx = 1; dx <= nx - i; dx += ddx) {
- for(dy = 1; dy <= ny - j; dy += ddy) {
- for(dz = 1; dz <= nz - k; dz += ddz) {
+ for (i = 0; i < nx; i += di) {
+ for (j = 0; j < ny; j += dj) {
+ for (k = 0; k < nz; k += dk) {
+ for (dx = 1; dx <= nx - i; dx += ddx) {
+ for (dy = 1; dy <= ny - j; dy += ddy) {
+ for (dz = 1; dz <= nz - k; dz += ddz) {
/*
* Describe the source and destination hyperslabs
* and the arrays to which they belong.
*/
- hs_size[0] = dx;
- hs_size[1] = dy;
- hs_size[2] = dz;
+ hs_size[0] = dx;
+ hs_size[1] = dy;
+ hs_size[2] = dz;
dst_size[0] = src_size[0] = nx;
dst_size[1] = src_size[1] = ny;
dst_size[2] = src_size[2] = nz;
- switch(mode) {
+ switch (mode) {
case VARIABLE_SRC:
dst_offset[0] = 0;
dst_offset[1] = 0;
@@ -444,38 +432,39 @@ test_copy(int mode,
* value to compare against later.
*/
ref_value = 0;
- for(u = src_offset[0]; u < src_offset[0] + dx; u++)
- for(v = src_offset[1]; v < src_offset[1] + dy; v++)
- for(w = src_offset[2]; w < src_offset[2] + dz; w++)
+ for (u = src_offset[0]; u < src_offset[0] + dx; u++)
+ for (v = src_offset[1]; v < src_offset[1] + dy; v++)
+ for (w = src_offset[2]; w < src_offset[2] + dz; w++)
ref_value += src[u * ny * nz + v * nz + w];
/*
* Set all loc values to 1 so we can detect writing
* outside the hyperslab.
*/
- for(u = 0; u < nx; u++)
- for(v = 0; v < ny; v++)
- for(w = 0; w < nz; w++)
+ for (u = 0; u < nx; u++)
+ for (v = 0; v < ny; v++)
+ for (w = 0; w < nz; w++)
dst[u * ny * nz + v * nz + w] = 1;
/*
* Copy a hyperslab from the global array to the
* local array.
*/
- H5VM_hyper_copy(ndims, hs_size, dst_size, dst_offset, dst, src_size, src_offset, src);
+ H5VM_hyper_copy(ndims, hs_size, dst_size, dst_offset, dst, src_size, src_offset,
+ src);
/*
* Sum the destination hyperslab. It should be
* the same as the reference value.
*/
acc = 0;
- for(u = dst_offset[0]; u < dst_offset[0] + dx; u++)
- for(v = dst_offset[1]; v < dst_offset[1] + dy; v++)
- for(w = dst_offset[2]; w < dst_offset[2] + dz; w++)
+ for (u = dst_offset[0]; u < dst_offset[0] + dx; u++)
+ for (v = dst_offset[1]; v < dst_offset[1] + dy; v++)
+ for (w = dst_offset[2]; w < dst_offset[2] + dz; w++)
acc += dst[u * ny * nz + v * nz + w];
- if(acc != ref_value) {
+ if (acc != ref_value) {
H5_FAILED()
- if(!HDisatty(1)) {
+ if (!HDisatty(1)) {
/*
* Print debugging info unless output is
* going directly to a terminal.
@@ -483,13 +472,9 @@ test_copy(int mode,
AT();
HDprintf(" acc != ref_value\n");
HDprintf(" i=%lu, j=%lu, k=%lu, "
- "dx=%lu, dy=%lu, dz=%lu\n",
- (unsigned long)i,
- (unsigned long)j,
- (unsigned long)k,
- (unsigned long)dx,
- (unsigned long)dy,
- (unsigned long)dz);
+ "dx=%lu, dy=%lu, dz=%lu\n",
+ (unsigned long)i, (unsigned long)j, (unsigned long)k,
+ (unsigned long)dx, (unsigned long)dy, (unsigned long)dz);
print_ref(nx, ny, nz);
HDprintf("\n Destination array is:\n");
print_array(dst, nx, ny, nz);
@@ -503,9 +488,9 @@ test_copy(int mode,
* we added the border of 1's to the hyperslab.
*/
acc = 0;
- for(u = 0; u < nx; u++)
- for(v = 0; v < ny; v++)
- for(w = 0; w < nz; w++)
+ for (u = 0; u < nx; u++)
+ for (v = 0; v < ny; v++)
+ for (w = 0; w < nz; w++)
acc += dst[u * ny * nz + v * nz + w];
/*
@@ -513,37 +498,33 @@ test_copy(int mode,
* optimization bug in the Mongoose 7.20 Irix64
* compiler.
*/
- if(acc + (unsigned) dx * (unsigned) dy
- * (unsigned) dz != ref_value + nx * ny * nz) {
+ if (acc + (unsigned)dx * (unsigned)dy * (unsigned)dz !=
+ ref_value + nx * ny * nz) {
H5_FAILED()
- if(!HDisatty(1)) {
+ if (!HDisatty(1)) {
/*
* Print debugging info unless output is
* going directly to a terminal.
*/
AT();
HDprintf(" acc != ref_value + nx*ny*nz - "
- "dx*dy*dz\n");
+ "dx*dy*dz\n");
HDprintf(" i=%lu, j=%lu, k=%lu, "
- "dx=%lu, dy=%lu, dz=%lu\n",
- (unsigned long)i,
- (unsigned long)j,
- (unsigned long)k,
- (unsigned long)dx,
- (unsigned long)dy,
- (unsigned long)dz);
+ "dx=%lu, dy=%lu, dz=%lu\n",
+ (unsigned long)i, (unsigned long)j, (unsigned long)k,
+ (unsigned long)dx, (unsigned long)dy, (unsigned long)dz);
print_ref(nx, ny, nz);
HDprintf("\n Destination array is:\n");
print_array(dst, nx, ny, nz);
} /* end if */
goto error;
} /* end if */
- } /* end for */
- } /* end for */
- } /* end for */
- } /* end for */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
PASSED();
@@ -553,15 +534,14 @@ test_copy(int mode,
return SUCCEED;
error:
- if(src)
+ if (src)
HDfree(src);
- if(dst)
+ if (dst)
HDfree(dst);
return FAIL;
} /* end test_copy() */
-
/*-------------------------------------------------------------------------
* Function: test_multifill
*
@@ -583,32 +563,32 @@ error:
static herr_t
test_multifill(size_t nx)
{
- hsize_t size;
- hsize_t src_stride;
- hsize_t dst_stride;
- char s[64];
+ hsize_t size;
+ hsize_t src_stride;
+ hsize_t dst_stride;
+ char s[64];
struct a_struct {
- int left;
+ int left;
double mid;
- int right;
+ int right;
} fill, *src = NULL, *dst = NULL;
- hsize_t i, j;
+ hsize_t i, j;
HDprintf("%-70s", "Testing multi-byte fill value");
fflush(stdout);
/* Initialize the source and destination */
- if(NULL == (src = (struct a_struct *)HDmalloc(nx * sizeof(*src))))
+ if (NULL == (src = (struct a_struct *)HDmalloc(nx * sizeof(*src))))
TEST_ERROR
- if(NULL == (dst = (struct a_struct *)HDmalloc(nx * sizeof(*dst))))
+ if (NULL == (dst = (struct a_struct *)HDmalloc(nx * sizeof(*dst))))
TEST_ERROR
- for(i = 0; i < nx; i++) {
- src[i].left = 1111111;
- src[i].mid = 12345.6789F;
+ for (i = 0; i < nx; i++) {
+ src[i].left = 1111111;
+ src[i].mid = 12345.6789F;
src[i].right = 2222222;
- dst[i].left = 3333333;
- dst[i].mid = 98765.4321F;
+ dst[i].left = 3333333;
+ dst[i].mid = 98765.4321F;
dst[i].right = 4444444;
} /* end for */
@@ -616,8 +596,8 @@ test_multifill(size_t nx)
* Describe the fill value. The zero stride says to read the same thing
* over and over again.
*/
- fill.left = 55555555;
- fill.mid = 3.1415927F;
+ fill.left = 55555555;
+ fill.mid = 3.1415927F;
fill.right = 66666666;
src_stride = 0;
@@ -630,41 +610,39 @@ test_multifill(size_t nx)
* Copy the fill value into each element
*/
size = nx;
- H5VM_stride_copy(1, (hsize_t)sizeof(double), &size, &dst_stride,
- &(dst[0].mid), &src_stride, &(fill.mid));
+ H5VM_stride_copy(1, (hsize_t)sizeof(double), &size, &dst_stride, &(dst[0].mid), &src_stride, &(fill.mid));
/*
* Check
*/
s[0] = '\0';
- for(i = 0; i < nx; i++) {
- if(dst[i].left != 3333333)
+ for (i = 0; i < nx; i++) {
+ if (dst[i].left != 3333333)
HDsprintf(s, "bad dst[%lu].left", (unsigned long)i);
- else if(!H5_DBL_ABS_EQUAL(dst[i].mid, fill.mid))
+ else if (!H5_DBL_ABS_EQUAL(dst[i].mid, fill.mid))
/* Check if two DOUBLE values are equal. If their difference
* is smaller than the EPSILON value for double, they are
* considered equal. See the definition in h5test.h.
*/
HDsprintf(s, "bad dst[%lu].mid", (unsigned long)i);
- else if(dst[i].right != 4444444)
+ else if (dst[i].right != 4444444)
HDsprintf(s, "bad dst[%lu].right", (unsigned long)i);
- if(s[0]) {
+ if (s[0]) {
H5_FAILED()
- if(!HDisatty(1)) {
+ if (!HDisatty(1)) {
AT();
- HDprintf(" fill={%d,%g,%d}\n ", fill.left, fill.mid,
- fill.right);
- for(j = 0; j < sizeof(fill); j++)
+ HDprintf(" fill={%d,%g,%d}\n ", fill.left, fill.mid, fill.right);
+ for (j = 0; j < sizeof(fill); j++)
HDprintf(" %02x", ((uint8_t *)&fill)[j]);
- HDprintf("\n dst[%lu]={%d,%g,%d}\n ", (unsigned long)i,
- dst[i].left, dst[i].mid, dst[i].right);
- for(j = 0; j < sizeof(dst[i]); j++)
+ HDprintf("\n dst[%lu]={%d,%g,%d}\n ", (unsigned long)i, dst[i].left, dst[i].mid,
+ dst[i].right);
+ for (j = 0; j < sizeof(dst[i]); j++)
HDprintf(" %02x", ((uint8_t *)(dst + i))[j]);
HDprintf("\n");
} /* end if */
goto error;
} /* end if */
- } /* end for */
+ } /* end for */
PASSED();
@@ -674,15 +652,14 @@ test_multifill(size_t nx)
return SUCCEED;
error:
- if(src)
+ if (src)
HDfree(src);
- if(dst)
+ if (dst)
HDfree(dst);
return FAIL;
} /* end test_multifill() */
-
/*-------------------------------------------------------------------------
* Function: test_endian
*
@@ -702,41 +679,41 @@ error:
static herr_t
test_endian(size_t nx)
{
- uint8_t *src = NULL; /*source array */
- uint8_t *dst = NULL; /*destination array */
- hssize_t src_stride[2]; /*source strides */
- hssize_t dst_stride[2]; /*destination strides */
- hsize_t size[2]; /*size vector */
- hsize_t i, j;
+ uint8_t *src = NULL; /*source array */
+ uint8_t *dst = NULL; /*destination array */
+ hssize_t src_stride[2]; /*source strides */
+ hssize_t dst_stride[2]; /*destination strides */
+ hsize_t size[2]; /*size vector */
+ hsize_t i, j;
HDprintf("%-70s", "Testing endian conversion by stride");
fflush(stdout);
/* Initialize arrays */
- if(NULL == (src = (uint8_t *)HDmalloc(nx * 4)))
+ if (NULL == (src = (uint8_t *)HDmalloc(nx * 4)))
TEST_ERROR
- if(NULL == (dst = (uint8_t *)HDcalloc(nx , (size_t)4)))
+ if (NULL == (dst = (uint8_t *)HDcalloc(nx, (size_t)4)))
TEST_ERROR
- init_full(src, nx, (size_t)4,(size_t)1);
+ init_full(src, nx, (size_t)4, (size_t)1);
/* Initialize strides */
src_stride[0] = 0;
src_stride[1] = 1;
dst_stride[0] = 8;
dst_stride[1] = -1;
- size[0] = nx;
- size[1] = 4;
+ size[0] = nx;
+ size[1] = 4;
/* Copy the array */
H5VM_stride_copy_s(2, (hsize_t)1, size, dst_stride, dst + 3, src_stride, src);
/* Compare */
- for(i = 0; i < nx; i++) {
- for(j = 0; j < 4; j++) {
- if(src[i * 4 + j] != dst[i * 4 + 3 - j]) {
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < 4; j++) {
+ if (src[i * 4 + j] != dst[i * 4 + 3 - j]) {
H5_FAILED()
- if(!HDisatty(1)) {
+ if (!HDisatty(1)) {
/*
* Print debugging info unless output is going directly
* to a terminal.
@@ -750,8 +727,8 @@ test_endian(size_t nx)
} /* end if */
goto error;
} /* end if */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
PASSED();
@@ -761,15 +738,14 @@ test_endian(size_t nx)
return SUCCEED;
error:
- if(src)
+ if (src)
HDfree(src);
- if(dst)
+ if (dst)
HDfree(dst);
return FAIL;
} /* end test_endian() */
-
/*-------------------------------------------------------------------------
* Function: test_transpose
*
@@ -788,67 +764,65 @@ error:
static herr_t
test_transpose(size_t nx, size_t ny)
{
- int *src = NULL;
- int *dst = NULL;
- hsize_t src_stride[2], dst_stride[2];
- hsize_t size[2];
+ int * src = NULL;
+ int * dst = NULL;
+ hsize_t src_stride[2], dst_stride[2];
+ hsize_t size[2];
char s[256];
- hsize_t i, j;
+ hsize_t i, j;
- HDsprintf(s, "Testing 2d transpose by stride %4lux%-lud", (unsigned long)nx,
- (unsigned long)ny);
+ HDsprintf(s, "Testing 2d transpose by stride %4lux%-lud", (unsigned long)nx, (unsigned long)ny);
HDprintf("%-70s", s);
fflush(stdout);
/* Initialize */
- if(NULL == (src = (int *)HDmalloc(nx * ny * sizeof(*src))))
+ if (NULL == (src = (int *)HDmalloc(nx * ny * sizeof(*src))))
TEST_ERROR
- if(NULL == (dst = (int *)HDcalloc(nx * ny, sizeof(*dst))))
+ if (NULL == (dst = (int *)HDcalloc(nx * ny, sizeof(*dst))))
TEST_ERROR
- for(i = 0; i < nx; i++)
- for(j = 0; j < ny; j++)
+ for (i = 0; i < nx; i++)
+ for (j = 0; j < ny; j++)
src[i * ny + j] = (int)(i * ny + j);
/* Build stride info */
- size[0] = nx;
- size[1] = ny;
+ size[0] = nx;
+ size[1] = ny;
src_stride[0] = 0;
src_stride[1] = sizeof(*src);
dst_stride[0] = (hsize_t)((1 - nx * ny) * sizeof(*src));
dst_stride[1] = (hsize_t)(nx * sizeof(*src));
/* Copy and transpose */
- H5VM_stride_copy(2, (hsize_t)sizeof(*src), size, dst_stride, dst,
- src_stride, src);
+ H5VM_stride_copy(2, (hsize_t)sizeof(*src), size, dst_stride, dst, src_stride, src);
/* Check */
- for(i = 0; i < nx; i++) {
- for(j = 0; j < ny; j++) {
- if(src[i * ny + j] != dst[j * nx + i]) {
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ if (src[i * ny + j] != dst[j * nx + i]) {
H5_FAILED()
- if(!HDisatty(1)) {
+ if (!HDisatty(1)) {
AT();
HDprintf(" diff at i=%lu, j=%lu\n", (unsigned long)i, (unsigned long)j);
HDprintf(" Source is:\n");
- for(i = 0; i < nx; i++) {
+ for (i = 0; i < nx; i++) {
HDprintf("%3lu:", (unsigned long)i);
- for(j = 0; j < ny; j++)
+ for (j = 0; j < ny; j++)
HDprintf(" %6d", src[i * ny + j]);
HDprintf("\n");
} /* end for */
HDprintf("\n Destination is:\n");
for (i = 0; i < ny; i++) {
HDprintf("%3lu:", (unsigned long)i);
- for(j = 0; j < nx; j++)
+ for (j = 0; j < nx; j++)
HDprintf(" %6d", dst[i * nx + j]);
HDprintf("\n");
} /* end for */
- } /* end if */
+ } /* end if */
goto error;
} /* end if */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
PASSED();
@@ -858,15 +832,14 @@ test_transpose(size_t nx, size_t ny)
return SUCCEED;
error:
- if(src)
+ if (src)
HDfree(src);
- if(dst)
+ if (dst)
HDfree(dst);
return FAIL;
} /* end test_transpose() */
-
/*-------------------------------------------------------------------------
* Function: test_sub_super
*
@@ -887,53 +860,50 @@ error:
static herr_t
test_sub_super(size_t nx, size_t ny)
{
- uint8_t *full = NULL; /*original image */
- uint8_t *half = NULL; /*image at 1/2 resolution */
- uint8_t *twice = NULL; /*2x2 pixels */
- hsize_t src_stride[4]; /*source stride info */
- hsize_t dst_stride[4]; /*destination stride info */
- hsize_t size[4]; /*number of sample points */
- hsize_t i, j;
- char s[256];
-
- HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
- (unsigned long)(2 * nx), (unsigned long)(2 * ny),
- (unsigned long)nx, (unsigned long)ny);
+ uint8_t *full = NULL; /*original image */
+ uint8_t *half = NULL; /*image at 1/2 resolution */
+ uint8_t *twice = NULL; /*2x2 pixels */
+ hsize_t src_stride[4]; /*source stride info */
+ hsize_t dst_stride[4]; /*destination stride info */
+ hsize_t size[4]; /*number of sample points */
+ hsize_t i, j;
+ char s[256];
+
+ HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)(2 * nx),
+ (unsigned long)(2 * ny), (unsigned long)nx, (unsigned long)ny);
HDprintf("%-70s", s);
fflush(stdout);
/* Initialize */
- if(NULL == (full = (uint8_t *)HDmalloc(4 * nx * ny)))
+ if (NULL == (full = (uint8_t *)HDmalloc(4 * nx * ny)))
TEST_ERROR
- if(NULL == (half = (uint8_t *)HDcalloc((size_t)1, nx * ny)))
+ if (NULL == (half = (uint8_t *)HDcalloc((size_t)1, nx * ny)))
TEST_ERROR
- if(NULL == (twice = (uint8_t *)HDcalloc((size_t)4, nx * ny)))
+ if (NULL == (twice = (uint8_t *)HDcalloc((size_t)4, nx * ny)))
TEST_ERROR
init_full(full, 2 * nx, 2 * ny, (size_t)1);
/* Setup */
- size[0] = nx;
- size[1] = ny;
+ size[0] = nx;
+ size[1] = ny;
src_stride[0] = (hsize_t)(2 * ny);
src_stride[1] = 2;
dst_stride[0] = 0;
dst_stride[1] = 1;
/* Copy */
- H5VM_stride_copy(2, (hsize_t)sizeof(uint8_t), size, dst_stride, half,
- src_stride, full);
+ H5VM_stride_copy(2, (hsize_t)sizeof(uint8_t), size, dst_stride, half, src_stride, full);
/* Check */
- for(i = 0; i < nx; i++) {
- for(j = 0; j < ny; j++) {
- if(full[4 * i * ny + 2 * j] != half[i * ny + j]) {
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ if (full[4 * i * ny + 2 * j] != half[i * ny + j]) {
H5_FAILED()
- if(!HDisatty(1)) {
+ if (!HDisatty(1)) {
AT();
- HDprintf(" full[%lu][%lu] != half[%lu][%lu]\n",
- (unsigned long)i * 2, (unsigned long)j * 2,
- (unsigned long)i, (unsigned long)j);
+ HDprintf(" full[%lu][%lu] != half[%lu][%lu]\n", (unsigned long)i * 2,
+ (unsigned long)j * 2, (unsigned long)i, (unsigned long)j);
HDprintf(" full is:\n");
print_array(full, 2 * nx, 2 * ny, (size_t)1);
HDprintf("\n half is:\n");
@@ -941,25 +911,24 @@ test_sub_super(size_t nx, size_t ny)
} /* end if */
goto error;
} /* end if */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
PASSED();
/*
* Test replicating pixels to produce an image twice as large in each
* dimension.
*/
- HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ",
- (unsigned long)nx, (unsigned long)ny, (unsigned long)(2 * nx),
- (unsigned long)(2 * ny));
+ HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)nx, (unsigned long)ny,
+ (unsigned long)(2 * nx), (unsigned long)(2 * ny));
HDprintf("%-70s", s);
fflush(stdout);
/* Setup stride */
- size[0] = nx;
- size[1] = ny;
- size[2] = 2;
- size[3] = 2;
+ size[0] = nx;
+ size[1] = ny;
+ size[2] = 2;
+ size[3] = 2;
src_stride[0] = 0;
src_stride[1] = 1;
src_stride[2] = 0;
@@ -970,32 +939,27 @@ test_sub_super(size_t nx, size_t ny)
dst_stride[3] = sizeof(uint8_t);
/* Copy */
- H5VM_stride_copy(4, (hsize_t)sizeof(uint8_t), size, dst_stride, twice,
- src_stride, half);
+ H5VM_stride_copy(4, (hsize_t)sizeof(uint8_t), size, dst_stride, twice, src_stride, half);
/* Check */
s[0] = '\0';
- for(i = 0; i < nx; i++) {
- for(j = 0; j < ny; j++) {
- if(half[i * ny + j] != twice[4 * i * ny + 2 * j])
- HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]",
- (unsigned long)i, (unsigned long)j,
- (unsigned long)i * 2, (unsigned long)j * 2);
- else if(half[i * ny + j] != twice[4 * i * ny + 2 * j + 1])
- HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]",
- (unsigned long)i, (unsigned long)j,
- (unsigned long)i * 2, (unsigned long)j * 2 + 1);
- else if(half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j])
- HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]",
- (unsigned long)i, (unsigned long)j,
- (unsigned long)i * 2 + 1, (unsigned long)j * 2);
- else if(half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1])
- HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]",
- (unsigned long)i, (unsigned long)j,
- (unsigned long)i * 2 + 1, (unsigned long)j * 2 + 1);
- if(s[0]) {
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ if (half[i * ny + j] != twice[4 * i * ny + 2 * j])
+ HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j,
+ (unsigned long)i * 2, (unsigned long)j * 2);
+ else if (half[i * ny + j] != twice[4 * i * ny + 2 * j + 1])
+ HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j,
+ (unsigned long)i * 2, (unsigned long)j * 2 + 1);
+ else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j])
+ HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j,
+ (unsigned long)i * 2 + 1, (unsigned long)j * 2);
+ else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1])
+ HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j,
+ (unsigned long)i * 2 + 1, (unsigned long)j * 2 + 1);
+ if (s[0]) {
H5_FAILED()
- if(!HDisatty(1)) {
+ if (!HDisatty(1)) {
AT();
HDprintf(" %s\n Half is:\n", s);
print_array(half, nx, ny, (size_t)1);
@@ -1004,8 +968,8 @@ test_sub_super(size_t nx, size_t ny)
} /* end if */
goto error;
} /* end if */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
PASSED();
@@ -1016,17 +980,16 @@ test_sub_super(size_t nx, size_t ny)
return SUCCEED;
error:
- if(full)
+ if (full)
HDfree(full);
- if(half)
+ if (half)
HDfree(half);
- if(twice)
+ if (twice)
HDfree(twice);
return FAIL;
} /* test_sub_super() */
-
/*-------------------------------------------------------------------------
* Function: test_array_fill
*
@@ -1046,30 +1009,30 @@ error:
static herr_t
test_array_fill(size_t lo, size_t hi)
{
- int *dst = NULL; /* Destination */
- int src[ARRAY_FILL_SIZE]; /* Source to duplicate */
- size_t u, v, w; /* Local index variables */
- char s[256];
+ int * dst = NULL; /* Destination */
+ int src[ARRAY_FILL_SIZE]; /* Source to duplicate */
+ size_t u, v, w; /* Local index variables */
+ char s[256];
- HDsprintf(s, "array filling %4lu-%-4lu elements", (unsigned long)lo,(unsigned long)hi);
+ HDsprintf(s, "array filling %4lu-%-4lu elements", (unsigned long)lo, (unsigned long)hi);
TESTING(s);
/* Initialize */
- if(NULL == (dst = (int *)HDcalloc(sizeof(int),ARRAY_FILL_SIZE * hi)))
+ if (NULL == (dst = (int *)HDcalloc(sizeof(int), ARRAY_FILL_SIZE * hi)))
TEST_ERROR
/* Setup */
- for(u = 0; u < ARRAY_FILL_SIZE; u++)
+ for (u = 0; u < ARRAY_FILL_SIZE; u++)
src[u] = (char)u;
/* Fill */
- for(w = lo; w <= hi; w++) {
+ for (w = lo; w <= hi; w++) {
H5VM_array_fill(dst, src, sizeof(src), w);
/* Check */
- for(u = 0; u < w; u++)
- for(v = 0; v < ARRAY_FILL_SIZE; v++)
- if(dst[(u * ARRAY_FILL_SIZE) + v] != src[v])
+ for (u = 0; u < w; u++)
+ for (v = 0; v < ARRAY_FILL_SIZE; v++)
+ if (dst[(u * ARRAY_FILL_SIZE) + v] != src[v])
TEST_ERROR
HDmemset(dst, 0, sizeof(int) * ARRAY_FILL_SIZE * w);
@@ -1082,12 +1045,11 @@ test_array_fill(size_t lo, size_t hi)
return SUCCEED;
error:
- if(dst)
+ if (dst)
HDfree(dst);
return FAIL;
} /* end test_array_fill() */
-
/*-------------------------------------------------------------------------
* Function: test_array_offset_n_calc
*
@@ -1107,20 +1069,21 @@ error:
static herr_t
test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z)
{
- hsize_t *a = NULL;
- hsize_t *temp_a; /* Array for stored calculated offsets */
- hsize_t off; /* Offset in array */
- size_t u, v, w; /* Local index variables */
- hsize_t dims[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of array to check */
- hsize_t coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates to check offset of */
- hsize_t new_coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of offset */
- char s[256];
-
- HDsprintf(s, "array offset %4lux%4lux%4lu elements", (unsigned long)z,(unsigned long)y,(unsigned long)x);
+ hsize_t *a = NULL;
+ hsize_t *temp_a; /* Array for stored calculated offsets */
+ hsize_t off; /* Offset in array */
+ size_t u, v, w; /* Local index variables */
+ hsize_t dims[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of array to check */
+ hsize_t coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates to check offset of */
+ hsize_t new_coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of offset */
+ char s[256];
+
+ HDsprintf(s, "array offset %4lux%4lux%4lu elements", (unsigned long)z, (unsigned long)y,
+ (unsigned long)x);
TESTING(s);
/* Initialize */
- if(NULL == (a = (hsize_t *)HDmalloc(sizeof(hsize_t) * x * y *z)))
+ if (NULL == (a = (hsize_t *)HDmalloc(sizeof(hsize_t) * x * y * z)))
TEST_ERROR
dims[0] = z;
@@ -1128,13 +1091,13 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z)
dims[2] = x;
/* Setup */
- for(u = 0, temp_a = a, off = 0; u < z; u++)
- for(v = 0; v < y; v++)
- for(w = 0; w < x; w++)
+ for (u = 0, temp_a = a, off = 0; u < z; u++)
+ for (v = 0; v < y; v++)
+ for (w = 0; w < x; w++)
*temp_a++ = off++;
/* Check offsets */
- for(u = 0; u < n; u++) {
+ for (u = 0; u < n; u++) {
/* Get random coordinate */
coords[0] = (hsize_t)((size_t)HDrandom() % z);
coords[1] = (hsize_t)((size_t)HDrandom() % y);
@@ -1144,20 +1107,21 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z)
off = H5VM_array_offset(ARRAY_OFFSET_NDIMS, dims, coords);
/* Check offset of coordinate */
- if(a[off] != off)
+ if (a[off] != off)
TEST_ERROR
/* Get coordinates of offset */
- if(H5VM_array_calc(off, ARRAY_OFFSET_NDIMS, dims, new_coords) < 0)
+ if (H5VM_array_calc(off, ARRAY_OFFSET_NDIMS, dims, new_coords) < 0)
TEST_ERROR
/* Check computed coordinates */
- for(v = 0; v < ARRAY_OFFSET_NDIMS; v++)
- if(coords[v] != new_coords[v]) {
- HDfprintf(stderr,"coords[%zu]=%" PRIuHSIZE ", new_coords[%zu]=%" PRIuHSIZE "\n", v, coords[v], v, new_coords[v]);
+ for (v = 0; v < ARRAY_OFFSET_NDIMS; v++)
+ if (coords[v] != new_coords[v]) {
+ HDfprintf(stderr, "coords[%zu]=%" PRIuHSIZE ", new_coords[%zu]=%" PRIuHSIZE "\n", v,
+ coords[v], v, new_coords[v]);
TEST_ERROR;
} /* end if */
- } /* end for */
+ } /* end for */
PASSED();
@@ -1166,13 +1130,12 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z)
return SUCCEED;
error:
- if(a)
+ if (a)
HDfree(a);
return FAIL;
} /* end test_array_offset_n_calc() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -1190,32 +1153,32 @@ error:
int
main(int argc, char *argv[])
{
- herr_t status;
- int nerrors = 0;
- unsigned size_of_test;
+ herr_t status;
+ int nerrors = 0;
+ unsigned size_of_test;
/* Parse arguments or assume `small' & `medium' */
- if(1 == argc)
+ if (1 == argc)
size_of_test = TEST_SMALL | TEST_MEDIUM;
else {
int i;
- for(i = 1, size_of_test = 0; i < argc; i++) {
- if(!HDstrcmp(argv[i], "small"))
+ for (i = 1, size_of_test = 0; i < argc; i++) {
+ if (!HDstrcmp(argv[i], "small"))
size_of_test |= TEST_SMALL;
- else if(!HDstrcmp(argv[i], "medium"))
+ else if (!HDstrcmp(argv[i], "medium"))
size_of_test |= TEST_MEDIUM;
else {
HDprintf("unrecognized argument: %s\n", argv[i]);
HDexit(EXIT_FAILURE);
} /* end else */
- } /* end for */
- } /* end else */
+ } /* end for */
+ } /* end else */
HDprintf("Test sizes: ");
- if(size_of_test & TEST_SMALL)
+ if (size_of_test & TEST_SMALL)
HDprintf(" SMALL");
- if(size_of_test & TEST_MEDIUM)
+ if (size_of_test & TEST_MEDIUM)
HDprintf(" MEDIUM");
HDprintf("\n");
@@ -1228,33 +1191,33 @@ main(int argc, char *argv[])
*/
#ifdef H5_HAVE_THREADSAFE
H5open();
-#endif /* H5_HAVE_THREADSAFE */
+#endif /* H5_HAVE_THREADSAFE */
/*
*------------------------------
* TEST HYPERSLAB FILL OPERATION
*------------------------------
*/
- if(size_of_test & TEST_SMALL) {
- status = test_fill((size_t)11, (size_t)0, (size_t)0, (size_t)1,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ if (size_of_test & TEST_SMALL) {
+ status = test_fill((size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_fill((size_t)11, (size_t)10, (size_t)0, (size_t)1,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_fill((size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_fill((size_t)3, (size_t)5, (size_t)5, (size_t)1,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_fill((size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
} /* end if */
- if(size_of_test & TEST_MEDIUM) {
- status = test_fill((size_t)113, (size_t)0, (size_t)0, (size_t)1,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_fill((size_t)113, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_fill((size_t)15, (size_t)11, (size_t)0, (size_t)1,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_fill((size_t)15, (size_t)11, (size_t)0, (size_t)1, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_fill((size_t)5, (size_t)7, (size_t)7, (size_t)1,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_fill((size_t)5, (size_t)7, (size_t)7, (size_t)1, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
} /* end if */
@@ -1264,84 +1227,84 @@ main(int argc, char *argv[])
*/
/* exhaustive, one-dimensional test */
- if(size_of_test & TEST_SMALL) {
- status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)0, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ if (size_of_test & TEST_SMALL) {
+ status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, (size_t)11, (size_t)0, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_DST, (size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)0, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
} /* end if */
- if(size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, (size_t)179, (size_t)0, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_copy(VARIABLE_SRC, (size_t)179, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, (size_t)179, (size_t)0, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_DST, (size_t)179, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, (size_t)179, (size_t)0, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_BOTH, (size_t)179, (size_t)0, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
} /* end if */
/* exhaustive, two-dimensional test */
- if(size_of_test & TEST_SMALL) {
- status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)10, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ if (size_of_test & TEST_SMALL) {
+ status = test_copy(VARIABLE_SRC, (size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, (size_t)11, (size_t)10, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_DST, (size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)10, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_BOTH, (size_t)11, (size_t)10, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
} /* end if */
- if(size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, (size_t)13, (size_t)19, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_copy(VARIABLE_SRC, (size_t)13, (size_t)19, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, (size_t)13, (size_t)19, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_DST, (size_t)13, (size_t)19, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, (size_t)13, (size_t)19, (size_t)0,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_BOTH, (size_t)13, (size_t)19, (size_t)0, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
} /* end if */
/* sparse, two-dimensional test */
- if(size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, (size_t)73, (size_t)67, (size_t)0,
- (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1);
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_copy(VARIABLE_SRC, (size_t)73, (size_t)67, (size_t)0, (size_t)7, (size_t)11, (size_t)1,
+ (size_t)13, (size_t)11, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, (size_t)73, (size_t)67, (size_t)0,
- (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1);
+ status = test_copy(VARIABLE_DST, (size_t)73, (size_t)67, (size_t)0, (size_t)7, (size_t)11, (size_t)1,
+ (size_t)13, (size_t)11, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, (size_t)73, (size_t)67, (size_t)0,
- (size_t)7, (size_t)11, (size_t)1, (size_t)13, (size_t)11, (size_t)1);
+ status = test_copy(VARIABLE_BOTH, (size_t)73, (size_t)67, (size_t)0, (size_t)7, (size_t)11, (size_t)1,
+ (size_t)13, (size_t)11, (size_t)1);
nerrors += status < 0 ? 1 : 0;
} /* end if */
/* exhaustive, three-dimensional test */
- if(size_of_test & TEST_SMALL) {
- status = test_copy(VARIABLE_SRC, (size_t)3, (size_t)5, (size_t)5,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ if (size_of_test & TEST_SMALL) {
+ status = test_copy(VARIABLE_SRC, (size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, (size_t)3, (size_t)5, (size_t)5,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_DST, (size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, (size_t)3, (size_t)5, (size_t)5,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_BOTH, (size_t)3, (size_t)5, (size_t)5, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
} /* end if */
- if(size_of_test & TEST_MEDIUM) {
- status = test_copy(VARIABLE_SRC, (size_t)7, (size_t)9, (size_t)5,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_copy(VARIABLE_SRC, (size_t)7, (size_t)9, (size_t)5, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_DST, (size_t)7, (size_t)9, (size_t)5,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_DST, (size_t)7, (size_t)9, (size_t)5, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
- status = test_copy(VARIABLE_BOTH, (size_t)7, (size_t)9, (size_t)5,
- (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1, (size_t)1);
+ status = test_copy(VARIABLE_BOTH, (size_t)7, (size_t)9, (size_t)5, (size_t)1, (size_t)1, (size_t)1,
+ (size_t)1, (size_t)1, (size_t)1);
nerrors += status < 0 ? 1 : 0;
} /* end if */
@@ -1349,11 +1312,11 @@ main(int argc, char *argv[])
* TEST MULTI-BYTE FILL
*---------------------
*/
- if(size_of_test & TEST_SMALL) {
+ if (size_of_test & TEST_SMALL) {
status = test_multifill((size_t)10);
nerrors += status < 0 ? 1 : 0;
} /* end if */
- if(size_of_test & TEST_MEDIUM) {
+ if (size_of_test & TEST_MEDIUM) {
status = test_multifill((size_t)500000);
nerrors += status < 0 ? 1 : 0;
} /* end if */
@@ -1362,7 +1325,7 @@ main(int argc, char *argv[])
* TEST TRANSLATION OPERATORS
*---------------------------
*/
- if(size_of_test & TEST_SMALL) {
+ if (size_of_test & TEST_SMALL) {
status = test_endian((size_t)10);
nerrors += status < 0 ? 1 : 0;
status = test_transpose((size_t)9, (size_t)9);
@@ -1370,7 +1333,7 @@ main(int argc, char *argv[])
status = test_transpose((size_t)3, (size_t)11);
nerrors += status < 0 ? 1 : 0;
} /* end if */
- if(size_of_test & TEST_MEDIUM) {
+ if (size_of_test & TEST_MEDIUM) {
status = test_endian((size_t)800000);
nerrors += status < 0 ? 1 : 0;
status = test_transpose((size_t)1200, (size_t)1200);
@@ -1383,11 +1346,11 @@ main(int argc, char *argv[])
* TEST SAMPLING OPERATIONS
*-------------------------
*/
- if(size_of_test & TEST_SMALL) {
+ if (size_of_test & TEST_SMALL) {
status = test_sub_super((size_t)5, (size_t)10);
nerrors += status < 0 ? 1 : 0;
} /* end if */
- if(size_of_test & TEST_MEDIUM) {
+ if (size_of_test & TEST_MEDIUM) {
status = test_sub_super((size_t)480, (size_t)640);
nerrors += status < 0 ? 1 : 0;
} /* end if */
@@ -1396,11 +1359,11 @@ main(int argc, char *argv[])
* TEST ARRAY FILL OPERATIONS
*-------------------------
*/
- if(size_of_test & TEST_SMALL) {
+ if (size_of_test & TEST_SMALL) {
status = test_array_fill((size_t)1, (size_t)9);
nerrors += status < 0 ? 1 : 0;
} /* end if */
- if(size_of_test & TEST_MEDIUM) {
+ if (size_of_test & TEST_MEDIUM) {
status = test_array_fill((size_t)9, (size_t)257);
nerrors += status < 0 ? 1 : 0;
} /* end if */
@@ -1409,23 +1372,20 @@ main(int argc, char *argv[])
* TEST ARRAY OFFSET OPERATIONS
*-------------------------
*/
- if(size_of_test & TEST_SMALL) {
- status = test_array_offset_n_calc((size_t)20, (size_t)7, (size_t)11,
- (size_t)13);
+ if (size_of_test & TEST_SMALL) {
+ status = test_array_offset_n_calc((size_t)20, (size_t)7, (size_t)11, (size_t)13);
nerrors += status < 0 ? 1 : 0;
} /* end if */
- if(size_of_test & TEST_MEDIUM) {
- status = test_array_offset_n_calc((size_t)500, (size_t)71,
- (size_t)193, (size_t)347);
+ if (size_of_test & TEST_MEDIUM) {
+ status = test_array_offset_n_calc((size_t)500, (size_t)71, (size_t)193, (size_t)347);
nerrors += status < 0 ? 1 : 0;
} /* end if */
/*--- END OF TESTS ---*/
- if(nerrors) {
- HDprintf("***** %d HYPERSLAB TEST%s FAILED! *****\n", nerrors, 1
- == nerrors ? "" : "S");
- if(HDisatty(1))
+ if (nerrors) {
+ HDprintf("***** %d HYPERSLAB TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
+ if (HDisatty(1))
HDprintf("(Redirect output to a pager or a file to see debug output)\n");
HDexit(EXIT_FAILURE);
} /* end if */
@@ -1434,8 +1394,7 @@ main(int argc, char *argv[])
#ifdef H5_HAVE_THREADSAFE
H5close();
-#endif /* H5_HAVE_THREADSAFE */
+#endif /* H5_HAVE_THREADSAFE */
HDexit(EXIT_SUCCESS);
}
-