1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-22 20:35:44 +01:00

modify some tests to use TREXIO_AUTO back end

This commit is contained in:
q-posev 2022-01-25 15:00:55 +01:00
parent a65b22eebb
commit d9309f5ab2
5 changed files with 53 additions and 3 deletions

View File

@ -155,7 +155,7 @@ del test_file
#==========================================================# #==========================================================#
# open previously created TREXIO file, now in 'read' mode # 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 assert test_file2.exists
# check for existence of some of the previously written variables # check for existence of some of the previously written variables

View File

@ -163,7 +163,7 @@ int test_read(const char* file_name, const back_end_t backend) {
/*================= START OF TEST ==================*/ /*================= START OF TEST ==================*/
// open existing file on 'read' mode [created by test_write] // 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); assert (file != NULL);
// read nucleus_num // read nucleus_num

View File

@ -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) { static int test_open_errors (const back_end_t backend) {
/* Try to call trexio_open with bad arguments */ /* Try to call trexio_open with bad arguments */
@ -128,6 +152,7 @@ int main(void) {
test_open_w (TREXIO_FILE, TEST_BACKEND); test_open_w (TREXIO_FILE, TEST_BACKEND);
test_open_r (TREXIO_FILE, TEST_BACKEND); test_open_r (TREXIO_FILE, TEST_BACKEND);
test_open_auto (TREXIO_FILE);
test_open_errors(TEST_BACKEND); test_open_errors(TEST_BACKEND);
test_inquire (TEST_BACKEND); test_inquire (TEST_BACKEND);

View File

@ -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) { static int test_open_errors (const back_end_t backend) {
/* Try to call trexio_open with bad arguments */ /* Try to call trexio_open with bad arguments */
@ -128,6 +152,7 @@ int main(void) {
test_open_w (TREXIO_FILE, TEST_BACKEND); test_open_w (TREXIO_FILE, TEST_BACKEND);
test_open_r (TREXIO_FILE, TEST_BACKEND); test_open_r (TREXIO_FILE, TEST_BACKEND);
test_open_auto (TREXIO_FILE);
test_open_errors(TEST_BACKEND); test_open_errors(TEST_BACKEND);
test_inquire (TEST_BACKEND); test_inquire (TEST_BACKEND);

View File

@ -226,7 +226,7 @@ subroutine test_read(file_name, back_end)
rc = trexio_inquire(file_name) rc = trexio_inquire(file_name)
call trexio_assert(rc, TREXIO_SUCCESS) 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) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_read_nucleus_num(trex_file, num_read) rc = trexio_read_nucleus_num(trex_file, num_read)