本文整理汇总了C++中TESTING函数的典型用法代码示例。如果您正苦于以下问题:C++ TESTING函数的具体用法?C++ TESTING怎么用?C++ TESTING使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TESTING函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
char filename[1024];
unsigned nerrors = 0;
h5_reset();
TESTING("reading data created on OpenVMS");
h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename);
nerrors += read_data(filename);
TESTING("reading data created on Linux");
h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof filename);
nerrors += read_data(filename);
TESTING("reading data created on Solaris");
h5_fixname(FILENAME[2], H5P_DEFAULT, filename, sizeof filename);
nerrors += read_data(filename);
if (nerrors) {
printf("***** %u FAILURE%s! *****\n",
nerrors, 1==nerrors?"":"S");
HDexit(1);
}
printf("All data type tests passed.\n");
return 0;
}
示例2: test_read_with_filters
/*-------------------------------------------------------------------------
* Function: test_read_with_filters
*
* Purpose: Tests reading dataset created with dynamically loaded filters
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 14 March 2013
*
*-------------------------------------------------------------------------
*/
static herr_t
test_read_with_filters(hid_t file)
{
hid_t dset; /* Dataset ID */
/*----------------------------------------------------------
* STEP 1: Test deflation by itself.
*----------------------------------------------------------
*/
#ifdef H5_HAVE_FILTER_DEFLATE
TESTING("Testing deflate filter");
if(H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) TEST_ERROR
if((dset = H5Dopen2(file,DSET_DEFLATE_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
if(test_read_data(dset, (int *)points_deflate) < 0) TEST_ERROR
if(H5Dclose(dset) < 0) TEST_ERROR
/* Clean up objects used for this test */
#else /* H5_HAVE_FILTER_DEFLATE */
TESTING("deflate filter");
SKIPPED();
puts(" Deflate filter not enabled");
#endif /* H5_HAVE_FILTER_DEFLATE */
/*----------------------------------------------------------
* STEP 2: Test DYNLIB1 by itself.
*----------------------------------------------------------
*/
TESTING("Testing DYNLIB1 filter");
if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
if(test_read_data(dset, (int *)points_dynlib1) < 0) TEST_ERROR
if(H5Dclose(dset) < 0) TEST_ERROR
/*----------------------------------------------------------
* STEP 3: Test Bogus2 by itself.
*----------------------------------------------------------
*/
TESTING("Testing DYNLIB2 filter");
if((dset = H5Dopen2(file,DSET_DYNLIB2_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
if(test_read_data(dset, (int *)points_dynlib2) < 0) TEST_ERROR
if(H5Dclose(dset) < 0) TEST_ERROR
return 0;
error:
return -1;
}
示例3: test_filter_write
/*-------------------------------------------------------------------------
* Function: test_filter_write_failure
*
* Purpose: Tests the library's behavior when a mandate filter returns
* failure. There're only 5 chunks with each of them having
* 2 integers. The filter will fail in the last chunk. The
* dataset should release all resources even though the last
* chunk can't be flushed to file. The file should close
* successfully.
*
* Return:
* Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 25 August 2010
*
* Modifications:
* Raymond Lu
* 5 Oct 2010
* Test when the chunk cache is enable and disabled to make
* sure the library behaves properly.
*-------------------------------------------------------------------------
*/
static herr_t
test_filter_write(char *file_name, hid_t my_fapl, hbool_t cache_enabled)
{
hid_t file = -1;
hid_t dataset=-1; /* dataset ID */
hid_t sid=-1; /* dataspace ID */
hid_t dcpl=-1; /* dataset creation property list ID */
hsize_t dims[1]={DIM}; /* dataspace dimension - 10*/
hsize_t chunk_dims[1]={FILTER_CHUNK_DIM}; /* chunk dimension - 2*/
int points[DIM]; /* Data */
herr_t ret; /* generic return value */
int i;
if(cache_enabled) {
TESTING("data writing when a mandatory filter fails and chunk cache is enabled");
} else {
TESTING("data writing when a mandatory filter fails and chunk cache is disabled");
}
/* Create file */
if((file = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR
/* create the data space */
if((sid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR
/* Create dcpl and register the filter */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) TEST_ERROR
if(H5Zregister (H5Z_FAIL_TEST) < 0) TEST_ERROR
/* Check that the filter was registered */
if(TRUE != H5Zfilter_avail(H5Z_FILTER_FAIL_TEST)) FAIL_STACK_ERROR
/* Enable the filter as mandatory */
if(H5Pset_filter(dcpl, H5Z_FILTER_FAIL_TEST, 0, (size_t)0, NULL) < 0)
TEST_ERROR
/* create a dataset */
if((dataset = H5Dcreate2(file, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR
/* Initialize the write buffer */
for(i = 0; i < DIM; i++)
points[i] = i;
/* Write data. If the chunk cache is enabled, H5Dwrite should succeed. If it is
* diabled, H5Dwrite should fail. */
if(cache_enabled) {
if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, points) < 0)
TEST_ERROR
} else {
示例4: test_1c
/*-------------------------------------------------------------------------
* Function: test_1c
*
* Purpose: Test a single external file which is large enough to
* represent the current data and large enough to represent the
* eventual size of the data.
*
* Return: Success: 0
*
* Failure: number of errors
*
* Programmer: Robb Matzke
* Monday, November 23, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
test_1c(hid_t file)
{
hid_t dcpl=-1; /*dataset creation properties */
hid_t space=-1; /*data space */
hid_t dset=-1; /*dataset */
hsize_t cur_size[1]; /*current data space size */
hsize_t max_size[1]; /*maximum data space size */
TESTING("extendible dataspace, exact external size");
if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) goto error;
cur_size[0] = 100;
max_size[0] = 200;
if(H5Pset_external(dcpl, "ext1.data", (off_t)0,
(hsize_t)(max_size[0] * sizeof(int))) < 0) goto error;
if((space = H5Screate_simple(1, cur_size, max_size)) < 0) goto error;
if((dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
goto error;
if(H5Dclose(dset) < 0) goto error;
if(H5Sclose(space) < 0) goto error;
if(H5Pclose(dcpl) < 0) goto error;
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Dclose(dset);
H5Pclose(dcpl);
H5Sclose(space);
} H5E_END_TRY;
return 1;
}
示例5: 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;
}
示例6: 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;
}
示例7: test_noread_with_filters
/*-------------------------------------------------------------------------
* Function: test_noread_with_filters
*
* Purpose: Tests reading dataset created with dynamically loaded filters disabled
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
static herr_t
test_noread_with_filters(hid_t file)
{
hid_t dset; /* Dataset ID */
unsigned plugin_state; /* status of plugins */
TESTING("Testing DYNLIB1 filter with plugins disabled");
/* disable filter plugin */
if(H5PLget_loading_state(&plugin_state) < 0) TEST_ERROR
plugin_state = plugin_state & ~H5PL_FILTER_PLUGIN;
if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
if(test_noread_data(dset) < 0) TEST_ERROR
if(H5Dclose(dset) < 0) TEST_ERROR
/* re-enable filter plugin */
plugin_state = plugin_state | H5PL_FILTER_PLUGIN;
if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
return 0;
error:
/* re-enable filter plugin */
plugin_state = plugin_state | H5PL_FILTER_PLUGIN;
if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
return -1;
}
示例8: test_allocate_many_small
/*-------------------------------------------------------------------------
* Function: test_allocate_many_small
*
* Purpose: Tests allocating many small blocks in a pool
*
* Return: Success: 0
*
* Failure: 1
*
* Programmer: Quincey Koziol
* Tuesday, May 6, 2005
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
test_allocate_many_small(void)
{
H5MP_pool_t *mp; /* Memory pool */
size_t free_size; /* Free size in pool */
void *spc[MPOOL_NUM_SMALL_BLOCKS]; /* Pointers to space allocated */
int i; /* Local index variable */
/*
* Test memory pool allocation
*/
TESTING("allocating many small blocks");
/* Create a memory pool */
if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
TEST_ERROR
/* Allocate space in pool */
for(i = 0; i < MPOOL_NUM_SMALL_BLOCKS; i++)
if(NULL == (spc[i] = H5MP_malloc(mp, (size_t)MPOOL_SMALL_BLOCK)))
TEST_ERROR
/* Check pool's free space */
if(H5MP_get_pool_free_size(mp, &free_size) < 0)
TEST_ERROR;
if(free_size != MPOOL_PAGE_SIZE - (((H5MP_BLOCK_ALIGN(MPOOL_SMALL_BLOCK) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t))) * MPOOL_NUM_SMALL_BLOCKS) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))))
TEST_ERROR
/* Check that free space totals match */
if (H5MP_pool_is_free_size_correct(mp) <= 0)
TEST_ERROR;
/* Free blocks in pool */
/* (Tests free block merging with block after it */
for(i = (MPOOL_NUM_SMALL_BLOCKS - 1); i >= 0; i--)
H5MP_free(mp, spc[i]);
/* Check pool's free space */
if (H5MP_get_pool_free_size(mp, &free_size) < 0)
TEST_ERROR;
if(free_size != MPOOL_PAGE_SIZE - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))
TEST_ERROR
/* Check that free space totals match */
if (H5MP_pool_is_free_size_correct(mp) <= 0)
TEST_ERROR;
/* Close the memory pool */
if (H5MP_close(mp) < 0)
TEST_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
} H5E_END_TRY;
return 1;
} /* test_allocate_many_small() */
示例9: test_create
/*-------------------------------------------------------------------------
* Function: test_create
*
* Purpose: Creates a named object that refers to indexed storage of raw
* data. No raw data is stored.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
test_create(hid_t f, const char *prefix)
{
hid_t dataset; /* Dataset ID */
hsize_t dims[H5O_LAYOUT_NDIMS+1]; /* Dimensions of dataset */
hsize_t my_chunk_dims[H5O_LAYOUT_NDIMS+1]; /* Dimensions of chunks */
char name[256]; /* Dataset name */
unsigned u; /* Local index variable */
TESTING("istore create");
dims[0] = my_chunk_dims[0] = 1;
for (u = 1; u <= H5S_MAX_RANK; u++) {
/* Initialize the dimension size in this new dimension */
dims[u] = my_chunk_dims[u] = 2;
/* Create chunked dataset of this dimensionality */
HDsnprintf(name, sizeof name, "%s_%02u", prefix, u);
if ((dataset=new_object(f, name, (int)u, dims, my_chunk_dims)) < 0)
return FAIL;
/* Close dataset created */
if(H5Dclose(dataset) < 0)
return FAIL;
}
PASSED();
return SUCCEED;
}
示例10: 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;
}
示例11: test_datasizes
/* Test driver for testing the API SDgetdatasize. */
extern int test_datasizes()
{
int32 fid;
intn status;
int num_errs = 0;
/* Output message about test being performed */
TESTING("getting data size of special data (tdatasizes.c)");
/* Open the file and initialize the SD interface */
fid = SDstart(FILE_NAME, DFACC_CREATE);
CHECK(fid, FAIL, "test_datasizes: SDstart");
/* Test nonspecial SDSs */
num_errs = num_errs + test_nonspecial_SDSs(fid);
/* Test compressed SDSs */
num_errs = num_errs + test_compressed_SDSs(fid);
/* Test chunked empty SDSs */
num_errs = num_errs + test_empty_SDSs(fid);
/* Test chunked_partial SDSs */
num_errs = num_errs + test_chunked_partial(fid);
/* Test chunked SDSs */
num_errs = num_errs + test_chkcmp_SDSs(fid);
/* Test extendable SDSs */
num_errs = num_errs + test_extend_SDSs(fid);
/* Close the file */
status = SDend(fid);
CHECK(status, FAIL, "test_datasizes: SDend");
if (num_errs == 0) PASSED();
return num_errs;
}
示例12: test_large
/*-------------------------------------------------------------------------
* Function: test_large
*
* Purpose: Creates a really large directory.
*
* Return: Success: 0
*
* Failure: number of errors
*
* Programmer: Robb Matzke
* [email protected]
* Aug 29 1997
*
* Modifications:
* Robb Matzke, 2002-03-28
* File is opened by parent instead of here.
*-------------------------------------------------------------------------
*/
static int
test_large(hid_t file)
{
hid_t cwg=-1, dir=-1;
int i;
char name[1024];
int nsyms = 5000;
TESTING("large directories");
/*
* Create a directory that has so many entries that the root
* of the B-tree ends up splitting.
*/
if ((cwg=H5Gcreate(file, "/big", (size_t)nsyms*16+2))<0) goto error;
for (i=0; i<nsyms; i++) {
sprintf(name, "%05d%05d", rand()%100000, i);
#if 0
fprintf(stderr, "%s\n", name);
#endif
if ((dir=H5Gcreate(cwg, name, 0))<0) goto error;
if (H5Gclose(dir)<0) goto error;
}
if (H5Gclose(cwg)<0) goto error;
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Gclose(dir);
H5Gclose(cwg);
} H5E_END_TRY;
return 1;
}
示例13: 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;
}
示例14: 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;
}
示例15: test_close_one
/*-------------------------------------------------------------------------
* Function: test_close_one
*
* Purpose: Tests closing pool with one block allocated
*
* Return: Success: 0
*
* Failure: 1
*
* Programmer: Quincey Koziol
* Friday, May 6, 2005
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
test_close_one(void)
{
H5MP_pool_t *mp; /* Memory pool */
/*
* Test memory pool closing
*/
TESTING("closing pool with blocks still allocated in one page");
/* Create a memory pool */
if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
TEST_ERROR
/* Allocate space in pool */
if(NULL == H5MP_malloc(mp, (size_t)MPOOL_NORMAL_BLOCK))
TEST_ERROR
/* Close the memory pool */
if(H5MP_close(mp) < 0)
TEST_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
} H5E_END_TRY;
return 1;
} /* test_close_one() */