2003-04-01 01:59:04 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* Copyright by The HDF Group. *
|
2003-04-01 01:59:04 +08:00
|
|
|
|
* 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 *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* 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. *
|
2003-04-01 01:59:04 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
/*
|
|
|
|
|
* Programmer: Robb Matzke <matzke@llnl.gov>
|
|
|
|
|
* Tuesday, December 22, 1998
|
|
|
|
|
*/
|
2001-04-04 02:09:16 +08:00
|
|
|
|
#include "h5test.h"
|
1999-01-08 01:14:55 +08:00
|
|
|
|
#define CPTR(VAR,CONST) ((VAR)=(CONST),&(VAR))
|
|
|
|
|
|
|
|
|
|
const char *FILENAME[] = {
|
|
|
|
|
"enum1",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
2011-10-11 05:55:45 +08:00
|
|
|
|
E1_RED,
|
|
|
|
|
E1_GREEN,
|
|
|
|
|
E1_BLUE,
|
|
|
|
|
E1_WHITE,
|
|
|
|
|
E1_BLACK
|
1999-01-08 01:14:55 +08:00
|
|
|
|
} c_e1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: test_named
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Create an enumeration data type and store it in the file.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: number of errors
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Wednesday, December 23, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
test_named(hid_t file)
|
|
|
|
|
{
|
2007-08-24 04:25:25 +08:00
|
|
|
|
hid_t type = -1, cwg = -1;
|
1999-01-08 01:14:55 +08:00
|
|
|
|
c_e1 val;
|
|
|
|
|
signed char val8;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
TESTING("named enumeration types");
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if((cwg = H5Gcreate2(file, "test_named", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
|
1999-01-08 01:14:55 +08:00
|
|
|
|
|
|
|
|
|
/* A native integer */
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "RED", CPTR(val, E1_RED )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) FAIL_STACK_ERROR
|
[svn-r14156] Description:
Add API versioning to H5Tcommit()
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
AIX/32 5.3 (copper) w/FORTRAN, w/parallel, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-09-26 10:50:31 +08:00
|
|
|
|
if(H5Tcommit2(cwg, "e1_a", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5Tclose(type) < 0) FAIL_STACK_ERROR
|
1999-01-08 01:14:55 +08:00
|
|
|
|
|
|
|
|
|
/* A smaller type */
|
2010-08-26 04:27:07 +08:00
|
|
|
|
if((type = H5Tcreate(H5T_ENUM, (size_t)1)) < 0) FAIL_STACK_ERROR
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5Tenum_insert(type, "RED", CPTR(val8, E1_RED )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "GREEN", CPTR(val8, E1_GREEN)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLUE", CPTR(val8, E1_BLUE )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "WHITE", CPTR(val8, E1_WHITE)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLACK", CPTR(val8, E1_BLACK)) < 0) FAIL_STACK_ERROR
|
[svn-r14156] Description:
Add API versioning to H5Tcommit()
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
AIX/32 5.3 (copper) w/FORTRAN, w/parallel, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-09-26 10:50:31 +08:00
|
|
|
|
if(H5Tcommit2(cwg, "e1_b", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5Tclose(type) < 0) FAIL_STACK_ERROR
|
1999-01-08 01:14:55 +08:00
|
|
|
|
|
|
|
|
|
/* A non-native type */
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5T_ORDER_BE == H5Tget_order(H5T_NATIVE_INT)) {
|
|
|
|
|
if ((type = H5Tenum_create(H5T_STD_U8LE)) < 0) FAIL_STACK_ERROR
|
1999-01-08 01:14:55 +08:00
|
|
|
|
} else {
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if ((type = H5Tenum_create(H5T_STD_U8BE)) < 0) FAIL_STACK_ERROR
|
1999-01-08 01:14:55 +08:00
|
|
|
|
}
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5Tenum_insert(type, "RED", CPTR(val8, E1_RED )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "GREEN", CPTR(val8, E1_GREEN)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLUE", CPTR(val8, E1_BLUE )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "WHITE", CPTR(val8, E1_WHITE)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLACK", CPTR(val8, E1_BLACK)) < 0) FAIL_STACK_ERROR
|
[svn-r14156] Description:
Add API versioning to H5Tcommit()
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
AIX/32 5.3 (copper) w/FORTRAN, w/parallel, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-09-26 10:50:31 +08:00
|
|
|
|
if(H5Tcommit2(cwg, "e1_c", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5Tclose(type) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
PASSED();
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Tclose(type);
|
|
|
|
|
H5Gclose(cwg);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-10-18 02:38:38 +08:00
|
|
|
|
* Function: test_conv
|
1999-01-08 01:14:55 +08:00
|
|
|
|
*
|
2012-10-18 02:38:38 +08:00
|
|
|
|
* Purpose: Tests writing and read data
|
1999-01-08 01:14:55 +08:00
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: number of errors
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Monday, January 4, 1999
|
2012-10-18 02:38:38 +08:00
|
|
|
|
*
|
|
|
|
|
* Raymond Lu
|
|
|
|
|
* 12 October 2012
|
|
|
|
|
* I added tests for enum-integer and enum-float conversions
|
1999-01-08 01:14:55 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static int
|
2012-10-18 02:38:38 +08:00
|
|
|
|
test_conv(hid_t file)
|
1999-01-08 01:14:55 +08:00
|
|
|
|
{
|
|
|
|
|
hid_t cwg=-1, type=-1, space=-1, dset=-1;
|
|
|
|
|
c_e1 val;
|
2012-10-18 02:38:38 +08:00
|
|
|
|
/* Some values are out of range for testing. The library should accept them */
|
1999-01-08 01:14:55 +08:00
|
|
|
|
static c_e1 data1[]={E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE,
|
|
|
|
|
E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED,
|
|
|
|
|
E1_RED, E1_BLUE, E1_GREEN, E1_BLACK, E1_WHITE,
|
2012-10-21 11:44:32 +08:00
|
|
|
|
E1_RED, E1_WHITE, (c_e1)0, (c_e1)-1, (c_e1)-2};
|
1999-01-08 01:14:55 +08:00
|
|
|
|
c_e1 data2[NELMTS(data1)];
|
2012-10-18 02:38:38 +08:00
|
|
|
|
short data_short[NELMTS(data1)];
|
|
|
|
|
int data_int[NELMTS(data1)];
|
|
|
|
|
double data_double[NELMTS(data1)];
|
2007-03-27 11:06:48 +08:00
|
|
|
|
hsize_t ds_size[1]={NELMTS(data1)};
|
|
|
|
|
size_t i;
|
1999-01-08 01:14:55 +08:00
|
|
|
|
|
2012-10-18 02:38:38 +08:00
|
|
|
|
TESTING("enumeration conversions");
|
2007-08-24 04:25:25 +08:00
|
|
|
|
|
2012-10-18 02:38:38 +08:00
|
|
|
|
if((cwg = H5Gcreate2(file, "test_conv", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
|
2007-08-24 04:25:25 +08:00
|
|
|
|
|
|
|
|
|
if((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "RED", CPTR(val, E1_RED )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
|
if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR
|
2012-10-18 02:38:38 +08:00
|
|
|
|
|
|
|
|
|
/***************************************
|
|
|
|
|
* Dataset of enumeration type
|
|
|
|
|
***************************************/
|
|
|
|
|
/* Create a dataset of enum type and write enum data to it */
|
|
|
|
|
if((dset = H5Dcreate2(cwg, "color_table1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR
|
2012-10-18 02:38:38 +08:00
|
|
|
|
|
|
|
|
|
/* Test reading back the data with no conversion */
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5Dread(dset, type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < (size_t)ds_size[0]; i++)
|
|
|
|
|
if(data1[i] != data2[i]) {
|
2001-01-26 01:03:29 +08:00
|
|
|
|
H5_FAILED();
|
2012-10-18 02:38:38 +08:00
|
|
|
|
printf(" 1. data1[%lu]=%d, data2[%lu]=%d (should be same)\n",
|
1999-01-08 01:14:55 +08:00
|
|
|
|
(unsigned long)i, (int)(data1[i]),
|
|
|
|
|
(unsigned long)i, (int)(data2[i]));
|
|
|
|
|
goto error;
|
2007-08-24 04:25:25 +08:00
|
|
|
|
} /* end if */
|
|
|
|
|
|
2012-10-18 02:38:38 +08:00
|
|
|
|
/* Test converting the data to integer. Read enum data back as integer */
|
|
|
|
|
if(H5Dread(dset, H5T_NATIVE_SHORT, space, space, H5P_DEFAULT, data_short) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < (size_t)ds_size[0]; i++)
|
2012-10-21 11:44:32 +08:00
|
|
|
|
if((short)data1[i] != data_short[i]) {
|
2012-10-18 02:38:38 +08:00
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf(" 2. data1[%lu]=%d, data_short[%lu]=%d (should be same)\n",
|
|
|
|
|
(unsigned long)i, (int)(data1[i]),
|
|
|
|
|
(unsigned long)i, (int)(data_short[i]));
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
/* Test converting the data to floating number. Read enum data back as floating number */
|
|
|
|
|
if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, data_double) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < (size_t)ds_size[0]; i++)
|
2012-10-23 03:46:03 +08:00
|
|
|
|
if((int)data1[i] != (int)data_double[i]) {
|
2012-10-18 02:38:38 +08:00
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf(" 3. data1[%lu]=%d, data_double[%lu]=%d (should be same)\n",
|
|
|
|
|
(unsigned long)i, (int)(data1[i]),
|
|
|
|
|
(unsigned long)i, (int)(data_double[i]));
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
/***************************************
|
|
|
|
|
* Dataset of integer type
|
|
|
|
|
***************************************/
|
|
|
|
|
/* Create a dataset of native integer and write enum data to it */
|
|
|
|
|
if((dset = H5Dcreate2(cwg, "color_table2", H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
if(H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
/* Test reading back the data with no conversion */
|
|
|
|
|
if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, data_int) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < (size_t)ds_size[0]; i++)
|
2012-10-21 11:44:32 +08:00
|
|
|
|
if((int)data1[i] != data_int[i]) {
|
2012-10-18 02:38:38 +08:00
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf(" 4. data1[%lu]=%d, data_int[%lu]=%d (should be same)\n",
|
|
|
|
|
(unsigned long)i, (int)(data1[i]),
|
|
|
|
|
(unsigned long)i, (int)(data_int[i]));
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
|
2012-10-18 02:38:38 +08:00
|
|
|
|
|
|
|
|
|
/***************************************
|
|
|
|
|
* Dataset of double type
|
|
|
|
|
***************************************/
|
|
|
|
|
/* Create a dataset of native double and write enum data to it */
|
|
|
|
|
if((dset = H5Dcreate2(cwg, "color_table3", H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
if(H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
/* Test reading back the data with no conversion */
|
|
|
|
|
if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, data_double) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < (size_t)ds_size[0]; i++)
|
2012-10-23 03:46:03 +08:00
|
|
|
|
if((int)data1[i] != (int)data_double[i]) {
|
2012-10-18 02:38:38 +08:00
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf(" 5. data1[%lu]=%d, data_double[%lu]=%d (should be same)\n",
|
|
|
|
|
(unsigned long)i, (int)(data1[i]),
|
|
|
|
|
(unsigned long)i, (int)(data_double[i]));
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
|
if(H5Sclose(space) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tclose(type) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
PASSED();
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Dclose(dset);
|
|
|
|
|
H5Sclose(space);
|
|
|
|
|
H5Tclose(type);
|
|
|
|
|
H5Gclose(cwg);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: test_tr1
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Writes enumerated data to a dataset which requires
|
|
|
|
|
* translation. Both memory and file data types use native
|
|
|
|
|
* integers but the file type has a different mapping between
|
|
|
|
|
* the integers and symbols.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: number of errors
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Monday, January 4, 1999
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
test_tr1(hid_t file)
|
|
|
|
|
{
|
2007-08-24 04:25:25 +08:00
|
|
|
|
hid_t cwg = -1, m_type = -1, f_type = -1, space = -1, dset = -1;
|
|
|
|
|
hsize_t ds_size[1] = {10};
|
2007-03-27 11:06:48 +08:00
|
|
|
|
size_t i;
|
1999-02-25 23:40:27 +08:00
|
|
|
|
c_e1 eval;
|
|
|
|
|
int ival;
|
2007-08-24 04:25:25 +08:00
|
|
|
|
static c_e1 data1[10] = {E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE,
|
1999-01-08 01:14:55 +08:00
|
|
|
|
E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED};
|
|
|
|
|
c_e1 data2[10];
|
|
|
|
|
|
|
|
|
|
TESTING("O(1) conversions");
|
2007-08-24 04:25:25 +08:00
|
|
|
|
|
[svn-r15868] Description:
Correct a minor error in file free space allocation which was affecting
the 'multi' VFD and preventing some tests from fully working with it.
Wholesale revisitation of all the places where tests were disabled
with various VFDs and remove or correct all these so that _only_ the tests
which _really_ can't work with particular VFDs are skipped during a
'make check-vfd' test.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-15 09:46:34 +08:00
|
|
|
|
if((cwg = H5Gcreate2(file, "test_tr1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
if((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "RED", CPTR(eval, E1_RED )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "GREEN", CPTR(eval, E1_GREEN)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "BLUE", CPTR(eval, E1_BLUE )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "WHITE", CPTR(eval, E1_WHITE)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "BLACK", CPTR(eval, E1_BLACK)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if((f_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "RED", CPTR(ival, 105)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "GREEN", CPTR(ival, 104)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "BLUE", CPTR(ival, 103)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "WHITE", CPTR(ival, 102)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "BLACK", CPTR(ival, 101)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < (size_t)ds_size[0]; i++)
|
|
|
|
|
if(data1[i] != data2[i]) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n",
|
|
|
|
|
(unsigned long)i, (int)(data1[i]),
|
|
|
|
|
(unsigned long)i, (int)(data2[i]));
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Sclose(space) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tclose(m_type) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tclose(f_type) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
PASSED();
|
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Dclose(dset);
|
|
|
|
|
H5Sclose(space);
|
|
|
|
|
H5Tclose(m_type);
|
|
|
|
|
H5Tclose(f_type);
|
|
|
|
|
H5Gclose(cwg);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
return 1;
|
1999-01-08 01:14:55 +08:00
|
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: test_tr2
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Tests conversions that use the O(log N) lookup function.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: number of errors
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Tuesday, January 5, 1999
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
test_tr2(hid_t file)
|
|
|
|
|
{
|
2007-08-24 04:25:25 +08:00
|
|
|
|
hid_t cwg = -1, m_type = -1, f_type = -1, space = -1, dset = -1;
|
|
|
|
|
hsize_t ds_size[1] = {10};
|
2007-03-27 11:06:48 +08:00
|
|
|
|
size_t i;
|
1999-01-08 01:14:55 +08:00
|
|
|
|
c_e1 val1;
|
|
|
|
|
int val2;
|
2007-08-24 04:25:25 +08:00
|
|
|
|
static c_e1 data1[10] = {E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE,
|
1999-01-08 01:14:55 +08:00
|
|
|
|
E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED};
|
|
|
|
|
c_e1 data2[10];
|
|
|
|
|
|
|
|
|
|
TESTING("O(log N) converions");
|
2007-08-24 04:25:25 +08:00
|
|
|
|
|
[svn-r15868] Description:
Correct a minor error in file free space allocation which was affecting
the 'multi' VFD and preventing some tests from fully working with it.
Wholesale revisitation of all the places where tests were disabled
with various VFDs and remove or correct all these so that _only_ the tests
which _really_ can't work with particular VFDs are skipped during a
'make check-vfd' test.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-15 09:46:34 +08:00
|
|
|
|
if((cwg = H5Gcreate2(file, "test_tr2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
if((m_type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "RED", CPTR(val1, E1_RED )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "GREEN", CPTR(val1, E1_GREEN)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "BLUE", CPTR(val1, E1_BLUE )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "WHITE", CPTR(val1, E1_WHITE)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(m_type, "BLACK", CPTR(val1, E1_BLACK)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
if((f_type = H5Tcreate(H5T_ENUM, sizeof(int))) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "RED", CPTR(val2, 1050)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "GREEN", CPTR(val2, 1040)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "BLUE", CPTR(val2, 1030)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "WHITE", CPTR(val2, 1020)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(f_type, "BLACK", CPTR(val2, 1010)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
if((space = H5Screate_simple(1, ds_size, NULL)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if((dset = H5Dcreate2(cwg, "color_table", f_type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Dwrite(dset, m_type, space, space, H5P_DEFAULT, data1) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Dread(dset, m_type, space, space, H5P_DEFAULT, data2) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < (size_t)ds_size[0]; i++)
|
|
|
|
|
if(data1[i] != data2[i]) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf(" data1[%lu]=%d, data2[%lu]=%d (should be same)\n",
|
|
|
|
|
(unsigned long)i, (int)(data1[i]),
|
|
|
|
|
(unsigned long)i, (int)(data2[i]));
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Sclose(space) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tclose(m_type) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tclose(f_type) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Gclose(cwg) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
PASSED();
|
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
2007-08-24 04:25:25 +08:00
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Dclose(dset);
|
|
|
|
|
H5Sclose(space);
|
|
|
|
|
H5Tclose(m_type);
|
|
|
|
|
H5Tclose(f_type);
|
|
|
|
|
H5Gclose(cwg);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
return 1;
|
1999-01-08 01:14:55 +08:00
|
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-06-12 03:34:02 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: test_value_dsnt_exist
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Create an enumeration datatype with "gaps in values"
|
|
|
|
|
* and then request a name of non-existing value within
|
|
|
|
|
* an existing range by calling H5Tenum_nameof function.
|
2005-08-14 04:53:35 +08:00
|
|
|
|
* Function should fail instead of succeeding and returning
|
|
|
|
|
* a name of one of the existing values.
|
2002-06-12 03:34:02 +08:00
|
|
|
|
* Request a value by supplying non-existing name by calling
|
|
|
|
|
* H5Tenum_nameof function. Function should fail.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: number of errors
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Elena Pourmal
|
|
|
|
|
* Wednesday, June 7, 2002
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static int
|
2002-06-13 02:24:25 +08:00
|
|
|
|
test_value_dsnt_exist(void)
|
2002-06-12 03:34:02 +08:00
|
|
|
|
{
|
|
|
|
|
|
2002-08-09 01:52:17 +08:00
|
|
|
|
hid_t datatype_id=(-1); /* identifiers */
|
2002-06-12 03:34:02 +08:00
|
|
|
|
int val;
|
|
|
|
|
char nam[100];
|
|
|
|
|
size_t size = 100;
|
|
|
|
|
TESTING("for non-existing name and value");
|
|
|
|
|
/* Turn off error reporting since we expect failure in this test */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2010-09-28 03:02:48 +08:00
|
|
|
|
if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) goto error;
|
2003-09-25 03:26:50 +08:00
|
|
|
|
|
2002-06-12 03:34:02 +08:00
|
|
|
|
if ((datatype_id = H5Tenum_create(H5T_NATIVE_INT))< 0) goto error;
|
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
|
/* These calls should fail, since no memebrs exist yet */
|
|
|
|
|
if (H5Tenum_valueof(datatype_id, "SAX", &val) >= 0) goto error;
|
2002-06-12 03:34:02 +08:00
|
|
|
|
val = 3;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) goto error;
|
2002-06-12 03:34:02 +08:00
|
|
|
|
|
|
|
|
|
val = 2;
|
|
|
|
|
if (H5Tenum_insert(datatype_id, "TWO", (int *)&val) < 0) goto error;
|
|
|
|
|
val = 6;
|
|
|
|
|
if (H5Tenum_insert(datatype_id, "SIX", (int *)&val) < 0) goto error;
|
|
|
|
|
val = 10;
|
|
|
|
|
if (H5Tenum_insert(datatype_id, "TEN", (int *)&val) < 0) goto error;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-06-12 03:34:02 +08:00
|
|
|
|
/* This call should fail since we did not create a member with value = 3*/
|
|
|
|
|
val = 3;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) goto error;
|
2002-06-12 03:34:02 +08:00
|
|
|
|
|
|
|
|
|
/* This call should fail since we did not create a member with value = 11*/
|
|
|
|
|
val = 11;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) goto error;
|
2002-06-12 03:34:02 +08:00
|
|
|
|
|
|
|
|
|
/* This call should fail since we did not create a member with value = 0*/
|
|
|
|
|
val = 0;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
if (H5Tenum_nameof(datatype_id, &val, nam, size) >= 0) goto error;
|
2002-06-12 03:34:02 +08:00
|
|
|
|
|
|
|
|
|
/* This call should fail since we do not have SAX name in the type */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
if (H5Tenum_valueof(datatype_id, "SAX", &val) >= 0) goto error;
|
2002-06-12 03:34:02 +08:00
|
|
|
|
|
|
|
|
|
/* This call should fail since we do not have TEEN name in the type */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
if (H5Tenum_valueof(datatype_id, "TEEN", &val) >= 0) goto error;
|
2002-06-12 03:34:02 +08:00
|
|
|
|
|
|
|
|
|
/* This call should fail since we do not have A name in the type */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
if (H5Tenum_valueof(datatype_id, "A", &val) >= 0) goto error;
|
2002-06-12 03:34:02 +08:00
|
|
|
|
|
|
|
|
|
if (H5Tclose(datatype_id) < 0) goto error;
|
|
|
|
|
PASSED();
|
|
|
|
|
return 0;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2002-06-12 03:34:02 +08:00
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Tclose(datatype_id);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-03 03:42:41 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: test_funcs
|
|
|
|
|
*
|
2006-06-27 22:45:06 +08:00
|
|
|
|
* Purpose: Create an enumeration data type and test some functions
|
2006-05-03 03:42:41 +08:00
|
|
|
|
* that are or aren't supposed to work with it.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: 0
|
|
|
|
|
*
|
|
|
|
|
* Failure: number of errors
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Raymond Lu
|
|
|
|
|
* Tuesday, April 4, 2006
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
test_funcs(void)
|
|
|
|
|
{
|
2006-07-16 03:49:04 +08:00
|
|
|
|
hid_t type=-1;
|
2006-05-03 03:42:41 +08:00
|
|
|
|
c_e1 val;
|
[svn-r15868] Description:
Correct a minor error in file free space allocation which was affecting
the 'multi' VFD and preventing some tests from fully working with it.
Wholesale revisitation of all the places where tests were disabled
with various VFDs and remove or correct all these so that _only_ the tests
which _really_ can't work with particular VFDs are skipped during a
'make check-vfd' test.
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
2008-10-15 09:46:34 +08:00
|
|
|
|
size_t size;
|
2006-05-03 03:42:41 +08:00
|
|
|
|
H5T_pad_t inpad;
|
|
|
|
|
H5T_cset_t cset;
|
|
|
|
|
herr_t ret;
|
|
|
|
|
|
|
|
|
|
TESTING("some functions with enumeration types");
|
|
|
|
|
|
|
|
|
|
/* A native integer */
|
2009-03-11 03:00:39 +08:00
|
|
|
|
if((type = H5Tcreate(H5T_ENUM, sizeof(c_e1))) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "RED", CPTR(val, E1_RED )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE )) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK)) < 0) FAIL_STACK_ERROR
|
|
|
|
|
|
|
|
|
|
if(H5Tget_precision(type) == 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tget_size(type) == 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tget_offset(type) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tget_sign(type) < 0) FAIL_STACK_ERROR
|
|
|
|
|
if(H5Tget_super(type) < 0) FAIL_STACK_ERROR
|
2006-06-27 22:45:06 +08:00
|
|
|
|
|
2006-05-03 03:42:41 +08:00
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
ret=H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
if (ret>=0) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf("Operation not allowed for this type.\n");
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
size=H5Tget_ebias(type);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
if (size>0) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf("Operation not allowed for this type.\n");
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
inpad=H5Tget_inpad(type);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
if (inpad>-1) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf("Operation not allowed for this type.\n");
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
cset=H5Tget_cset(type);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
if (cset>-1) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf("Operation not allowed for this type.\n");
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
size = 16;
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
ret=H5Tset_offset(type, (size_t)size);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
if (ret>=0) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf("Operation not allowed for this type.\n");
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
ret=H5Tset_order(type, H5T_ORDER_BE);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
if (ret>=0) {
|
|
|
|
|
H5_FAILED();
|
|
|
|
|
printf("Operation not allowed for this type.\n");
|
|
|
|
|
goto error;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
if (H5Tclose(type)<0) goto error;
|
|
|
|
|
|
|
|
|
|
PASSED();
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
|
H5Tclose(type);
|
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: main
|
|
|
|
|
*
|
2005-08-14 04:53:35 +08:00
|
|
|
|
* Purpose:
|
1999-01-08 01:14:55 +08:00
|
|
|
|
*
|
2005-08-14 04:53:35 +08:00
|
|
|
|
* Return: Success:
|
1999-01-08 01:14:55 +08:00
|
|
|
|
*
|
2005-08-14 04:53:35 +08:00
|
|
|
|
* Failure:
|
1999-01-08 01:14:55 +08:00
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Tuesday, December 22, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
main(void)
|
|
|
|
|
{
|
|
|
|
|
hid_t fapl=-1, file=-1;
|
|
|
|
|
char name[1024];
|
|
|
|
|
int nerrors=0;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
h5_reset();
|
|
|
|
|
fapl = h5_fileaccess();
|
|
|
|
|
|
|
|
|
|
/* Create the file */
|
|
|
|
|
h5_fixname(FILENAME[0], fapl, name, sizeof name);
|
|
|
|
|
if ((file=H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error;
|
|
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
nerrors += test_named(file);
|
2012-10-18 02:38:38 +08:00
|
|
|
|
nerrors += test_conv(file);
|
1999-01-08 01:14:55 +08:00
|
|
|
|
nerrors += test_tr1(file);
|
|
|
|
|
nerrors += test_tr2(file);
|
2002-06-12 03:34:02 +08:00
|
|
|
|
nerrors += test_value_dsnt_exist();
|
2006-05-03 03:42:41 +08:00
|
|
|
|
nerrors += test_funcs();
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2006-05-03 03:42:41 +08:00
|
|
|
|
H5Fclose(file);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2011-04-16 06:05:23 +08:00
|
|
|
|
/* Verify symbol table messages are cached */
|
|
|
|
|
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
|
|
|
|
|
|
1999-01-08 01:14:55 +08:00
|
|
|
|
if (nerrors) goto error;
|
|
|
|
|
puts("All enum tests passed.");
|
2000-09-10 08:08:27 +08:00
|
|
|
|
h5_cleanup(FILENAME, fapl);
|
1999-01-08 01:14:55 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
puts("*** ENUM TESTS FAILED ***");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|