本文整理汇总了C++中H5_FAILED函数的典型用法代码示例。如果您正苦于以下问题:C++ H5_FAILED函数的具体用法?C++ H5_FAILED怎么用?C++ H5_FAILED使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了H5_FAILED函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_1g
/*-------------------------------------------------------------------------
* Function: test_1g
*
* Purpose: It should be impossible to define an unlimited external file
* and then follow it with another external file.
*
* Return: Success: 0
*
* Failure: number of errors
*
* Programmer: Robb Matzke
* Monday, November 23, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
test_1g(void)
{
hid_t dcpl=-1; /*dataset creation properties */
herr_t status; /*function return status */
int n; /*number of external files */
TESTING("external file following unlimited file");
if ((dcpl=H5Pcreate (H5P_DATASET_CREATE)) < 0) goto error;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) goto error;
H5E_BEGIN_TRY {
status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100);
} H5E_END_TRY;
if (status>=0) {
H5_FAILED();
puts (" H5Pset_external() succeeded when it should have failed.");
goto error;
}
if ((n = H5Pget_external_count(dcpl)) < 0) goto error;
if (1!=n) {
H5_FAILED();
puts(" Wrong external file count returned.");
goto error;
}
if (H5Pclose(dcpl) < 0) goto error;
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
} H5E_END_TRY;
return 1;
}
示例2: test_3
/*-------------------------------------------------------------------------
* Function: test_3
*
* Purpose: Creates a few global heap objects and then removes them all.
* The collection should also be removed.
*
* Return: Success: 0
*
* Failure: number of errors
*
* Programmer: Robb Matzke
* Tuesday, March 31, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
test_3 (hid_t fapl)
{
hid_t file = -1;
H5F_t *f = NULL;
H5HG_t obj[1024];
uint8_t out[1024];
int i;
size_t size;
herr_t status;
int nerrors = 0;
char filename[1024];
TESTING("complete object removal");
/* Open a clean file */
h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
if(NULL == (f = (H5F_t *)H5I_object(file))) {
H5_FAILED();
puts(" Unable to create file");
goto error;
}
/* Create some stuff */
for (i=0; i<1024; i++) {
size = i%30+100;
memset (out, 'A'+i%26, size);
H5Eclear2(H5E_DEFAULT);
status = H5HG_insert (f, H5P_DATASET_XFER_DEFAULT, size, out, obj+i);
if (status<0) {
H5_FAILED();
puts(" Unable to insert object into global heap");
nerrors++;
}
}
/* Remove everything */
for (i=0; i<1024; i++) {
status = H5HG_remove (f, H5P_DATASET_XFER_DEFAULT, obj+i);
if (status<0) {
H5_FAILED();
puts(" Unable to remove object");
nerrors++;
}
}
if (H5Fclose(file)<0) goto error;
if (nerrors) goto error;
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Fclose(file);
} H5E_END_TRY;
return MAX(1, nerrors);
}
示例3: test_decrement
/*-------------------------------------------------------------------------
* Function: test_decrement
*
* Purpose: Test operation to decrement bit vector by 1.
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Raymond Lu
* Monday, April 12, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
test_decrement (void)
{
uint8_t vector[8];
size_t offset, size;
int i, j;
ssize_t n;
TESTING("bit decrement operations");
for (i=0; i<NTESTS; i++) {
offset = HDrand() % (8*sizeof vector);
size = (unsigned)HDrand() % (8*sizeof(vector)-offset);
/* Don't want size to be 0 */
if(size == 0) continue;
/* All-zero sequence will become 111111(size=6) after decrement */
memset (vector, 0x00, sizeof vector);
/* decrement the sequence by one */
H5T_bit_dec (vector, offset, size);
/* Look for the ones */
n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1);
if ((size_t)n!=offset) {
H5_FAILED();
printf (" Unable to find first bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
/*
* Look for zeros and ones in reverse order. This is only to test
* that reverse searches work as expected.
*/
n = H5T_bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1);
if (n!=(ssize_t)(offset+size-1)) {
H5_FAILED();
printf (" Unable to find last bit in destination "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
}
PASSED();
return 0;
failed:
printf (" i=%d, offset=%lu, size=%lu\n",
i, (unsigned long)offset, (unsigned long)size);
for (j=sizeof(vector)-1; j>=0; --j) printf ("%02x", vector[j]);
printf ("\n");
return -1;
}
示例4: test_create_close
static int test_create_close(hid_t fid)
{
herr_t err;
hid_t table;
hid_t part_t;
TESTING("H5PTcreate_fl and H5PTclose");
/* Create a datatype for the particle struct */
part_t = make_particle_type();
HDassert(part_t != -1);
/* Create the table */
table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1);
H5Tclose(part_t);
if( H5PTis_valid(table) < 0)
goto error;
if( H5PTis_varlen(table) != 0)
goto error;
/* Close the table */
err = H5PTclose(table);
if( err < 0)
goto error;
PASSED();
return SUCCEED;
error:
H5_FAILED();
return FAIL;
}
示例5: test_1h
/*-------------------------------------------------------------------------
* Function: test_1h
*
* Purpose: It should be impossible to create a set of external files
* whose total size overflows a size_t integer.
*
* Return: Success: 0
*
* Failure: number of errors
*
* Programmer: Robb Matzke
* Monday, November 23, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
test_1h(void)
{
hid_t dcpl=-1; /*dataset creation properties */
herr_t status; /*return status */
TESTING("address overflow in external files");
if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1) < 0) goto error;
H5E_BEGIN_TRY {
status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100);
} H5E_END_TRY;
if (status>=0) {
H5_FAILED();
puts(" H5Pset_external() succeeded when it should have failed.");
goto error;
}
if (H5Pclose(dcpl) < 0) goto error;
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
} H5E_END_TRY;
return 1;
}
示例6: test_open
/*-------------------------------------------------------------------------
* test_open
*
* Tests opening and closing a FL packet table
*
*-------------------------------------------------------------------------
*/
static int test_open(hid_t fid)
{
herr_t err;
hid_t table;
TESTING("H5PTopen");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
if( H5PTis_valid(table) < 0)
goto error;
if( H5PTis_varlen(table) != 0)
goto error;
/* Close the table */
err = H5PTclose(table);
if( err < 0)
goto error;
PASSED();
return SUCCEED;
error:
if (table > 0) H5PTclose(table);
H5_FAILED();
return FAIL;
}
示例7: test_create_close
static int test_create_close(hid_t fid)
{
herr_t err;
hid_t table;
hid_t part_t;
TESTING("H5PTcreate_fl and H5PTclose");
/* Create a datatype for the particle struct */
part_t = make_particle_type();
HDassert(part_t != -1);
/* Create the table */
table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1);
H5Tclose(part_t);
if( H5PTis_valid(table) < 0)
goto out;
#ifdef VLPT_REMOVED
if( H5PTis_varlen(table) != 0)
goto out;
#endif /* VLPT_REMOVED */
/* Close the table */
err = H5PTclose(table);
if( err < 0)
goto out;
PASSED();
return 0;
out:
H5_FAILED();
return -1;
}
示例8: test_open
/*-------------------------------------------------------------------------
* test_open
*
* Tests opening and closing a FL packet table
*
*-------------------------------------------------------------------------
*/
static int test_open(hid_t fid)
{
herr_t err;
hid_t table;
TESTING("H5PTopen");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
if( H5PTis_valid(table) < 0)
goto out;
#ifdef VLPT_REMOVED
if( H5PTis_varlen(table) != 0)
goto out;
#endif /* VLPT_REMOVED */
/* Close the table */
err = H5PTclose(table);
if( err < 0)
goto out;
PASSED();
return 0;
out:
H5_FAILED();
return -1;
}
示例9: test_compounds
/*-------------------------------------------------------------------------
* subroutine for test_text_dtype(): test_compounds().
*-------------------------------------------------------------------------
*/
static int test_compounds(void)
{
hid_t dtype;
int nmembs;
char *memb_name = NULL;
H5T_class_t memb_class;
H5T_class_t type_class;
char* dt_str;
size_t str_len;
TESTING3(" text for compound types");
if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I16BE \"one_field\" : 2; H5T_STD_U8LE \"two_field\" : 6; }", H5LT_DDL))<0)
goto out;
if((type_class = H5Tget_class(dtype))<0)
goto out;
if(type_class != H5T_COMPOUND)
goto out;
if((nmembs = H5Tget_nmembers(dtype))<0)
goto out;
if(nmembs != 2)
goto out;
if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
goto out;
dt_str = (char*)calloc(str_len, sizeof(char));
if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0)
goto out;
if(strcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\" : 2;\n H5T_STD_U8LE \"two_field\" : 6;\n }")) {
printf("dt=\n%s\n", dt_str);
goto out;
}
free(dt_str);
if(H5Tclose(dtype)<0)
goto out;
if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I32BE \"i32_field\"; H5T_STD_I16BE \"i16_field\"; H5T_COMPOUND { H5T_STD_I16BE \"sec_field\"; H5T_COMPOUND { H5T_STD_I32BE \"thd_field\"; } \"grandchild\"; } \"child_compound\"; H5T_STD_I8BE \"i8_field\"; }", H5LT_DDL))<0)
goto out;
if((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
goto out;
if(strcmp(memb_name, "i16_field"))
goto out;
free(memb_name);
if((memb_class = H5Tget_member_class(dtype, 2))<0)
goto out;
if(memb_class != H5T_COMPOUND)
goto out;
PASSED();
return 0;
out:
H5_FAILED();
return -1;
}
示例10: test_duplicatelong_attachscales
static int test_duplicatelong_attachscales(const char *filename)
{
hid_t fid = -1;
hid_t did = -1;
char dsname[32];
char scalename[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al2");
TESTING2("test_duplicatelong_attachscales");
if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset 2 */
if(create_long_dataset(fid, dsname, "al2") < 0)
goto out;
if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
if(test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
if(test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
if(test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
if(test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
if(H5Dclose(did) < 0)
goto out;
}
else
goto out;
PASSED();
H5Fclose(fid);
return SUCCEED;
out:
H5E_BEGIN_TRY {
H5Dclose(did);
H5Fclose(fid);
} H5E_END_TRY;
H5_FAILED();
return FAIL;
}
示例11: test_read_data
/*-------------------------------------------------------------------------
* Function: test_read_data
*
* Purpose: Tests reading data and compares values
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 14 March 2013
*
*-------------------------------------------------------------------------
*/
static herr_t
test_read_data(hid_t dataset, int *origin_data)
{
int check[DSET_DIM1][DSET_DIM2];
const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
int *data_p = origin_data;
size_t i, j; /* Local index variables */
/* Read the dataset back */
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
for(i=0; i<size[0]; i++) {
for(j=0; j<size[1]; j++) {
if(*data_p != check[i][j]) {
H5_FAILED();
fprintf(stderr," Read different values than written.\n");
fprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
fprintf(stderr," At original: %d\n", *data_p);
fprintf(stderr," At returned: %d\n", (int)check[i][j]);
goto error;
}
data_p++;
}
}
PASSED();
return 0;
error:
return -1;
}
示例12: h5_errors
/*-------------------------------------------------------------------------
* Function: h5_errors
*
* Purpose: Displays the error stack after printing "*FAILED*".
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, March 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
h5_errors(hid_t estack, void UNUSED *client_data)
{
H5_FAILED();
H5Eprint2(estack, stdout);
return 0;
}
示例13: test_append
/*-------------------------------------------------------------------------
* test_append
*
* Tests appending packets to a FL packet table
*
*-------------------------------------------------------------------------
*/
static int test_append(hid_t fid)
{
herr_t err;
hid_t table;
hsize_t count;
TESTING("H5PTappend");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
if( H5PTis_valid(table) < 0)
goto out;
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
if( err < 0)
goto out;
/* There should be 0 records in the table */
if( count != 0 )
goto out;
/* Append one particle */
err = H5PTappend(table, (size_t)1, &(testPart[0]));
if( err < 0)
goto out;
/* Append several particles */
err = H5PTappend(table, (size_t)6, &(testPart[1]));
if( err < 0)
goto out;
/* Append one more particle */
err = H5PTappend(table, (size_t)1, &(testPart[7]));
if( err < 0)
goto out;
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
if( err < 0)
goto out;
/* There should be 8 records in the table now */
if( count != 8 )
goto out;
/* Close the table */
err = H5PTclose(table);
if( err < 0)
goto out;
PASSED();
return 0;
out:
H5_FAILED();
if( H5PTis_valid(table) < 0)
H5PTclose(table);
return -1;
}
示例14: test_opaque
/*-------------------------------------------------------------------------
* test_opaque
*
* Tests that the packet table works with an opaque datatype.
*
*-------------------------------------------------------------------------
*/
static int test_opaque(hid_t fid)
{
herr_t err;
hid_t table;
hid_t part_t;
size_t c;
particle_t readBuf[NRECORDS];
TESTING("opaque data");
/* Create an opaque datatype for the particle struct */
if ((part_t = H5Tcreate (H5T_OPAQUE, sizeof(particle_t) )) < 0 )
return -1;
HDassert(part_t != -1);
/* Tag the opaque datatype */
if ( H5Tset_tag(part_t, "Opaque Particle" ) < 0)
return -1;
/* Create a new table */
table = H5PTcreate_fl(fid, "Packet Test Dataset3", part_t, (hsize_t)100, -1);
H5Tclose(part_t);
if( H5PTis_valid(table) < 0)
goto out;
/* Append several particles, starting at particle 1 */
err = H5PTappend(table, (size_t)(NRECORDS - 1), &(testPart[1]));
if( err < 0)
goto out;
/* Read the particles back */
err = H5PTread_packets(table, (hsize_t)0, 7, &(readBuf[0]));
if( err < 0)
goto out;
/* Ensure that particles were read correctly */
for(c=0; c<NRECORDS - 1; c++)
{
if( cmp_par(c+1, c, testPart, readBuf) != 0)
goto out;
}
/* Close the table */
err = H5PTclose(table);
if( err < 0)
goto out;
PASSED();
return 0;
out:
H5_FAILED();
if( H5PTis_valid(table) < 0)
H5PTclose(table);
return -1;
}
示例15: test_noconv
/*-------------------------------------------------------------------------
* Function: test_noconv
*
* Purpose: Tests creation of datasets when no conversion is present.
*
* Return: Success: 0
*
* Failure: number of errors
*
* Programmer: Robb Matzke
* Monday, January 4, 1999
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
test_noconv(hid_t file)
{
hid_t cwg=-1, type=-1, space=-1, dset=-1;
c_e1 val;
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,
E1_RED, E1_WHITE, E1_GREEN, E1_GREEN, E1_BLUE};
c_e1 data2[NELMTS(data1)];
hsize_t ds_size[1]={NELMTS(data1)};
size_t i;
TESTING("no-conversion datasets");
if ((cwg=H5Gcreate(file, "test_noconv", 0))<0) goto error;
if ((type = H5Tcreate(H5T_ENUM, sizeof(c_e1)))<0) goto error;
if (H5Tenum_insert(type, "RED", CPTR(val, E1_RED ))<0) goto error;
if (H5Tenum_insert(type, "GREEN", CPTR(val, E1_GREEN))<0) goto error;
if (H5Tenum_insert(type, "BLUE", CPTR(val, E1_BLUE ))<0) goto error;
if (H5Tenum_insert(type, "WHITE", CPTR(val, E1_WHITE))<0) goto error;
if (H5Tenum_insert(type, "BLACK", CPTR(val, E1_BLACK))<0) goto error;
if ((space=H5Screate_simple(1, ds_size, NULL))<0) goto error;
if ((dset=H5Dcreate(cwg, "color_table", type, space, H5P_DEFAULT))<0)
goto error;
if (H5Dwrite(dset, type, space, space, H5P_DEFAULT, data1)<0) goto error;
if (H5Dread(dset, type, space, space, H5P_DEFAULT, data2)<0) goto error;
for (i=0; i<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) goto error;
if (H5Sclose(space)<0) goto error;
if (H5Tclose(type)<0) goto error;
if (H5Gclose(cwg)<0) goto error;
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Dclose(dset);
H5Sclose(space);
H5Tclose(type);
H5Gclose(cwg);
} H5E_END_TRY;
return 1;
}