mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-12-23 04:43:57 +01:00
add test to read/append non-existing files
This commit is contained in:
parent
c370434dcf
commit
b8c569f9a3
18
src/test.c
18
src/test.c
@ -91,6 +91,7 @@ int test_h5read() {
|
||||
int64_t num;
|
||||
double* coord;
|
||||
|
||||
// test reading existing file [created by test_h5write()], should work
|
||||
file = trexio_open(file_name, 'r', TREXIO_HDF5);
|
||||
assert (file != NULL);
|
||||
|
||||
@ -112,6 +113,23 @@ int test_h5read() {
|
||||
rc = trexio_close(file);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
|
||||
// test reading non-existing file, should fail and return NULL
|
||||
const char* file_name2 = "test_nonexisting.h5";
|
||||
trexio_t* file2 = NULL;
|
||||
|
||||
file2 = trexio_open(file_name2, 'r', TREXIO_HDF5);
|
||||
assert (file2 == NULL);
|
||||
|
||||
// test appending non-existing file, should create it
|
||||
const char* file_name3 = "test_append.h5";
|
||||
trexio_t* file3 = NULL;
|
||||
|
||||
file3 = trexio_open(file_name3, 'a', TREXIO_HDF5);
|
||||
assert (file3 != NULL);
|
||||
|
||||
rc = trexio_close(file3);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
|
||||
free(coord);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user