diff --git a/python/test/test_api.py b/python/test/test_api.py index 86eb619..a600983 100644 --- a/python/test/test_api.py +++ b/python/test/test_api.py @@ -155,7 +155,7 @@ del test_file #==========================================================# # open previously created TREXIO file, now in 'read' mode -test_file2 = trexio.File(output_filename, 'r', TEST_TREXIO_BACKEND) +test_file2 = trexio.File(output_filename, 'r', trexio.TREXIO_AUTO) assert test_file2.exists # check for existence of some of the previously written variables diff --git a/tests/io_all.c b/tests/io_all.c index d2d1ed2..e476efd 100644 --- a/tests/io_all.c +++ b/tests/io_all.c @@ -163,7 +163,7 @@ int test_read(const char* file_name, const back_end_t backend) { /*================= START OF TEST ==================*/ // open existing file on 'read' mode [created by test_write] - file = trexio_open(file_name, 'r', backend, &rc); + file = trexio_open(file_name, 'r', TREXIO_AUTO, &rc); assert (file != NULL); // read nucleus_num diff --git a/tests/open_hdf5.c b/tests/open_hdf5.c index 7f4ec62..d0a6581 100644 --- a/tests/open_hdf5.c +++ b/tests/open_hdf5.c @@ -57,6 +57,30 @@ static int test_open_r (const char* file_name, const back_end_t backend) { } +static int test_open_auto (const char* file_name) { + +/* Try to open the TREXIO file in 'read' mode */ + + trexio_t* file = NULL; + trexio_exit_code rc; + +/*================= START OF TEST ==================*/ + + // open file in 'write' mode + file = trexio_open(file_name, 'r', TREXIO_AUTO, &rc); + assert (file != NULL); + assert (rc == TREXIO_SUCCESS); + + // close current session + rc = trexio_close(file); + assert (rc == TREXIO_SUCCESS); + +/*================= END OF TEST ==================*/ + + return 0; +} + + static int test_open_errors (const back_end_t backend) { /* Try to call trexio_open with bad arguments */ @@ -128,6 +152,7 @@ int main(void) { test_open_w (TREXIO_FILE, TEST_BACKEND); test_open_r (TREXIO_FILE, TEST_BACKEND); + test_open_auto (TREXIO_FILE); test_open_errors(TEST_BACKEND); test_inquire (TEST_BACKEND); diff --git a/tests/open_text.c b/tests/open_text.c index 4ec7810..130ba91 100644 --- a/tests/open_text.c +++ b/tests/open_text.c @@ -57,6 +57,30 @@ static int test_open_r (const char* file_name, const back_end_t backend) { } +static int test_open_auto (const char* file_name) { + +/* Try to open the TREXIO file in 'read' mode */ + + trexio_t* file = NULL; + trexio_exit_code rc; + +/*================= START OF TEST ==================*/ + + // open file in 'write' mode + file = trexio_open(file_name, 'r', TREXIO_AUTO, &rc); + assert (file != NULL); + assert (rc == TREXIO_SUCCESS); + + // close current session + rc = trexio_close(file); + assert (rc == TREXIO_SUCCESS); + +/*================= END OF TEST ==================*/ + + return 0; +} + + static int test_open_errors (const back_end_t backend) { /* Try to call trexio_open with bad arguments */ @@ -128,6 +152,7 @@ int main(void) { test_open_w (TREXIO_FILE, TEST_BACKEND); test_open_r (TREXIO_FILE, TEST_BACKEND); + test_open_auto (TREXIO_FILE); test_open_errors(TEST_BACKEND); test_inquire (TEST_BACKEND); diff --git a/tests/test_f.f90 b/tests/test_f.f90 index e7d4ee1..bc227ad 100644 --- a/tests/test_f.f90 +++ b/tests/test_f.f90 @@ -226,7 +226,7 @@ subroutine test_read(file_name, back_end) rc = trexio_inquire(file_name) call trexio_assert(rc, TREXIO_SUCCESS) - trex_file = trexio_open(file_name, 'r', back_end, rc) + trex_file = trexio_open(file_name, 'r', TREXIO_AUTO, rc) call trexio_assert(rc, TREXIO_SUCCESS) rc = trexio_read_nucleus_num(trex_file, num_read)