diff options
Diffstat (limited to 'hl/test/test_image.c')
-rw-r--r-- | hl/test/test_image.c | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 8a67883..b9f290e 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -71,11 +71,11 @@ main(void) if (nerrors) goto error; - HDprintf("All image tests passed.\n"); + printf("All image tests passed.\n"); return 0; error: - HDprintf("***** %d IMAGE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); + printf("***** %d IMAGE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); return 1; } @@ -111,14 +111,14 @@ test_simple(void) hsize_t pal_dims_out[2]; /* palette dimensions */ /* Allocate image buffers */ - buf1 = (unsigned char *)HDmalloc(WIDTH * HEIGHT); - HDassert(buf1); - buf2 = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3); - HDassert(buf2); - buf1_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT); - HDassert(buf1_out); - buf2_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3); - HDassert(buf2_out); + buf1 = (unsigned char *)malloc(WIDTH * HEIGHT); + assert(buf1); + buf2 = (unsigned char *)malloc(WIDTH * HEIGHT * 3); + assert(buf2); + buf1_out = (unsigned char *)malloc(WIDTH * HEIGHT); + assert(buf1_out); + buf2_out = (unsigned char *)malloc(WIDTH * HEIGHT * 3); + assert(buf2_out); /* create an image */ space = WIDTH * HEIGHT / PAL_ENTRIES; @@ -274,13 +274,13 @@ test_simple(void) */ if (buf1) - HDfree(buf1); + free(buf1); if (buf2) - HDfree(buf2); + free(buf2); if (buf1_out) - HDfree(buf1_out); + free(buf1_out); if (buf2_out) - HDfree(buf2_out); + free(buf2_out); /* Close the file. */ if (H5Fclose(fid) < 0) @@ -293,13 +293,13 @@ test_simple(void) /* error zone, gracefully close */ out: if (buf1) - HDfree(buf1); + free(buf1); if (buf2) - HDfree(buf2); + free(buf2); if (buf1_out) - HDfree(buf1_out); + free(buf1_out); if (buf2_out) - HDfree(buf2_out); + free(buf2_out); H5E_BEGIN_TRY { H5Fclose(fid); @@ -329,7 +329,7 @@ test_data(void) if ((fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - HDprintf("Testing read ascii image data and generate images\n"); + printf("Testing read ascii image data and generate images\n"); /*------------------------------------------------------------------------- * read 8bit image data @@ -480,7 +480,7 @@ test_data(void) goto out; /* Release memory buffer */ - HDfree(image_data); + free(image_data); return 0; @@ -488,7 +488,7 @@ test_data(void) out: /* Release memory buffer */ if (image_data) - HDfree(image_data); + free(image_data); H5E_BEGIN_TRY { @@ -531,16 +531,16 @@ test_generate(void) if ((fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - HDprintf("Testing read and process data and make indexed images\n"); + printf("Testing read and process data and make indexed images\n"); /*------------------------------------------------------------------------- * read data; the file data format is described below *------------------------------------------------------------------------- */ - f = HDfopen(data_file, "r"); + f = fopen(data_file, "r"); if (f == NULL) { - HDprintf("Could not find file %s. Try set $srcdir \n", data_file); + printf("Could not find file %s. Try set $srcdir \n", data_file); goto out; } @@ -579,12 +579,12 @@ test_generate(void) ! */ - if (HDfscanf(f, "%d %d %d", &imax, &jmax, &kmax) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%d %d %d", &imax, &jmax, &kmax) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if (HDfscanf(f, "%f %f %f", &valex, &xmin, &xmax) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%f %f %f", &valex, &xmin, &xmax) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ @@ -606,21 +606,21 @@ test_generate(void) if (n_elements > INT_MAX / (int)sizeof(float)) goto out; - data = (float *)HDmalloc((size_t)n_elements * sizeof(float)); + data = (float *)malloc((size_t)n_elements * sizeof(float)); if (NULL == data) goto out; - image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char)); + image_data = (unsigned char *)malloc((size_t)n_elements * sizeof(unsigned char)); if (NULL == image_data) goto out; for (i = 0; i < n_elements; i++) { - if (HDfscanf(f, "%f ", &value) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%f ", &value) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ data[i] = value; } - HDfclose(f); + fclose(f); f = NULL; /*------------------------------------------------------------------------- @@ -712,8 +712,8 @@ test_generate(void) goto out; /* Release memory buffers */ - HDfree(data); - HDfree(image_data); + free(data); + free(image_data); /* Indicate success */ return 0; @@ -722,9 +722,9 @@ test_generate(void) out: /* Release memory buffers */ if (data) - HDfree(data); + free(data); if (image_data) - HDfree(image_data); + free(image_data); H5E_BEGIN_TRY { @@ -732,7 +732,7 @@ out: } H5E_END_TRY if (f) - HDfclose(f); + fclose(f); H5_FAILED(); return retval; } @@ -773,38 +773,38 @@ read_data(const char *fname, /*IN*/ *------------------------------------------------------------------------- */ - if (NULL == (f = HDfopen(data_file, "r"))) { - HDprintf("Could not open file %s. Try set $srcdir \n", data_file); + if (NULL == (f = fopen(data_file, "r"))) { + printf("Could not open file %s. Try set $srcdir \n", data_file); goto out; } - if (HDfscanf(f, "%s", str) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%s", str) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if (HDfscanf(f, "%d", &color_planes) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%d", &color_planes) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if (HDfscanf(f, "%s", str) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%s", str) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if (HDfscanf(f, "%d", &h) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%d", &h) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if (HDfscanf(f, "%s", str) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%s", str) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ - if (HDfscanf(f, "%d", &w) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%d", &w) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ @@ -825,10 +825,10 @@ read_data(const char *fname, /*IN*/ /* Release the buffer, if it was previously allocated */ if (image_data) - HDfree(image_data); + free(image_data); /* Allocate the image data buffer */ - image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char)); + image_data = (unsigned char *)malloc((size_t)n_elements * sizeof(unsigned char)); if (NULL == image_data) goto out; @@ -837,8 +837,8 @@ read_data(const char *fname, /*IN*/ /* Read data elements */ for (i = 0; i < n_elements; i++) { - if (HDfscanf(f, "%d", &n) < 0 && HDferror(f)) { - HDprintf("fscanf error in file %s.\n", data_file); + if (fscanf(f, "%d", &n) < 0 && ferror(f)) { + printf("fscanf error in file %s.\n", data_file); goto out; } /* end if */ image_data[i] = (unsigned char)n; @@ -849,7 +849,7 @@ read_data(const char *fname, /*IN*/ out: if (f) - HDfclose(f); + fclose(f); return ret_val; } /* end read_data() */ @@ -889,40 +889,40 @@ read_palette(const char *fname, rgb_t *palette, size_t palette_size) return -1; /* open the input file */ - if (!(file = HDfopen(data_file, "r"))) { - HDprintf("Could not open file %s. Try set $srcdir \n", data_file); + if (!(file = fopen(data_file, "r"))) { + printf("Could not open file %s. Try set $srcdir \n", data_file); return -1; } /* read the file ident string */ - if (HDfgets(buffer, sizeof(buffer), file) == NULL) { - HDfclose(file); + if (fgets(buffer, sizeof(buffer), file) == NULL) { + fclose(file); return -1; } /* ensure it matches the palette file ident string */ - if (HDstrncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 && - HDstrncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0) { - HDfclose(file); + if (strncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 && + strncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0) { + fclose(file); return -1; } /* read the version string */ - if (HDfgets(buffer, sizeof(buffer), file) == NULL) { - HDfclose(file); + if (fgets(buffer, sizeof(buffer), file) == NULL) { + fclose(file); return -1; } /* ensure it matches the palette file version string */ - if (HDstrncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 && - HDstrncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0) { - HDfclose(file); + if (strncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 && + strncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0) { + fclose(file); return -1; } /* read the number of colors */ - if (HDfgets(buffer, sizeof(buffer), file) == NULL) { - HDfclose(file); + if (fgets(buffer, sizeof(buffer), file) == NULL) { + fclose(file); return -1; } @@ -930,27 +930,27 @@ read_palette(const char *fname, rgb_t *palette, size_t palette_size) check for missing version or number of colors in this case it reads the first entry */ - if (HDstrlen(buffer) > 4) { - HDfclose(file); + if (strlen(buffer) > 4) { + fclose(file); return -1; } - if (HDsscanf(buffer, "%u", &nentries) != 1) { - HDfclose(file); + if (sscanf(buffer, "%u", &nentries) != 1) { + fclose(file); return -1; } /* ensure there are a sensible number of colors in the palette */ if ((nentries > 256) || (nentries > palette_size)) { - HDfclose(file); + fclose(file); return (-1); } /* read the palette entries */ for (u = 0; u < nentries; u++) { /* extract the red, green and blue color components. */ - if (HDfscanf(file, "%u %u %u", &red, &green, &blue) != 3) { - HDfclose(file); + if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3) { + fclose(file); return -1; } /* store this palette entry */ @@ -960,7 +960,7 @@ read_palette(const char *fname, rgb_t *palette, size_t palette_size) } /* close file */ - HDfclose(file); + fclose(file); return (int)nentries; } |