summaryrefslogtreecommitdiffstats
path: root/hl/test
diff options
context:
space:
mode:
Diffstat (limited to 'hl/test')
-rw-r--r--hl/test/test_ds.c13
-rw-r--r--hl/test/test_image.c463
-rw-r--r--hl/test/test_lite.c1483
-rw-r--r--hl/test/test_table.c646
4 files changed, 1298 insertions, 1307 deletions
diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c
index cdc2c3b..6951619 100644
--- a/hl/test/test_ds.c
+++ b/hl/test/test_ds.c
@@ -45,14 +45,12 @@ static int read_data( const char* fname, int ndims, hsize_t *dims, float **buf )
#define DIM3_SIZE 2
#define DIM0 0
#define DIM1 1
-#define DIM2 2
#define DS_1_NAME "ds_a_1"
#define DS_11_NAME "ds_a_11"
#define DS_2_NAME "ds_a_2"
#define DS_21_NAME "ds_a_21"
#define DS_22_NAME "ds_a_22"
-#define DS_3_NAME "ds_a_3"
#define SCALE_1_NAME "Latitude set 0"
#define SCALE_11_NAME "Latitude set 1"
@@ -1415,6 +1413,10 @@ static int test_simple(void)
case 1: /* for DIM 1, we get no valid scales */
if(match_size!=0 && idx!=0)
goto out;
+ break;
+ default:
+ assert(0);
+ break;
}/*switch*/
}/*for*/
}
@@ -1523,7 +1525,7 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor
char *buf=NULL; /* data buffer */
size_t size;
int i;
- char *data=visitor_data;
+ char *data = (char*) visitor_data;
/* unused */
dset=dset;
@@ -2955,7 +2957,7 @@ static int test_errors2(void)
hsize_t dimd[2] = {3,3}; /* size of data dataset */
hsize_t dims[1] = {3}; /* size of scale dataset */
char lbuf[255]; /* label buffer */
- size_t label_len; /* label lenght */
+ ssize_t label_len; /* label lenght */
int scale_idx; /* scale index */
int nscales; /* number of scales in DIM */
int count; /* visitor data */
@@ -3137,4 +3139,5 @@ out:
} H5E_END_TRY;
H5_FAILED();
return FAIL;
-} \ No newline at end of file
+}
+
diff --git a/hl/test/test_image.c b/hl/test/test_image.c
index 2a365e2..426ae1d 100644
--- a/hl/test/test_image.c
+++ b/hl/test/test_image.c
@@ -1,17 +1,17 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+* Copyright by The HDF Group. *
+* Copyright by the Board of Trustees of the University of Illinois. *
+* All rights reserved. *
+* *
+* This file is part of HDF5. The full HDF5 copyright notice, including *
+* terms governing use, modification, and redistribution, is contained in *
+* the files COPYING and Copyright.html. COPYING can be found at the root *
+* of the source code distribution tree; Copyright.html can be found at the *
+* root level of an installed copy of the electronic HDF5 document set and *
+* is linked from the top-level documents page. It can also be found at *
+* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+* access to either file, you may request a copy from help@hdfgroup.org. *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
#include <string.h>
@@ -61,9 +61,9 @@ static int read_palette(const char* file_name, rgb_t *palette, size_t palette_si
unsigned char *image_data = NULL;
/*-------------------------------------------------------------------------
- * the main program
- *-------------------------------------------------------------------------
- */
+* the main program
+*-------------------------------------------------------------------------
+*/
int main(void)
{
@@ -83,9 +83,9 @@ error:
}
/*-------------------------------------------------------------------------
- * a simple test that generates images and palettes
- *-------------------------------------------------------------------------
- */
+* a simple test that generates images and palettes
+*-------------------------------------------------------------------------
+*/
static int test_simple(void)
{
@@ -94,6 +94,7 @@ static int test_simple(void)
hsize_t planes;
hid_t fid;
int i, j, n, space;
+ hsize_t u;
char interlace[20];
hssize_t npals;
@@ -142,7 +143,7 @@ static int test_simple(void)
}
}
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* define a palette, blue to red tones
*-------------------------------------------------------------------------
*/
@@ -156,7 +157,7 @@ static int test_simple(void)
/* Create a new HDF5 file using default properties. */
fid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* Indexed image test
*-------------------------------------------------------------------------
*/
@@ -182,9 +183,9 @@ static int test_simple(void)
if ( H5IMread_image( fid, IMAGE1_NAME, buf1_out ) < 0 )
goto out;
- for (i = 0; i < height*width*planes; i++)
+ for (u = 0; u < height*width*planes; u++)
{
- if ( buf1[i] != buf1_out[i] )
+ if ( buf1[u] != buf1_out[u] )
goto out;
}
@@ -192,7 +193,7 @@ static int test_simple(void)
PASSED();
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* True color image test
*-------------------------------------------------------------------------
*/
@@ -210,16 +211,16 @@ static int test_simple(void)
if ( H5IMread_image( fid, IMAGE2_NAME, buf2_out ) < 0 )
goto out;
- for (i = 0; i < height*width*planes; i++)
+ for (u = 0; u < height*width*planes; u++)
{
- if ( buf2[i] != buf2_out[i] )
+ if ( buf2[u] != buf2_out[u] )
goto out;
}
PASSED();
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* H5IMget_npalettes test
*-------------------------------------------------------------------------
*/
@@ -229,7 +230,7 @@ static int test_simple(void)
if ( H5IMget_npalettes( fid, IMAGE1_NAME, &npals ) < 0 )
goto out;
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* H5IMget_palette_info test
*-------------------------------------------------------------------------
*/
@@ -243,7 +244,7 @@ static int test_simple(void)
goto out;
}
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* H5IMget_palette test
*-------------------------------------------------------------------------
*/
@@ -257,7 +258,7 @@ static int test_simple(void)
goto out;
}
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* H5IMis_image test
*-------------------------------------------------------------------------
*/
@@ -268,7 +269,7 @@ static int test_simple(void)
if ( H5IMis_image( fid, IMAGE2_NAME ) < 0 )
goto out;
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* H5IMis_palette test
*-------------------------------------------------------------------------
*/
@@ -276,7 +277,7 @@ static int test_simple(void)
if ( H5IMis_palette( fid, PAL_NAME ) < 0 )
goto out;
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* end tests
*-------------------------------------------------------------------------
*/
@@ -301,9 +302,9 @@ out:
/*-------------------------------------------------------------------------
- * read sample realistic image data from ASCII files
- *-------------------------------------------------------------------------
- */
+* read sample realistic image data from ASCII files
+*-------------------------------------------------------------------------
+*/
static int test_data(void)
{
@@ -321,7 +322,7 @@ static int test_data(void)
printf("Testing read ascii image data and generate images\n");
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* read 8bit image data
*-------------------------------------------------------------------------
*/
@@ -341,7 +342,7 @@ static int test_data(void)
TESTING2("attaching palettes");
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* palette #1. rainbow palette. data is contained in "pal_rgb.h"
*-------------------------------------------------------------------------
*/
@@ -358,7 +359,7 @@ static int test_data(void)
if (H5IMlink_palette(fid,IMAGE1_NAME,PAL1_NAME)<0)
goto out;
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* palette #2. sepia palette.
* read a PAL file and attach the palette to the HDF5 file
*-------------------------------------------------------------------------
@@ -384,7 +385,7 @@ static int test_data(void)
if (H5IMlink_palette(fid,IMAGE1_NAME,PAL2_NAME)<0)
goto out;
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* palette #3. earth palette.
* read a PAL file and attach the palette to the HDF5 file
*-------------------------------------------------------------------------
@@ -413,7 +414,7 @@ static int test_data(void)
PASSED();
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* palette #4. blue-red
* make a palette whith blue to red colors
*-------------------------------------------------------------------------
@@ -434,7 +435,7 @@ static int test_data(void)
goto out;
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* true color image example with pixel interlace
*-------------------------------------------------------------------------
*/
@@ -469,7 +470,7 @@ static int test_data(void)
PASSED();
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
@@ -488,16 +489,16 @@ out:
}
- /*
- The following test provides an examples of how to generate HDF5 image data from
- floating point data. In the example we use real life topographic data
- (from the North American hemisphere). In the dataset sea values are represented
- as negative numbers and land values are represented as positive numbers.
- The example generates 3 HDF5 images, one that generates an image from all the values,
- another that generates an image from the land values and another that generates an
- image from the sea values.
- For the example we used data from MODB, the Mediterranean Oceanic Data Base
- http://modb.oce.ulg.ac.be/
+/*
+The following test provides an examples of how to generate HDF5 image data from
+floating point data. In the example we use real life topographic data
+(from the North American hemisphere). In the dataset sea values are represented
+as negative numbers and land values are represented as positive numbers.
+The example generates 3 HDF5 images, one that generates an image from all the values,
+another that generates an image from the land values and another that generates an
+image from the sea values.
+For the example we used data from MODB, the Mediterranean Oceanic Data Base
+http://modb.oce.ulg.ac.be/
*/
@@ -519,7 +520,7 @@ static int test_generate(void)
printf("Testing read and process data and make indexed images\n");
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* compose the name of the file to open, using the srcdir, if appropriate
*-------------------------------------------------------------------------
*/
@@ -543,40 +544,40 @@ static int test_generate(void)
return -1;
}
-/*
-!The first line of the ASCII file contains the dimension of the array :
-! IMAX, JMAX, KMAX. The integers are stored with the FORTRAN format I5.
-!The second line contains the exclusion value, the minimum and the maximum value of this
-! file. These numbers are stored with the FORTRAN format E12.5.
-! The remaining lines contains the data of the array, with 5 numbers per line
-! (except the last line for each I-line).
-! The array is stored in horizontal slices from sea surface to sea bottom and from
-! north to south. So the indexes go from :
-!
-! DO K = KMAX to 1
-! DO J = JMAX to 1
-! DO I = 1 to IMAX
-! read
-! OD
-! OD
-! OD
-!
-! ____________________________
-! / /| (imax,jmax,kmax)
-! / sea surface / |
-! / / |
-! /__________________________ / |
-! | | |
-! | | | (imax,jmax,1) n
-! | | / /
-! | | / /
-! ^ j | | / w <-----o-----> e
-! k | / |__________________________|/ /
-! | / (imax,1,1) /
-! |----------> s
-! i
-!
-*/
+ /*
+ !The first line of the ASCII file contains the dimension of the array :
+ ! IMAX, JMAX, KMAX. The integers are stored with the FORTRAN format I5.
+ !The second line contains the exclusion value, the minimum and the maximum value of this
+ ! file. These numbers are stored with the FORTRAN format E12.5.
+ ! The remaining lines contains the data of the array, with 5 numbers per line
+ ! (except the last line for each I-line).
+ ! The array is stored in horizontal slices from sea surface to sea bottom and from
+ ! north to south. So the indexes go from :
+ !
+ ! DO K = KMAX to 1
+ ! DO J = JMAX to 1
+ ! DO I = 1 to IMAX
+ ! read
+ ! OD
+ ! OD
+ ! OD
+ !
+ ! ____________________________
+ ! / /| (imax,jmax,kmax)
+ ! / sea surface / |
+ ! / / |
+ ! /__________________________ / |
+ ! | | |
+ ! | | | (imax,jmax,1) n
+ ! | | / /
+ ! | | / /
+ ! ^ j | | / w <-----o-----> e
+ ! k | / |__________________________|/ /
+ ! | / (imax,1,1) /
+ ! |----------> s
+ ! i
+ !
+ */
fscanf( f, "%d %d %d", &imax, &jmax, &kmax );
@@ -592,7 +593,7 @@ static int test_generate(void)
}
fclose( f );
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* transform the data from floating point to unsigned char
* we are processing all the data here
*-------------------------------------------------------------------------
@@ -611,7 +612,7 @@ static int test_generate(void)
PASSED();
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* transform the data from floating point to unsigned char
* here we just process the land data
*-------------------------------------------------------------------------
@@ -633,7 +634,7 @@ static int test_generate(void)
PASSED();
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* transform the data from floating point to unsigned char
* here we just process the sea data
*-------------------------------------------------------------------------
@@ -655,7 +656,7 @@ static int test_generate(void)
PASSED();
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* make a palette and attach it to the datasets
*-------------------------------------------------------------------------
*/
@@ -677,7 +678,7 @@ static int test_generate(void)
PASSED();
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* close
*-------------------------------------------------------------------------
*/
@@ -697,25 +698,25 @@ out:
/*-------------------------------------------------------------------------
- * read_data
- * utility function to read ASCII image data
- * the files have a header of the type
- *
- * components
- * n
- * height
- * n
- * width
- * n
- *
- * followed by the image data
- *
- *-------------------------------------------------------------------------
- */
+* read_data
+* utility function to read ASCII image data
+* the files have a header of the type
+*
+* components
+* n
+* height
+* n
+* width
+* n
+*
+* followed by the image data
+*
+*-------------------------------------------------------------------------
+*/
static int read_data( const char* fname, /*IN*/
- hsize_t *width, /*OUT*/
- hsize_t *height /*OUT*/ )
+ hsize_t *width, /*OUT*/
+ hsize_t *height /*OUT*/ )
{
int i, n;
int color_planes;
@@ -725,7 +726,7 @@ static int read_data( const char* fname, /*IN*/
char *srcdir = getenv("srcdir"); /* the source directory */
char data_file[512]=""; /* buffer to hold name of existing data file */
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* compose the name of the file to open, using "srcdir", if appropriate
*-------------------------------------------------------------------------
*/
@@ -737,7 +738,7 @@ static int read_data( const char* fname, /*IN*/
}
strcat(data_file,fname);
- /*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
* read
*-------------------------------------------------------------------------
*/
@@ -781,17 +782,17 @@ static int read_data( const char* fname, /*IN*/
/*-------------------------------------------------------------------------
- * read_palette
- * Read an ASCII palette file .PAL into an array
- * the files have a header of the type
- *
- * Parameters:
- * fname - name of file to read.
- * palette - array of rgb_t to store the read palette.
- * palette_size - number of elements in 'palette' array
- *
- *-------------------------------------------------------------------------
- */
+* read_palette
+* Read an ASCII palette file .PAL into an array
+* the files have a header of the type
+*
+* Parameters:
+* fname - name of file to read.
+* palette - array of rgb_t to store the read palette.
+* palette_size - number of elements in 'palette' array
+*
+*-------------------------------------------------------------------------
+*/
#define STRING_JASC "JASC-PAL"
@@ -803,118 +804,118 @@ static int read_palette(const char* fname,
rgb_t *palette,
size_t palette_size)
{
- FILE *file;
- char buffer[80];
- unsigned u;
- unsigned int red;
- unsigned int green;
- unsigned int blue;
- unsigned nentries;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]; /* buffer to hold name of existing data file */
+ FILE *file;
+ char buffer[80];
+ unsigned u;
+ unsigned int red;
+ unsigned int green;
+ unsigned int blue;
+ unsigned nentries;
+ char *srcdir = getenv("srcdir"); /* the source directory */
+ char data_file[512]; /* buffer to hold name of existing data file */
-/*-------------------------------------------------------------------------
- * compose the name of the file to open, using "srcdir", if appropriate
- *-------------------------------------------------------------------------
- */
- strcpy(data_file, "");
- if (srcdir)
- {
- strcpy(data_file, srcdir);
- strcat(data_file, "/");
- }
- strcat(data_file,fname);
-
- /* ensure the given palette is valid */
- if (!palette)
- return -1;
-
- /* open the input 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 (fgets(buffer, sizeof(buffer), file) == NULL)
- {
- fclose(file);
- return -1;
- }
-
- /* ensure it matches the palette file ident string */
- 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 (fgets(buffer, sizeof(buffer), file) == NULL)
- {
- fclose(file);
- return -1;
- }
-
- /* ensure it matches the palette file version string */
- 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 (fgets(buffer, sizeof(buffer), file) == NULL)
- {
- fclose(file);
- return -1;
- }
-
-
- /* extract the number of colors.
+ /*-------------------------------------------------------------------------
+ * compose the name of the file to open, using "srcdir", if appropriate
+ *-------------------------------------------------------------------------
+ */
+ strcpy(data_file, "");
+ if (srcdir)
+ {
+ strcpy(data_file, srcdir);
+ strcat(data_file, "/");
+ }
+ strcat(data_file,fname);
+
+ /* ensure the given palette is valid */
+ if (!palette)
+ return -1;
+
+ /* open the input 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 (fgets(buffer, sizeof(buffer), file) == NULL)
+ {
+ fclose(file);
+ return -1;
+ }
+
+ /* ensure it matches the palette file ident string */
+ 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 (fgets(buffer, sizeof(buffer), file) == NULL)
+ {
+ fclose(file);
+ return -1;
+ }
+
+ /* ensure it matches the palette file version string */
+ 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 (fgets(buffer, sizeof(buffer), file) == NULL)
+ {
+ fclose(file);
+ return -1;
+ }
+
+
+ /* extract the number of colors.
check for missing version or number of colors
in this case it reads the first entry
*/
- if ( strlen( buffer ) > 4 )
- {
- fclose(file);
- return -1;
- }
-
- 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))
- {
- fclose(file);
- return(-1);
- }
-
- /* read the palette entries */
- for (u = 0; u < nentries; u++)
- {
- /* extract the red, green and blue color components. */
- if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3)
- {
- fclose(file);
- return -1;
- }
- /* store this palette entry */
- palette[u].r = (unsigned char)red;
- palette[u].g = (unsigned char)green;
- palette[u].b = (unsigned char)blue;
- }
-
- /* close file */
- fclose(file);
-
- return nentries;
+ if ( strlen( buffer ) > 4 )
+ {
+ fclose(file);
+ return -1;
+ }
+
+ 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))
+ {
+ fclose(file);
+ return(-1);
+ }
+
+ /* read the palette entries */
+ for (u = 0; u < nentries; u++)
+ {
+ /* extract the red, green and blue color components. */
+ if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3)
+ {
+ fclose(file);
+ return -1;
+ }
+ /* store this palette entry */
+ palette[u].r = (unsigned char)red;
+ palette[u].g = (unsigned char)green;
+ palette[u].b = (unsigned char)blue;
+ }
+
+ /* close file */
+ fclose(file);
+
+ return nentries;
}
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index 239ad60..6de2e31 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -1,17 +1,17 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+* Copyright by The HDF Group. *
+* Copyright by the Board of Trustees of the University of Illinois. *
+* All rights reserved. *
+* *
+* This file is part of HDF5. The full HDF5 copyright notice, including *
+* terms governing use, modification, and redistribution, is contained in *
+* the files COPYING and Copyright.html. COPYING can be found at the root *
+* of the source code distribution tree; Copyright.html can be found at the *
+* root level of an installed copy of the electronic HDF5 document set and *
+* is linked from the top-level documents page. It can also be found at *
+* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+* access to either file, you may request a copy from help@hdfgroup.org. *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
#include <string.h>
@@ -45,358 +45,355 @@
#define ATTR10_NAME "attr float"
#define ATTR11_NAME "attr double"
-/*Initial input buffer size for testing H5LTtext_to_dtype()*/
-#define BUF_SIZE 1024
-
static herr_t make_attributes( hid_t loc_id, const char* obj_name );
/*-------------------------------------------------------------------------
- * test dataset functions
- *-------------------------------------------------------------------------
- */
+* test dataset functions
+*-------------------------------------------------------------------------
+*/
static int test_dsets( void )
{
- int rank = 2;
- hsize_t dims[2] = {2,3};
- hid_t file_id;
- hid_t dataset_id;
- char data_char_in[DIM] = {1,2,3,4,5,6};
- char data_char_out[DIM];
- short data_short_in[DIM] = {1,2,3,4,5,6};
- short data_short_out[DIM];
- int data_int_in[DIM] = {1,2,3,4,5,6};
- int data_int_out[DIM];
- long data_long_in[DIM] = {1,2,3,4,5,6};
- long data_long_out[DIM];
- float data_float_in[DIM] = {1,2,3,4,5,6};
- float data_float_out[DIM];
- double data_double_in[DIM] = {1,2,3,4,5,6};
- double data_double_out[DIM];
- const char *data_string_in = "This is a string";
- char data_string_out[20];
- int i;
-
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
+ int rank = 2;
+ hsize_t dims[2] = {2,3};
+ hid_t file_id;
+ hid_t dataset_id;
+ char data_char_in[DIM] = {1,2,3,4,5,6};
+ char data_char_out[DIM];
+ short data_short_in[DIM] = {1,2,3,4,5,6};
+ short data_short_out[DIM];
+ int data_int_in[DIM] = {1,2,3,4,5,6};
+ int data_int_out[DIM];
+ long data_long_in[DIM] = {1,2,3,4,5,6};
+ long data_long_out[DIM];
+ float data_float_in[DIM] = {1,2,3,4,5,6};
+ float data_float_out[DIM];
+ double data_double_in[DIM] = {1,2,3,4,5,6};
+ double data_double_out[DIM];
+ const char *data_string_in = "This is a string";
+ char data_string_out[20];
+ int i;
-/*-------------------------------------------------------------------------
- * H5LTmake_dataset test
- *-------------------------------------------------------------------------
- */
- TESTING("H5LTmake_dataset");
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate( FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
- /* Make dataset */
- if ( H5LTmake_dataset( file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in ) < 0 )
- goto out;
+ /*-------------------------------------------------------------------------
+ * H5LTmake_dataset test
+ *-------------------------------------------------------------------------
+ */
- /* Read dataset using the basic HDF5 API */
+ TESTING("H5LTmake_dataset");
- if ( ( dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT) ) < 0 )
- goto out;
+ /* Make dataset */
+ if ( H5LTmake_dataset( file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in ) < 0 )
+ goto out;
- if ( H5Dread ( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out ) < 0 )
- goto out;
+ /* Read dataset using the basic HDF5 API */
- if ( H5Dclose( dataset_id ) < 0 )
- goto out;
+ if ( ( dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT) ) < 0 )
+ goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
- goto out;
- }
- }
+ if ( H5Dread ( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out ) < 0 )
+ goto out;
- PASSED();
+ if ( H5Dclose( dataset_id ) < 0 )
+ goto out;
-/*-------------------------------------------------------------------------
- * read using the LT function H5LTread_dataset
- *-------------------------------------------------------------------------
- */
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_int_in[i] != data_int_out[i] ) {
+ goto out;
+ }
+ }
- TESTING("H5LTread_dataset");
+ PASSED();
- if ( H5LTread_dataset( file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out ) < 0 )
- goto out;
+ /*-------------------------------------------------------------------------
+ * read using the LT function H5LTread_dataset
+ *-------------------------------------------------------------------------
+ */
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
- goto out;
- }
- }
+ TESTING("H5LTread_dataset");
- PASSED();
+ if ( H5LTread_dataset( file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out ) < 0 )
+ goto out;
-/*-------------------------------------------------------------------------
- * test the H5LTmake_dataset_ functions
- *-------------------------------------------------------------------------
- */
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_int_in[i] != data_int_out[i] ) {
+ goto out;
+ }
+ }
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTmake_dataset_char
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * test the H5LTmake_dataset_ functions
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTmake_dataset_char");
- /* Make dataset char */
- if ( H5LTmake_dataset_char( file_id, DSET1_NAME, rank, dims, data_char_in ) < 0 )
- goto out;
+ /*-------------------------------------------------------------------------
+ * H5LTmake_dataset_char
+ *-------------------------------------------------------------------------
+ */
- /* Read dataset */
- if ( H5LTread_dataset( file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out ) < 0 )
- goto out;
+ TESTING("H5LTmake_dataset_char");
- for (i = 0; i < DIM; i++)
- {
- if ( data_char_in[i] != data_char_out[i] ) {
- goto out;
- }
- }
+ /* Make dataset char */
+ if ( H5LTmake_dataset_char( file_id, DSET1_NAME, rank, dims, data_char_in ) < 0 )
+ goto out;
+
+ /* Read dataset */
+ if ( H5LTread_dataset( file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out ) < 0 )
+ goto out;
- /* Read dataset */
- if ( H5LTread_dataset_char( file_id, DSET1_NAME, data_char_out ) < 0 )
- goto out;
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_char_in[i] != data_char_out[i] ) {
+ goto out;
+ }
+ }
- for (i = 0; i < DIM; i++)
- {
- if ( data_char_in[i] != data_char_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset_char( file_id, DSET1_NAME, data_char_out ) < 0 )
+ goto out;
- PASSED();
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_char_in[i] != data_char_out[i] ) {
+ goto out;
+ }
+ }
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTmake_dataset_short
- *-------------------------------------------------------------------------
- */
- TESTING("H5LTmake_dataset_short");
+ /*-------------------------------------------------------------------------
+ * H5LTmake_dataset_short
+ *-------------------------------------------------------------------------
+ */
- /* Make dataset short */
- if ( H5LTmake_dataset_short( file_id, DSET2_NAME, rank, dims, data_short_in ) < 0 )
- goto out;
+ TESTING("H5LTmake_dataset_short");
- /* Read dataset */
- if ( H5LTread_dataset( file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out ) < 0 )
- goto out;
+ /* Make dataset short */
+ if ( H5LTmake_dataset_short( file_id, DSET2_NAME, rank, dims, data_short_in ) < 0 )
+ goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_short_in[i] != data_short_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset( file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out ) < 0 )
+ goto out;
- /* Read dataset */
- if ( H5LTread_dataset_short( file_id, DSET2_NAME, data_short_out ) < 0 )
- goto out;
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_short_in[i] != data_short_out[i] ) {
+ goto out;
+ }
+ }
- for (i = 0; i < DIM; i++)
- {
- if ( data_short_in[i] != data_short_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset_short( file_id, DSET2_NAME, data_short_out ) < 0 )
+ goto out;
- PASSED();
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_short_in[i] != data_short_out[i] ) {
+ goto out;
+ }
+ }
-/*-------------------------------------------------------------------------
- * H5LTmake_dataset_int
- *-------------------------------------------------------------------------
- */
+ PASSED();
- TESTING("H5LTmake_dataset_int");
+ /*-------------------------------------------------------------------------
+ * H5LTmake_dataset_int
+ *-------------------------------------------------------------------------
+ */
- /* Make dataset int */
- if ( H5LTmake_dataset_int( file_id, DSET3_NAME, rank, dims, data_int_in ) < 0 )
- goto out;
+ TESTING("H5LTmake_dataset_int");
- /* Read dataset */
- if ( H5LTread_dataset( file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out ) < 0 )
- goto out;
+ /* Make dataset int */
+ if ( H5LTmake_dataset_int( file_id, DSET3_NAME, rank, dims, data_int_in ) < 0 )
+ goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset( file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out ) < 0 )
+ goto out;
- /* Read dataset */
- if ( H5LTread_dataset_int( file_id, DSET3_NAME, data_int_out ) < 0 )
- goto out;
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_int_in[i] != data_int_out[i] ) {
+ goto out;
+ }
+ }
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset_int( file_id, DSET3_NAME, data_int_out ) < 0 )
+ goto out;
- PASSED();
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_int_in[i] != data_int_out[i] ) {
+ goto out;
+ }
+ }
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTmake_dataset_long
- *-------------------------------------------------------------------------
- */
- TESTING("H5LTmake_dataset_long");
+ /*-------------------------------------------------------------------------
+ * H5LTmake_dataset_long
+ *-------------------------------------------------------------------------
+ */
- /* Make dataset long */
- if ( H5LTmake_dataset_long( file_id, DSET4_NAME, rank, dims, data_long_in ) < 0 )
- goto out;
+ TESTING("H5LTmake_dataset_long");
- /* Read dataset */
- if ( H5LTread_dataset( file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out ) < 0 )
- goto out;
+ /* Make dataset long */
+ if ( H5LTmake_dataset_long( file_id, DSET4_NAME, rank, dims, data_long_in ) < 0 )
+ goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_long_in[i] != data_long_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset( file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out ) < 0 )
+ goto out;
- /* Read dataset */
- if ( H5LTread_dataset_long( file_id, DSET4_NAME, data_long_out ) < 0 )
- goto out;
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_long_in[i] != data_long_out[i] ) {
+ goto out;
+ }
+ }
- for (i = 0; i < DIM; i++)
- {
- if ( data_long_in[i] != data_long_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset_long( file_id, DSET4_NAME, data_long_out ) < 0 )
+ goto out;
- PASSED();
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_long_in[i] != data_long_out[i] ) {
+ goto out;
+ }
+ }
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTmake_dataset_float
- *-------------------------------------------------------------------------
- */
- TESTING("H5LTmake_dataset_float");
+ /*-------------------------------------------------------------------------
+ * H5LTmake_dataset_float
+ *-------------------------------------------------------------------------
+ */
- /* Make dataset float */
- if ( H5LTmake_dataset_float( file_id, DSET5_NAME, rank, dims, data_float_in ) < 0 )
- goto out;
+ TESTING("H5LTmake_dataset_float");
- /* Read dataset */
- if ( H5LTread_dataset( file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out ) < 0 )
- goto out;
+ /* Make dataset float */
+ if ( H5LTmake_dataset_float( file_id, DSET5_NAME, rank, dims, data_float_in ) < 0 )
+ goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_float_in[i] != data_float_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset( file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out ) < 0 )
+ goto out;
- /* Read dataset */
- if ( H5LTread_dataset_float( file_id, DSET5_NAME, data_float_out ) < 0 )
- goto out;
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_float_in[i] != data_float_out[i] ) {
+ goto out;
+ }
+ }
- for (i = 0; i < DIM; i++)
- {
- if ( data_float_in[i] != data_float_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset_float( file_id, DSET5_NAME, data_float_out ) < 0 )
+ goto out;
- PASSED();
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_float_in[i] != data_float_out[i] ) {
+ goto out;
+ }
+ }
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTmake_dataset_double
- *-------------------------------------------------------------------------
- */
- TESTING("H5LTmake_dataset_double");
+ /*-------------------------------------------------------------------------
+ * H5LTmake_dataset_double
+ *-------------------------------------------------------------------------
+ */
- /* Make dataset double */
- if ( H5LTmake_dataset_double( file_id, DSET6_NAME, rank, dims, data_double_in ) < 0 )
- goto out;
+ TESTING("H5LTmake_dataset_double");
- /* Read dataset */
- if ( H5LTread_dataset( file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out ) < 0 )
- goto out;
+ /* Make dataset double */
+ if ( H5LTmake_dataset_double( file_id, DSET6_NAME, rank, dims, data_double_in ) < 0 )
+ goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_double_in[i] != data_double_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset( file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out ) < 0 )
+ goto out;
- /* Read dataset */
- if ( H5LTread_dataset_double( file_id, DSET6_NAME, data_double_out ) < 0 )
- goto out;
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_double_in[i] != data_double_out[i] ) {
+ goto out;
+ }
+ }
- for (i = 0; i < DIM; i++)
- {
- if ( data_double_in[i] != data_double_out[i] ) {
- goto out;
- }
- }
+ /* Read dataset */
+ if ( H5LTread_dataset_double( file_id, DSET6_NAME, data_double_out ) < 0 )
+ goto out;
- PASSED();
+ for (i = 0; i < DIM; i++)
+ {
+ if ( data_double_in[i] != data_double_out[i] ) {
+ goto out;
+ }
+ }
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTmake_dataset_string
- *-------------------------------------------------------------------------
- */
- TESTING("H5LTmake_dataset_string");
+ /*-------------------------------------------------------------------------
+ * H5LTmake_dataset_string
+ *-------------------------------------------------------------------------
+ */
- /* Make dataset string */
- if ( H5LTmake_dataset_string(file_id,DSET7_NAME,data_string_in) < 0 )
- goto out;
+ TESTING("H5LTmake_dataset_string");
- /* Read dataset */
- if ( H5LTread_dataset_string(file_id,DSET7_NAME,data_string_out) < 0 )
- goto out;
+ /* Make dataset string */
+ if ( H5LTmake_dataset_string(file_id,DSET7_NAME,data_string_in) < 0 )
+ goto out;
- if ( strcmp(data_string_in,data_string_out) != 0 )
- goto out;
+ /* Read dataset */
+ if ( H5LTread_dataset_string(file_id,DSET7_NAME,data_string_out) < 0 )
+ goto out;
+ if ( strcmp(data_string_in,data_string_out) != 0 )
+ goto out;
-/*-------------------------------------------------------------------------
- * end tests
- *-------------------------------------------------------------------------
- */
- /* Close the file. */
- H5Fclose( file_id );
+ /*-------------------------------------------------------------------------
+ * end tests
+ *-------------------------------------------------------------------------
+ */
+
+ /* Close the file. */
+ H5Fclose( file_id );
- PASSED();
+ PASSED();
- return 0;
+ return 0;
out:
- /* Close the file. */
- H5_FAILED();
- return -1;
+ /* Close the file. */
+ H5_FAILED();
+ return -1;
}
/*-------------------------------------------------------------------------
- * test attribute functions
- *-------------------------------------------------------------------------
- */
+* test attribute functions
+*-------------------------------------------------------------------------
+*/
static int test_attr(void)
{
@@ -477,575 +474,575 @@ out:
}
/*-------------------------------------------------------------------------
- * make_attributes
- *-------------------------------------------------------------------------
- */
+* make_attributes
+*-------------------------------------------------------------------------
+*/
static herr_t make_attributes( hid_t loc_id, const char* obj_name )
{
- int rank_out;
- hsize_t *dims_out = 0;
- H5T_class_t type_class;
- size_t type_size;
- int i;
-
- char attr_str_in[] = {"My attribute"};
- char attr_str_out[20];
- char attr_char_in[5] = {1,2,3,4,5};
- char attr_char_out[5];
- short attr_short_in[5] = {1,2,3,4,5};
- short attr_short_out[5];
- int attr_int_in[5] = {1,2,3,4,5};
- int attr_int_out[5];
- long attr_long_in[5] = {1,2,3,4,5};
- long attr_long_out[5];
- float attr_float_in[5] = {1,2,3,4,5};
- float attr_float_out[5];
- double attr_double_in[5] = {1,2,3,4,5};
- double attr_double_out[5];
- unsigned char attr_uchar_in[5] = {1,2,3,4,5};
- unsigned char attr_uchar_out[5];
- unsigned short attr_ushort_in[5] = {1,2,3,4,5};
- unsigned short attr_ushort_out[5];
- unsigned int attr_uint_in[5] = {1,2,3,4,5};
- unsigned int attr_uint_out[5];
- unsigned long attr_ulong_in[5] = {1,2,3,4,5};
- unsigned long attr_ulong_out[5];
+ int rank_out;
+ hsize_t *dims_out = 0;
+ H5T_class_t type_class;
+ size_t type_size;
+ int i;
+
+ char attr_str_in[] = {"My attribute"};
+ char attr_str_out[20];
+ char attr_char_in[5] = {1,2,3,4,5};
+ char attr_char_out[5];
+ short attr_short_in[5] = {1,2,3,4,5};
+ short attr_short_out[5];
+ int attr_int_in[5] = {1,2,3,4,5};
+ int attr_int_out[5];
+ long attr_long_in[5] = {1,2,3,4,5};
+ long attr_long_out[5];
+ float attr_float_in[5] = {1,2,3,4,5};
+ float attr_float_out[5];
+ double attr_double_in[5] = {1,2,3,4,5};
+ double attr_double_out[5];
+ unsigned char attr_uchar_in[5] = {1,2,3,4,5};
+ unsigned char attr_uchar_out[5];
+ unsigned short attr_ushort_in[5] = {1,2,3,4,5};
+ unsigned short attr_ushort_out[5];
+ unsigned int attr_uint_in[5] = {1,2,3,4,5};
+ unsigned int attr_uint_out[5];
+ unsigned long attr_ulong_in[5] = {1,2,3,4,5};
+ unsigned long attr_ulong_out[5];
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_string test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_string test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_string");
+ TESTING("H5LTset_attribute_string");
- /* Set the attribute */
- if ( H5LTset_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_in ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_in ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_string test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_string test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_string");
+ TESTING("H5LTget_attribute_string");
- /* Get the attribute */
- if ( H5LTget_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_out ) < 0 )
+ return -1;
- if ( strcmp( attr_str_in, attr_str_out ) != 0 )
- {
- return -1;
- }
+ if ( strcmp( attr_str_in, attr_str_out ) != 0 )
+ {
+ return -1;
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_char test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_char test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_char");
+ TESTING("H5LTset_attribute_char");
- /* Set the attribute */
- if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_char test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_char test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_char");
+ TESTING("H5LTget_attribute_char");
- /* Get the attribute */
- if ( H5LTget_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_char_in[i] != attr_char_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_char_in[i] != attr_char_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_char_in[i] != attr_char_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_char_in[i] != attr_char_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_short test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_short test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_short");
+ TESTING("H5LTset_attribute_short");
- /* Set the attribute */
- if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_short test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_short test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_short");
+ TESTING("H5LTget_attribute_short");
- /* Get the attribute */
- if ( H5LTget_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_short_in[i] != attr_short_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_short_in[i] != attr_short_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_short_in[i] != attr_short_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_short_in[i] != attr_short_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_int test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_int test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_int");
+ TESTING("H5LTset_attribute_int");
- /* Set the attribute */
- if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_int test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_int test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_int");
+ TESTING("H5LTget_attribute_int");
- /* Get the attribute */
- if ( H5LTget_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_int_in[i] != attr_int_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_int_in[i] != attr_int_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_long test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_long test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_long");
+ TESTING("H5LTset_attribute_long");
- /* Set the attribute */
- if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_long test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_long test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_long");
+ TESTING("H5LTget_attribute_long");
- /* Get the attribute */
- if ( H5LTget_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_long_in[i] != attr_long_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_long_in[i] != attr_long_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_long_in[i] != attr_long_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_long_in[i] != attr_long_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_uchar test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_uchar test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_uchar");
+ TESTING("H5LTset_attribute_uchar");
- /* Set the attribute */
- if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_uchar test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_uchar test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_uchar");
+ TESTING("H5LTget_attribute_uchar");
- /* Get the attribute */
- if ( H5LTget_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uchar_in[i] != attr_uchar_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_uchar_in[i] != attr_uchar_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uchar_in[i] != attr_uchar_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_uchar_in[i] != attr_uchar_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_ushort test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_ushort test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_ushort");
+ TESTING("H5LTset_attribute_ushort");
- /* Set the attribute */
- if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_ushort test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_ushort test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_ushort");
+ TESTING("H5LTget_attribute_ushort");
- /* Get the attribute */
- if ( H5LTget_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ushort_in[i] != attr_ushort_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_ushort_in[i] != attr_ushort_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ushort_in[i] != attr_ushort_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_ushort_in[i] != attr_ushort_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_int test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_int test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_uint");
+ TESTING("H5LTset_attribute_uint");
- /* Set the attribute */
- if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_int test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_int test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_uint");
+ TESTING("H5LTget_attribute_uint");
- /* Get the attribute */
- if ( H5LTget_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uint_in[i] != attr_uint_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_uint_in[i] != attr_uint_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uint_in[i] != attr_uint_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_uint_in[i] != attr_uint_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_ulong test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_ulong test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_ulong");
+ TESTING("H5LTset_attribute_ulong");
- /* Set the attribute */
- if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_long test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_long test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_ulong");
+ TESTING("H5LTget_attribute_ulong");
- /* Get the attribute */
- if ( H5LTget_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ulong_in[i] != attr_ulong_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_ulong_in[i] != attr_ulong_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ulong_in[i] != attr_ulong_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_ulong_in[i] != attr_ulong_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_float test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_float test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_float");
+ TESTING("H5LTset_attribute_float");
- /* Set the attribute */
- if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_float test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_float test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_float");
+ TESTING("H5LTget_attribute_float");
- /* Get the attribute */
- if ( H5LTget_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_float_in[i] != attr_float_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_float_in[i] != attr_float_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_float_in[i] != attr_float_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_float_in[i] != attr_float_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTset_attribute_double test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTset_attribute_double test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTset_attribute_double");
+ TESTING("H5LTset_attribute_double");
- /* Set the attribute */
- if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 )
- return -1;
+ /* Set the attribute */
+ if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 )
+ return -1;
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_double test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_double test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_double");
+ TESTING("H5LTget_attribute_double");
- /* Get the attribute */
- if ( H5LTget_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_double_in[i] != attr_double_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_double_in[i] != attr_double_out[i] ) {
+ return -1;
+ }
+ }
- /* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out ) < 0 )
- return -1;
+ /* Get the attribute */
+ if ( H5LTget_attribute( loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out ) < 0 )
+ return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_double_in[i] != attr_double_out[i] ) {
- return -1;
- }
- }
+ for (i = 0; i < 5; i++)
+ {
+ if ( attr_double_in[i] != attr_double_out[i] ) {
+ return -1;
+ }
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_ndims test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_ndims test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_ndims");
+ TESTING("H5LTget_attribute_ndims");
- if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 )
- return -1;
+ if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 )
+ return -1;
- if ( rank_out != 1 ) {
- return -1;
- }
+ if ( rank_out != 1 ) {
+ return -1;
+ }
- PASSED();
+ PASSED();
-/*-------------------------------------------------------------------------
- * H5LTget_attribute_info test
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5LTget_attribute_info test
+ *-------------------------------------------------------------------------
+ */
- TESTING("H5LTget_attribute_info");
+ TESTING("H5LTget_attribute_info");
- dims_out = malloc( sizeof(hsize_t) * rank_out );
+ dims_out = (hsize_t*) malloc( sizeof(hsize_t) * rank_out );
- if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class,
- &type_size) < 0 )
- return -1;
+ if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class,
+ &type_size) < 0 )
+ return -1;
- for (i = 0; i < rank_out; i++)
- {
- if ( dims_out[i] != 5 ) {
- return -1;
- }
- }
+ for (i = 0; i < rank_out; i++)
+ {
+ if ( dims_out[i] != 5 ) {
+ return -1;
+ }
+ }
- if ( type_class != H5T_INTEGER ) {
- return -1;
- }
+ if ( type_class != H5T_INTEGER ) {
+ return -1;
+ }
- if ( dims_out )
- free( dims_out );
+ if ( dims_out )
+ free( dims_out );
- PASSED();
+ PASSED();
- return 0;
+ return 0;
}
/*-------------------------------------------------------------------------
- * subroutine for test_text_dtype(): test_integers().
- *-------------------------------------------------------------------------
- */
+* subroutine for test_text_dtype(): test_integers().
+*-------------------------------------------------------------------------
+*/
static int test_integers(void)
{
hid_t dtype;
@@ -1094,9 +1091,9 @@ out:
}
/*-------------------------------------------------------------------------
- * subroutine for test_text_dtype(): test_fps().
- *-------------------------------------------------------------------------
- */
+* subroutine for test_text_dtype(): test_fps().
+*-------------------------------------------------------------------------
+*/
static int test_fps(void)
{
hid_t dtype;
@@ -1145,9 +1142,9 @@ out:
}
/*-------------------------------------------------------------------------
- * subroutine for test_text_dtype(): test_strings().
- *-------------------------------------------------------------------------
- */
+* subroutine for test_text_dtype(): test_strings().
+*-------------------------------------------------------------------------
+*/
static int test_strings(void)
{
hid_t dtype;
@@ -1231,9 +1228,9 @@ out:
}
/*-------------------------------------------------------------------------
- * subroutine for test_text_dtype(): test_opaques().
- *-------------------------------------------------------------------------
- */
+* subroutine for test_text_dtype(): test_opaques().
+*-------------------------------------------------------------------------
+*/
static int test_opaques(void)
{
hid_t dtype;
@@ -1280,9 +1277,9 @@ out:
}
/*-------------------------------------------------------------------------
- * subroutine for test_text_dtype(): test_enums().
- *-------------------------------------------------------------------------
- */
+* subroutine for test_text_dtype(): test_enums().
+*-------------------------------------------------------------------------
+*/
static int test_enums(void)
{
hid_t dtype;
@@ -1321,8 +1318,8 @@ static int test_enums(void)
if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0)
goto out;
/*if(strcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) {
- printf("dt=\n%s\n", dt_str);
- goto out;
+ printf("dt=\n%s\n", dt_str);
+ goto out;
}*/
free(dt_str);
@@ -1338,9 +1335,9 @@ out:
}
/*-------------------------------------------------------------------------
- * subroutine for test_text_dtype(): test_variables().
- *-------------------------------------------------------------------------
- */
+* subroutine for test_text_dtype(): test_variables().
+*-------------------------------------------------------------------------
+*/
static int test_variables(void)
{
hid_t dtype;
@@ -1393,9 +1390,9 @@ out:
}
/*-------------------------------------------------------------------------
- * subroutine for test_text_dtype(): test_arrays().
- *-------------------------------------------------------------------------
- */
+* subroutine for test_text_dtype(): test_arrays().
+*-------------------------------------------------------------------------
+*/
static int test_arrays(void)
{
hid_t dtype;
@@ -1431,8 +1428,8 @@ static int test_arrays(void)
if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0)
goto out;
/*if(strcmp(dt_str, "H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE \"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }")) {
- printf("dt=\n%s\n", dt_str);
- goto out;
+ printf("dt=\n%s\n", dt_str);
+ goto out;
}*/
free(dt_str);
@@ -1448,9 +1445,9 @@ out:
}
/*-------------------------------------------------------------------------
- * subroutine for test_text_dtype(): test_compounds().
- *-------------------------------------------------------------------------
- */
+* subroutine for test_text_dtype(): test_compounds().
+*-------------------------------------------------------------------------
+*/
static int test_compounds(void)
{
hid_t dtype;
@@ -1513,9 +1510,9 @@ out:
}
/*-------------------------------------------------------------------------
- * subroutine for test_text_dtype(): test_complicated_compound().
- *-------------------------------------------------------------------------
- */
+* subroutine for test_text_dtype(): test_complicated_compound().
+*-------------------------------------------------------------------------
+*/
static int test_complicated_compound(void)
{
hid_t dtype;
@@ -1532,8 +1529,8 @@ static int test_complicated_compound(void)
/* compose the name of the file to open, using the srcdir, if appropriate */
if(srcdir)
{
- strcpy(filename, srcdir);
- strcat(filename, "/");
+ strcpy(filename, srcdir);
+ strcat(filename, "/");
}
strcat(filename, INPUT_FILE);
@@ -1541,14 +1538,14 @@ static int test_complicated_compound(void)
fp = fopen(filename, "r");
if(fp == NULL)
{
- printf( "Could not find file %s. Try set $srcdir \n", filename);
- goto out;
+ printf( "Could not find file %s. Try set $srcdir \n", filename);
+ goto out;
}
/* This part reads in the input as a string in a slow manner. GNU C
- * Library has convenient function getline() but isn't available on
- * all machines.
- */
+ * Library has convenient function getline() but isn't available on
+ * all machines.
+ */
if((line = (char*)calloc(size, sizeof(char)))==NULL)
goto out;
if(fgets(line, (int)size, fp)==NULL)
@@ -1593,9 +1590,9 @@ out:
}
/*-------------------------------------------------------------------------
- * test H5LTtext_to_dtype function
- *-------------------------------------------------------------------------
- */
+* test H5LTtext_to_dtype function
+*-------------------------------------------------------------------------
+*/
static int test_text_dtype(void)
{
TESTING("H5LTtext_to_dtype");
@@ -1634,30 +1631,30 @@ out:
}
/*-------------------------------------------------------------------------
- * the main program
- *-------------------------------------------------------------------------
- */
+* the main program
+*-------------------------------------------------------------------------
+*/
int main( void )
{
- int nerrors=0;
+ int nerrors=0;
- /* test dataset functions */
- nerrors += test_dsets();
+ /* test dataset functions */
+ nerrors += test_dsets();
- /* test attribute functions */
- nerrors += test_attr();
+ /* test attribute functions */
+ nerrors += test_attr();
- /* test text-dtype functions */
- nerrors += test_text_dtype();
+ /* test text-dtype functions */
+ nerrors += test_text_dtype();
- /* check for errors */
- if (nerrors)
- goto error;
+ /* check for errors */
+ if (nerrors)
+ goto error;
- return 0;
+ return 0;
error:
- return 1;
+ return 1;
}
diff --git a/hl/test/test_table.c b/hl/test/test_table.c
index bd8dd79..fd08ed9 100644
--- a/hl/test/test_table.c
+++ b/hl/test/test_table.c
@@ -1,17 +1,17 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+* Copyright by The HDF Group. *
+* Copyright by the Board of Trustees of the University of Illinois. *
+* All rights reserved. *
+* *
+* This file is part of HDF5. The full HDF5 copyright notice, including *
+* terms governing use, modification, and redistribution, is contained in *
+* the files COPYING and Copyright.html. COPYING can be found at the root *
+* of the source code distribution tree; Copyright.html can be found at the *
+* root level of an installed copy of the electronic HDF5 document set and *
+* is linked from the top-level documents page. It can also be found at *
+* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+* access to either file, you may request a copy from help@hdfgroup.org. *
+* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
#include <string.h>
@@ -24,28 +24,28 @@
/*-------------------------------------------------------------------------
- * Table API test
- *
- * Functions tested:
- *
- * H5TBmake_table
- * H5TBread_table
- * H5TBwrite_records
- * H5TBread_records
- * H5TBappend_records
- * H5TBinsert_record
- * H5TBdelete_record
- * H5TBcombine_tables
- * H5TBwrite_fields_name
- * H5TBread_fields_name
- * H5TBwrite_fields_index
- * H5TBinsert_field
- * H5TBdelete_field
- * H5TBget_table_info
- * H5TBget_field_info
- *
- *-------------------------------------------------------------------------
- */
+* Table API test
+*
+* Functions tested:
+*
+* H5TBmake_table
+* H5TBread_table
+* H5TBwrite_records
+* H5TBread_records
+* H5TBappend_records
+* H5TBinsert_record
+* H5TBdelete_record
+* H5TBcombine_tables
+* H5TBwrite_fields_name
+* H5TBread_fields_name
+* H5TBwrite_fields_index
+* H5TBinsert_field
+* H5TBdelete_field
+* H5TBget_table_info
+* H5TBget_field_info
+*
+*-------------------------------------------------------------------------
+*/
#define TITLE "Title"
#define NFIELDS 5
@@ -55,9 +55,9 @@
#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);}
/*-------------------------------------------------------------------------
- * structure used for all tests, a particle with properties
- *-------------------------------------------------------------------------
- */
+* structure used for all tests, a particle with properties
+*-------------------------------------------------------------------------
+*/
typedef struct particle_t
{
char name[16];
@@ -68,19 +68,9 @@ typedef struct particle_t
} particle_t;
/*-------------------------------------------------------------------------
- * local auxiliary functions
- *-------------------------------------------------------------------------
- */
-
-static hid_t h5file_open(const char *fname, unsigned flags);
-static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf );
-static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords,
- particle_t *rbuf, particle_t *wbuf);
-
-/*-------------------------------------------------------------------------
- * a subset of particle_t, with latitude and longitude fields
- *-------------------------------------------------------------------------
- */
+* a subset of particle_t, with latitude and longitude fields
+*-------------------------------------------------------------------------
+*/
typedef struct position_t
{
long longi;
@@ -88,9 +78,9 @@ typedef struct position_t
} position_t;
/*-------------------------------------------------------------------------
- * a subset of particle_t, with name and pressure fields
- *-------------------------------------------------------------------------
- */
+* a subset of particle_t, with name and pressure fields
+*-------------------------------------------------------------------------
+*/
typedef struct namepressure_t
{
char name[16];
@@ -98,9 +88,9 @@ typedef struct namepressure_t
} namepressure_t;
/*-------------------------------------------------------------------------
- * an extended particle, used in the insert field test
- *-------------------------------------------------------------------------
- */
+* an extended particle, used in the insert field test
+*-------------------------------------------------------------------------
+*/
typedef struct particle2_t
{
char name[16];
@@ -112,9 +102,9 @@ typedef struct particle2_t
} particle2_t;
/*-------------------------------------------------------------------------
- * a particle with one field less, used in the delete field test
- *-------------------------------------------------------------------------
- */
+* a particle with one field less, used in the delete field test
+*-------------------------------------------------------------------------
+*/
typedef struct particle3_t
{
char name[16];
@@ -126,16 +116,16 @@ typedef struct particle3_t
/*-------------------------------------------------------------------------
- * function to open an HDF5 file and return its file identifier
- *-------------------------------------------------------------------------
- */
+* function to open an HDF5 file and return its file identifier
+*-------------------------------------------------------------------------
+*/
static hid_t h5file_open(const char *fname, unsigned flags)
{
-
+
hid_t fid; /* identifier for the file */
char *srcdir = getenv("srcdir"); /* the source directory */
char data_file[512]=""; /* buffer to hold name of existing file */
-
+
/* compose the name of the file to open, using the srcdir, if appropriate */
if (srcdir)
{
@@ -143,21 +133,21 @@ static hid_t h5file_open(const char *fname, unsigned flags)
strcat(data_file,"/");
}
strcat(data_file,fname);
-
+
/* open */
if ((fid = H5Fopen(data_file,flags,H5P_DEFAULT))<0)
{
fprintf(stderr,"Error: Cannot open file <%s>\n",data_file );
exit(1);
}
-
+
return fid;
}
/*-------------------------------------------------------------------------
- * function that compares one particle
- *-------------------------------------------------------------------------
- */
+* function that compares one particle
+*-------------------------------------------------------------------------
+*/
static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf )
{
if ( ( strcmp( rbuf[i].name, wbuf[j].name ) != 0 ) ||
@@ -177,9 +167,9 @@ static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf )
}
/*-------------------------------------------------------------------------
- * function to compare deleted records
- *-------------------------------------------------------------------------
- */
+* function to compare deleted records
+*-------------------------------------------------------------------------
+*/
static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords,
particle_t *rbuf, particle_t *wbuf)
{
@@ -204,11 +194,11 @@ static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords,
/*-------------------------------------------------------------------------
- * the test program
- *-------------------------------------------------------------------------
- */
+* the test program
+*-------------------------------------------------------------------------
+*/
-int test_table(hid_t fid, int write)
+static int test_table(hid_t fid, int do_write)
{
hid_t fid1;
hid_t fid2;
@@ -277,39 +267,39 @@ int test_table(hid_t fid, int write)
{"six", 6.0f},
{"seven", 7.0f},
};
-
-
+
+
/*-------------------------------------------------------------------------
* initialize table parameters
* field offsets and sizes used in the fields functions
*-------------------------------------------------------------------------
*/
-
+
size_t field_offset_pos[2]=
{
HOFFSET( position_t, longi ),
- HOFFSET( position_t, lati )
+ HOFFSET( position_t, lati )
};
size_t field_offset_namepre[2]=
{
HOFFSET( namepressure_t, name ),
- HOFFSET( namepressure_t, pressure )
+ HOFFSET( namepressure_t, pressure )
};
size_t field_sizes_pos[2]=
{
sizeof(position_in[0].longi),
- sizeof(position_in[0].lati)
+ sizeof(position_in[0].lati)
};
size_t field_sizes_namepre[2]=
{
sizeof(namepre_in[0].name),
- sizeof(namepre_in[0].pressure)
+ sizeof(namepre_in[0].pressure)
};
size_t field_sizes_pre[1]=
{
sizeof(namepre_in[0].pressure)
};
-
+
/*-------------------------------------------------------------------------
* query table test
*-------------------------------------------------------------------------
@@ -318,7 +308,7 @@ int test_table(hid_t fid, int write)
size_t sizes_out[NFIELDS];
size_t offset_out[NFIELDS];
size_t size_out;
-
+
/*-------------------------------------------------------------------------
* initialize table parameters
* field indexes (zero based) used in the fields functions
@@ -329,7 +319,7 @@ int test_table(hid_t fid, int write)
int field_index_pos[2] = { 1,4 };
int field_index_namepre[2] = { 0,2 };
int field_index[NFIELDS] = { 0,1,2,3,4 };
-
+
/*-------------------------------------------------------------------------
* initialize table parameters
* size and the offsets of struct members in memory
@@ -351,48 +341,48 @@ int test_table(hid_t fid, int write)
sizeof( rbuf2[0].temperature),
sizeof( rbuf2[0].lati),
sizeof( rbuf2[0].new_field)};
- /*-------------------------------------------------------------------------
- * initialize table parameters
- * size and the offsets of struct members in memory
- * these are used for the delete field test
- *-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
+ * initialize table parameters
+ * size and the offsets of struct members in memory
+ * these are used for the delete field test
+ *-------------------------------------------------------------------------
*/
size_t dst_size3 = sizeof( particle3_t );
size_t dst_offset3[NFIELDS-1] = { HOFFSET( particle3_t, name ),
HOFFSET( particle3_t, longi ),
HOFFSET( particle3_t, temperature ),
HOFFSET( particle3_t, lati )};
-
+
size_t dst_sizes3[NFIELDS-1] = { sizeof( rbuf3[0].name),
sizeof( rbuf3[0].longi),
sizeof( rbuf3[0].temperature),
sizeof( rbuf3[0].lati)};
-
-
- /*-------------------------------------------------------------------------
- * initialize table parameters
- * 1) size and the offsets of struct members in memory
- * 2) field names
- * 3) define a HDF5 type for the fields
- *-------------------------------------------------------------------------
+
+
+ /*-------------------------------------------------------------------------
+ * initialize table parameters
+ * 1) size and the offsets of struct members in memory
+ * 2) field names
+ * 3) define a HDF5 type for the fields
+ *-------------------------------------------------------------------------
*/
-
+
size_t type_size_mem = sizeof( particle_t );
size_t field_offset[NFIELDS]=
{
HOFFSET( particle_t, name ),
- HOFFSET( particle_t, longi ),
- HOFFSET( particle_t, pressure ),
- HOFFSET( particle_t, temperature ),
- HOFFSET( particle_t, lati )
+ HOFFSET( particle_t, longi ),
+ HOFFSET( particle_t, pressure ),
+ HOFFSET( particle_t, temperature ),
+ HOFFSET( particle_t, lati )
};
size_t field_size[NFIELDS] =
{
sizeof( rbuf[0].name),
- sizeof( rbuf[0].longi),
- sizeof( rbuf[0].pressure),
- sizeof( rbuf[0].temperature),
- sizeof( rbuf[0].lati)
+ sizeof( rbuf[0].longi),
+ sizeof( rbuf[0].pressure),
+ sizeof( rbuf[0].temperature),
+ sizeof( rbuf[0].lati)
};
const char *field_names[NFIELDS] =
{ "Name","Longitude","Pressure","Temperature","Latitude" };
@@ -404,7 +394,7 @@ int test_table(hid_t fid, int write)
field_type[2] = H5T_NATIVE_FLOAT;
field_type[3] = H5T_NATIVE_DOUBLE;
field_type[4] = H5T_NATIVE_INT;
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -414,37 +404,37 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
TESTING2("making table");
-
+
if (H5TBmake_table(TITLE,fid,"table1",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
chunk_size,fill,compress,wbuf)<0)
goto out;
PASSED();
}
-
+
TESTING2("reading table");
-
+
/*-------------------------------------------------------------------------
* read the table
*-------------------------------------------------------------------------
*/
-
+
if (H5TBread_table(fid,"table1",type_size_mem,field_offset,field_size,rbuf)<0)
goto out;
-
+
/* compare the extracted table with the original array */
for( i = 0; i < NRECORDS; i++ )
{
if (cmp_par(i,i,rbuf,wbuf)<0)
goto out;
}
-
+
PASSED();
-
-
+
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -453,16 +443,16 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
TESTING2("writing records");
-
+
/* create an empty table */
if (H5TBmake_table(TITLE,fid,"table2",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
chunk_size,fill,compress,0)<0)
goto out;
-
+
/*-------------------------------------------------------------------------
* write records, start at 0, write 8
* pos = 0 1 2 3 4 5 6 7
@@ -474,21 +464,21 @@ int test_table(hid_t fid, int write)
if (H5TBwrite_records(fid,"table2",wstart,wrecords,type_size_mem,field_offset,
field_size,wbuf)<0)
goto out;
-
+
/* read it back */
if (H5TBread_table(fid,"table2",type_size_mem,field_offset,field_size,rbuf)<0)
goto out;
-
+
/* compare */
for( i = 0; i < NRECORDS; i++ )
{
if (cmp_par(i,i,rbuf,wbuf)<0)
goto out;
}
-
+
PASSED();
}
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -497,32 +487,32 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
-
+
TESTING2("reading records");
-
+
/*-------------------------------------------------------------------------
* read records, start at 0, read 8
* pos = 0 1 2 3 4 5 6 7
* data= 0 1 2 3 4 5 6 7
*-------------------------------------------------------------------------
*/
-
+
/*-------------------------------------------------------------------------
* for the read test we cannot use "table2" because it has been appended
* we use the original "table1" instead
*-------------------------------------------------------------------------
*/
- if(write)
+ if(do_write)
strcpy(tname,"table2");
else
strcpy(tname,"table1");
-
+
rstart=0;
rrecords=8;
if (H5TBread_records(fid,tname,rstart,rrecords,type_size_mem,field_offset,
field_size,rbuf)<0)
goto out;
-
+
/* compare */
for( i=(int)rstart; i<(int)rrecords; i++)
{
@@ -530,7 +520,7 @@ int test_table(hid_t fid, int write)
goto out;
}
PASSED();
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -540,10 +530,10 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
TESTING2("appending records");
-
+
/*-------------------------------------------------------------------------
* append 2 records
* pos = 0 1 2 3 4 5 6 7 8 9
@@ -553,15 +543,15 @@ int test_table(hid_t fid, int write)
arecords=2;
if (H5TBappend_records(fid,"table2",arecords,type_size_mem,field_offset,field_size,abuf)<0)
return 1;
-
+
if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0)
return 1;
-
+
rstart=0; rrecords=NRECORDS+arecords;
if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset,
field_size,rbuf)<0)
return 1;
-
+
/* compare */
wrecords=8;
for( i=(int)rstart; i<(int)wrecords; i++)
@@ -576,7 +566,7 @@ int test_table(hid_t fid, int write)
}
PASSED();
}
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -586,10 +576,10 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
TESTING2("inserting records");
-
+
/*-------------------------------------------------------------------------
* insert 2 records
* pos = 0 1 2 3 4 5 6 7 8 9 10 11
@@ -599,14 +589,14 @@ int test_table(hid_t fid, int write)
istart=1; irecords=2;
if (H5TBinsert_record(fid,"table2",istart,irecords,type_size_mem,field_offset,field_size,ibuf)<0)
return 1;
-
+
if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0)
return 1;
-
+
if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset,
field_size,rbuf)<0)
return 1;
-
+
/* compare */
for( i=0; i<12; i++)
{
@@ -636,7 +626,7 @@ int test_table(hid_t fid, int write)
}
PASSED();
}
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -646,17 +636,17 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
TESTING2("deleting records");
-
+
/*-------------------------------------------------------------------------
* Create a table
* pos = 0 1 2 3 4 5 6 7
* data= 0 1 2 3 4 5 6 7
*-------------------------------------------------------------------------
*/
-
+
for( i=0; i<NRECORDS; i++)
{
wbufd[i].lati = wbuf[i].lati;
@@ -664,15 +654,15 @@ int test_table(hid_t fid, int write)
wbufd[i].pressure = wbuf[i].pressure;
wbufd[i].temperature = wbuf[i].temperature;
strcpy(wbufd[i].name, wbuf[i].name );
-
+
}
-
-
+
+
if (H5TBmake_table(TITLE,fid,"table3",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
chunk_size,fill,compress,wbufd)<0)
goto out;
-
+
/*-------------------------------------------------------------------------
* Delete records, start at 2, delete 3
* pos = 0 1 2 3 4
@@ -682,21 +672,21 @@ int test_table(hid_t fid, int write)
dstart=2; drecords=3;
if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
goto out;
-
+
if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
goto out;
-
+
rstart=0;
if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
field_size,rbuf)<0)
goto out;
-
+
/* compare */
nrecords=NRECORDS;
assert(rrecords == nrecords-drecords);
if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
goto out;
-
+
/*-------------------------------------------------------------------------
* reset compare buffer
*-------------------------------------------------------------------------
@@ -706,7 +696,7 @@ int test_table(hid_t fid, int write)
{
wbufd[i] = rbuf[i];
}
-
+
/*-------------------------------------------------------------------------
* Delete records, start at 0, delete 2
* pos = 0 1 2
@@ -716,20 +706,20 @@ int test_table(hid_t fid, int write)
dstart=0; drecords=2;
if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
goto out;
-
+
if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
goto out;
-
+
rstart=0;
if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
field_size,rbuf)<0)
goto out;
-
+
/* Compare */
assert(rrecords == nrecords-drecords);
if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
goto out;
-
+
/*-------------------------------------------------------------------------
* reset compare buffer
*-------------------------------------------------------------------------
@@ -739,7 +729,7 @@ int test_table(hid_t fid, int write)
{
wbufd[i] = rbuf[i];
}
-
+
/*-------------------------------------------------------------------------
* Delete records, start at 1, delete 1
* pos = 0 1
@@ -749,20 +739,20 @@ int test_table(hid_t fid, int write)
dstart=1; drecords=1;
if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
goto out;
-
+
if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
goto out;
-
+
rstart=0;
if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
field_size,rbuf)<0)
goto out;
-
+
/* Compare */
assert(rrecords == nrecords-drecords);
if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
goto out;
-
+
/*-------------------------------------------------------------------------
* reset compare buffer
*-------------------------------------------------------------------------
@@ -772,7 +762,7 @@ int test_table(hid_t fid, int write)
{
wbufd[i] = rbuf[i];
}
-
+
/*-------------------------------------------------------------------------
* Delete records, start at 0, delete 1
* pos = 0
@@ -782,20 +772,20 @@ int test_table(hid_t fid, int write)
dstart=0; drecords=1;
if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
goto out;
-
+
if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
goto out;
-
+
rstart=0;
if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
field_size,rbuf)<0)
goto out;
-
+
/* Compare */
assert(rrecords == nrecords-drecords);
if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
goto out;
-
+
/*-------------------------------------------------------------------------
* reset compare buffer
*-------------------------------------------------------------------------
@@ -805,11 +795,11 @@ int test_table(hid_t fid, int write)
{
wbufd[i] = rbuf[i];
}
-
+
/* Read complete table */
if (H5TBread_table(fid,"table3",type_size_mem,field_offset,field_size,rbuf)<0)
goto out;
-
+
/* Compare */
for( i=0; i<rrecords; i++)
{
@@ -828,16 +818,16 @@ int test_table(hid_t fid, int write)
dstart=0; drecords=1;
if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
goto out;
-
+
if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
goto out;
-
+
if (rrecords)
goto out;
-
+
PASSED();
}
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -847,11 +837,11 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
-
- if (write)
+
+ if (do_write)
{
TESTING2("adding records");
-
+
/* create 2 tables */
if (H5TBmake_table(TITLE,fid,"table4",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
@@ -861,18 +851,18 @@ int test_table(hid_t fid, int write)
field_names,field_offset,field_type,
chunk_size,fill,compress,wbuf)<0)
goto out;
-
+
/* add the records from "table4" to "table5" */
start1 = 3;
nrecords = 2;
start2 = 6;
if ( H5TBadd_records_from(fid,"table4",start1,nrecords,"table5",start2)<0)
goto out;
-
+
/* read final table */
if (H5TBread_table(fid,"table5",type_size_mem,field_offset,field_size,rbuf)<0)
goto out;
-
+
/* compare */
for( i = 0; i < NRECORDS+2; i++ )
{
@@ -894,10 +884,10 @@ int test_table(hid_t fid, int write)
goto out;
}
}
-
+
PASSED();
}
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -907,11 +897,11 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
-
- if (write)
+
+ if (do_write)
{
TESTING2("combining tables");
-
+
/* create 2 tables */
if (H5TBmake_table(TITLE,fid,"table6",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
@@ -921,15 +911,15 @@ int test_table(hid_t fid, int write)
field_names,field_offset,field_type,
chunk_size,fill,compress,wbuf)<0)
goto out;
-
+
/* combine the two tables into a third */
if ( H5TBcombine_tables(fid,"table6",fid,"table7","table8")<0)
goto out;
-
+
/* read merged table */
if (H5TBread_table(fid,"table8",type_size_mem,field_offset,field_size,rbufc)<0)
goto out;
-
+
/* compare */
for( i = 0; i < NRECORDS*2; i++ )
{
@@ -944,16 +934,16 @@ int test_table(hid_t fid, int write)
goto out;
}
}
-
+
/*-------------------------------------------------------------------------
* multi file test
*-------------------------------------------------------------------------
*/
-
+
/* create 2 files using default properties. */
fid1 = H5Fcreate("combine_tables1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
fid2 = H5Fcreate("combine_tables2.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
-
+
/* create 2 tables, one in each file */
if (H5TBmake_table(TITLE,fid1,"table1",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
@@ -963,15 +953,15 @@ int test_table(hid_t fid, int write)
field_names,field_offset,field_type,
chunk_size,fill,compress,wbuf)<0)
goto out;
-
+
/* combine the two tables into a third */
if ( H5TBcombine_tables(fid1,"table1",fid2,"table2","table3")<0)
goto out;
-
+
/* read merged table */
if (H5TBread_table(fid1,"table3",type_size_mem,field_offset,field_size,rbufc)<0)
goto out;
-
+
/* compare */
for( i = 0; i < NRECORDS*2; i++ )
{
@@ -986,15 +976,15 @@ int test_table(hid_t fid, int write)
goto out;
}
}
-
+
/* close files */
H5Fclose(fid1);
H5Fclose(fid2);
-
+
PASSED();
}
-
-
+
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -1003,39 +993,39 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
TESTING2("writing fields by name");
-
+
/* make an empty table with fill values */
if (H5TBmake_table(TITLE,fid,"table9",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
chunk_size,fill1,compress,0)<0)
goto out;
-
+
/* write the pressure field starting at record 2 */
start = 2;
nrecords = NRECORDS_ADD;
if (H5TBwrite_fields_name(fid,"table9","Pressure",start,nrecords,sizeof(float),
0,field_sizes_pre,pressure_in)<0)
goto out;
-
+
/* write the new longitude and latitude information starting at record 2 */
start = 2;
nrecords = 3;
if (H5TBwrite_fields_name(fid,"table9","Latitude,Longitude",start,nrecords,sizeof(position_t),
field_offset_pos,field_sizes_pos,position_in)<0)
goto out;
-
+
/* read back the all table */
start = 0;
nrecords = NRECORDS;
if (H5TBread_table(fid,"table9",type_size_mem,field_offset,field_size,rbuf)<0)
goto out;
-
+
{
-
-
+
+
/* compare the read values with the initial values */
for( i = 0; i < NRECORDS; i++ )
{
@@ -1054,12 +1044,12 @@ int test_table(hid_t fid, int write)
}
}
}
-
-
-
+
+
+
PASSED();
} /*write*/
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -1069,18 +1059,18 @@ int test_table(hid_t fid, int write)
*-------------------------------------------------------------------------
*/
TESTING2("reading fields by name");
-
+
/*-------------------------------------------------------------------------
* write and read the "Pressure" field
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
if (H5TBmake_table(TITLE,fid,"table10",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
chunk_size,fill1,compress,0)<0)
goto out;
-
+
/* write the pressure field to all the records */
start = 0;
nrecords = NRECORDS;
@@ -1088,15 +1078,15 @@ int test_table(hid_t fid, int write)
sizeof( float ),0,field_sizes_pre,pressure_in)<0)
goto out;
}
-
+
/* read the "Pressure" field */
start = 0;
nrecords = NRECORDS;
if ( H5TBread_fields_name(fid,"table10","Pressure",start,nrecords,
sizeof(float),0,field_sizes_pre,pressure_out)<0)
goto out;
-
-
+
+
/* Compare the extracted table with the initial values */
for( i = 0; i < NRECORDS; i++ )
{
@@ -1104,12 +1094,12 @@ int test_table(hid_t fid, int write)
goto out;
}
}
-
+
/*-------------------------------------------------------------------------
* Write and read the "Latitude,Longitude" fields
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
/* Write the new longitude and latitude information to all the records */
start = 0;
@@ -1118,15 +1108,15 @@ int test_table(hid_t fid, int write)
sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 )
goto out;
}/*write*/
-
+
/* Read the "Latitude,Longitude" fields */
start = 0;
nrecords = NRECORDS_ADD;
if ( H5TBread_fields_name( fid, "table10", "Latitude,Longitude",
start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 )
goto out;
-
-
+
+
/* Compare the extracted table with the initial values */
for( i = 0; i < NRECORDS_ADD; i++ )
{
@@ -1134,13 +1124,13 @@ int test_table(hid_t fid, int write)
position_out[i].longi != position_in[i].longi )
goto out;
}
-
-
+
+
/*-------------------------------------------------------------------------
* Write and read the "Name,Pressure" fields
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
/* Write the new name and pressure information to all the records */
start = 0;
@@ -1149,7 +1139,7 @@ int test_table(hid_t fid, int write)
sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 )
goto out;
}/*write*/
-
+
/* Read the "Name,Pressure" fields */
start = 0;
nrecords = NRECORDS;
@@ -1157,24 +1147,24 @@ int test_table(hid_t fid, int write)
start, nrecords, sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre,
namepre_out ) < 0 )
goto out;
-
-
+
+
/* Compare the extracted table with the initial values */
for( i = 0; i < NRECORDS; i++ )
{
if ( ( strcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) ||
namepre_out[i].pressure != namepre_in[i].pressure ) {
- goto out;
+ goto out;
}
}
-
+
/* reset buffer */
for( i = 0; i < NRECORDS; i++ )
{
strcpy( namepre_out[i].name, "\0" );
namepre_out[i].pressure = -1;
}
-
+
/*-------------------------------------------------------------------------
* read only 3 records of the "Name,Pressure" fields, starting at record 2
*-------------------------------------------------------------------------
@@ -1185,22 +1175,22 @@ int test_table(hid_t fid, int write)
start, nrecords, sizeof(namepressure_t), field_offset_namepre,
field_sizes_namepre, namepre_out ) < 0 )
goto out;
-
-
+
+
/* Compare the extracted table with the initial values */
for( i = 0; i < 3; i++ )
{
int iistart = (int) start;
if ( ( strcmp( namepre_out[i].name, namepre_in[iistart+i].name ) != 0 ) ||
namepre_out[i].pressure != namepre_in[iistart+i].pressure ) {
- goto out;
+ goto out;
}
}
-
-
-
+
+
+
PASSED();
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -1209,16 +1199,16 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
TESTING2("writing fields by index");
-
+
/* make an empty table */
if (H5TBmake_table(TITLE,fid,"table11",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
chunk_size,fill,compress,NULL)<0)
goto out;
-
+
/* write the pressure field starting at record 2 */
nfields = 1;
start = 2;
@@ -1226,8 +1216,8 @@ int test_table(hid_t fid, int write)
if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pre, start, nrecords,
sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 )
goto out;
-
-
+
+
/* write the new longitude and latitude information starting at record 2 */
nfields = 2;
start = 2;
@@ -1235,7 +1225,7 @@ int test_table(hid_t fid, int write)
if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pos, start, nrecords,
sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 )
goto out;
-
+
/* read back the all table */
nfields = 5;
start = 0;
@@ -1243,7 +1233,7 @@ int test_table(hid_t fid, int write)
if ( H5TBread_fields_index(fid, "table11", nfields, field_index,
start, nrecords, type_size_mem, field_offset, field_size, rbuf ) < 0 )
goto out;
-
+
/* Compare the extracted table with the initial values */
for( i = 0; i < NRECORDS; i++ )
{
@@ -1255,11 +1245,11 @@ int test_table(hid_t fid, int write)
goto out;
}
}
-
+
PASSED();
}
-
-
+
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -1268,22 +1258,22 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
-
+
TESTING2("reading fields by index");
-
- if (write)
+
+ if (do_write)
{
/* make an empty table */
if (H5TBmake_table(TITLE,fid,"table12",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
chunk_size,fill,compress,NULL)<0)
goto out;
-
+
/*-------------------------------------------------------------------------
* write and read the "Pressure" field
*-------------------------------------------------------------------------
*/
-
+
/* write the pressure field to all the records */
nfields = 1;
start = 0;
@@ -1292,7 +1282,7 @@ int test_table(hid_t fid, int write)
sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 )
goto out;
}
-
+
/* read the "Pressure" field */
nfields = 1;
start = 0;
@@ -1300,7 +1290,7 @@ int test_table(hid_t fid, int write)
if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pre,
start, nrecords, sizeof(float), 0, field_sizes_pre, pressure_out ) < 0 )
goto out;
-
+
/* compare the extracted table with the initial values */
for( i = 0; i < NRECORDS; i++ )
{
@@ -1308,12 +1298,12 @@ int test_table(hid_t fid, int write)
goto out;
}
}
-
+
/*-------------------------------------------------------------------------
* write and read the "Latitude,Longitude" fields
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
/* write the new longitude and latitude information to all the records */
nfields = 2;
@@ -1323,7 +1313,7 @@ int test_table(hid_t fid, int write)
sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 )
goto out;
} /*write*/
-
+
/* read the "Latitude,Longitude" fields */
nfields = 2;
start = 0;
@@ -1331,22 +1321,22 @@ int test_table(hid_t fid, int write)
if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pos,
start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 )
goto out;
-
+
/* compare the extracted table with the initial values */
for( i = 0; i < NRECORDS_ADD; i++ )
{
if ( position_out[i].lati != position_in[i].lati ||
position_out[i].longi != position_in[i].longi ) {
- goto out;
+ goto out;
}
}
-
+
/*-------------------------------------------------------------------------
* write and read the "Name,Pressure" fields
*-------------------------------------------------------------------------
*/
-
- if (write)
+
+ if (do_write)
{
/* write the new name and pressure information to all the records */
nfields = 2;
@@ -1356,7 +1346,7 @@ int test_table(hid_t fid, int write)
sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 )
goto out;
}
-
+
/* read the "Name,Pressure" fields */
nfields = 2;
start = 0;
@@ -1365,28 +1355,28 @@ int test_table(hid_t fid, int write)
start, nrecords, sizeof(namepressure_t), field_offset_namepre,
field_sizes_namepre, namepre_out ) < 0 )
goto out;
-
+
/* compare the extracted table with the initial values */
for( i = 0; i < NRECORDS; i++ )
{
if ( ( strcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) ||
namepre_out[i].pressure != namepre_in[i].pressure ) {
- goto out;
+ goto out;
}
}
-
+
/* reset buffer */
for( i = 0; i < NRECORDS; i++ )
{
strcpy( namepre_out[i].name, "\0" );
namepre_out[i].pressure = -1;
}
-
+
/*-------------------------------------------------------------------------
* read only 3 records of the "Name,Pressure" fields, starting at record 2
*-------------------------------------------------------------------------
*/
-
+
/* write the new name and pressure information to all the records */
nfields = 2;
start = 2;
@@ -1395,20 +1385,20 @@ int test_table(hid_t fid, int write)
start, nrecords, sizeof(namepressure_t), field_offset_namepre,
field_sizes_namepre, namepre_out ) < 0 )
goto out;
-
+
/* compare the extracted table with the initial values */
for( i = 0; i < 3; i++ )
{
int iistart = (int) start;
if ( ( strcmp( namepre_out[i].name, wbuf[iistart+i].name ) != 0 ) ||
namepre_out[i].pressure != wbuf[iistart+i].pressure ) {
- goto out;
+ goto out;
}
}
-
+
PASSED();
-
-
+
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -1417,27 +1407,27 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
-
- if (write)
+
+ if (do_write)
{
TESTING2("inserting fields");
-
+
/* make a table */
if (H5TBmake_table(TITLE,fid,"table13",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
chunk_size,fill1,compress,wbuf)<0)
goto out;
-
+
/* insert the new field at the end of the field list */
position = NFIELDS;
if ( H5TBinsert_field( fid, "table13", "New Field", field_type_new, position,
fill1_new, buf_new ) < 0 )
goto out;
-
+
/* read the table */
if ( H5TBread_table( fid, "table13", dst_size2, dst_offset2, dst_sizes2, rbuf2 ) < 0 )
goto out;
-
+
/* compare the extracted table with the original array */
for( i = 0; i < NRECORDS; i++ )
{
@@ -1447,12 +1437,12 @@ int test_table(hid_t fid, int write)
rbuf2[i].pressure != wbuf[i].pressure ||
rbuf2[i].temperature != wbuf[i].temperature ||
rbuf2[i].new_field != buf_new[i] ) {
- goto out;
+ goto out;
}
}
PASSED();
}
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -1461,24 +1451,24 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
- if (write)
+ if (do_write)
{
TESTING2("deleting fields");
-
+
/* make a table */
if (H5TBmake_table(TITLE,fid,"table14",FIELDS,RECORDS,type_size_mem,
field_names,field_offset,field_type,
chunk_size,fill,compress,wbuf)<0)
goto out;
-
+
/* delete the field */
if ( H5TBdelete_field(fid, "table14", "Pressure" ) < 0 )
goto out;
-
+
/* read the table */
if ( H5TBread_table(fid, "table14", dst_size3, dst_offset3, dst_sizes3, rbuf3 ) < 0 )
goto out;
-
+
/* compare the extracted table with the original array */
for( i = 0; i < NRECORDS; i++ )
{
@@ -1486,13 +1476,13 @@ int test_table(hid_t fid, int write)
rbuf3[i].lati != wbuf[i].lati ||
rbuf3[i].longi != wbuf[i].longi ||
rbuf3[i].temperature != wbuf[i].temperature ) {
- goto out;
+ goto out;
}
}
-
+
PASSED();
}
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -1502,19 +1492,19 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
-
+
TESTING2("getting table info");
-
+
/* get table info */
if ( H5TBget_table_info (fid, "table1", &rfields, &rrecords ) < 0 )
goto out;
-
+
if ( NFIELDS != rfields || rrecords != NRECORDS ) {
goto out;
}
-
+
PASSED();
-
+
/*-------------------------------------------------------------------------
*
* Functions tested:
@@ -1523,36 +1513,36 @@ int test_table(hid_t fid, int write)
*
*-------------------------------------------------------------------------
*/
-
+
TESTING2("getting field info");
-
+
/* alocate */
- names_out = malloc( sizeof(char*) * (size_t)NFIELDS );
+ names_out = (char**) malloc( sizeof(char*) * (size_t)NFIELDS );
for ( i = 0; i < NFIELDS; i++)
{
- names_out[i] = malloc( sizeof(char) * 255 );
+ names_out[i] = (char*) malloc( sizeof(char) * 255 );
}
-
+
/* Get field info */
if ( H5TBget_field_info(fid, "table1", names_out, sizes_out, offset_out, &size_out ) < 0 )
goto out;
-
+
for ( i = 0; i < NFIELDS; i++)
{
if ( (strcmp( field_names[i], names_out[i] ) != 0)) {
goto out;
}
}
-
+
/* release */
for ( i = 0; i < NFIELDS; i++)
{
free ( names_out[i] );
}
free ( names_out );
-
+
PASSED();
-
+
/*-------------------------------------------------------------------------
* end
*-------------------------------------------------------------------------
@@ -1565,77 +1555,77 @@ out:
/*-------------------------------------------------------------------------
- * the main program
- *-------------------------------------------------------------------------
- */
+* the main program
+*-------------------------------------------------------------------------
+*/
int main(void)
{
hid_t fid; /* identifier for the file */
unsigned flags=H5F_ACC_RDONLY;
-
+
/*-------------------------------------------------------------------------
* test1: create a file for the write/read test
*-------------------------------------------------------------------------
*/
-
+
/* create a file using default properties */
fid=H5Fcreate("test_table.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
-
+
puts("Testing table with file creation mode (read/write in native architecture):");
-
+
/* test, do write */
if (test_table(fid,1)<0)
goto out;
-
+
/* close */
H5Fclose(fid);
-
+
/*-------------------------------------------------------------------------
* test2: open a file written in test1 on a big-endian machine
*-------------------------------------------------------------------------
*/
puts("Testing table with file open mode (read big-endian data):");
-
+
fid=h5file_open(TEST_FILE_BE,flags);
-
+
/* test, do not write */
if (test_table(fid,0)<0)
goto out;
-
+
/* close */
H5Fclose(fid);
-
+
/*-------------------------------------------------------------------------
* test3: open a file written in test1 on a little-endian machine
*-------------------------------------------------------------------------
*/
puts("Testing table with file open mode (read little-endian data):");
-
+
fid=h5file_open(TEST_FILE_LE,flags);
-
+
/* test, do not write */
if (test_table(fid,0)<0)
goto out;
-
+
/* close */
H5Fclose(fid);
-
+
/*-------------------------------------------------------------------------
* test4: open a file written in test1 on the Cray T3 machine
*-------------------------------------------------------------------------
*/
puts("Testing table with file open mode (read Cray data):");
-
+
fid=h5file_open(TEST_FILE_CRAY,flags);
-
+
/* test, do not write */
if (test_table(fid,0)<0)
goto out;
-
+
/* close */
H5Fclose(fid);
-
+
return 0;
out:
H5Fclose(fid);