From 4fd3c05d79bbeed1a70ae24ae5236a0fcc76f7ed Mon Sep 17 00:00:00 2001 From: q-posev Date: Tue, 8 Jun 2021 14:39:41 +0200 Subject: [PATCH] add test for truncating strings using max_str_len argument of read_ --- tests/test.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/test.c b/tests/test.c index 3be77a5..719026a 100644 --- a/tests/test.c +++ b/tests/test.c @@ -57,14 +57,14 @@ int test_write(const char* file_name, const back_end_t backend) { const char* label[] = {"C" , "Na", - "C" , + "C asdasdasdas" , "C" , - "C" , + "C 666" , "C" , "H" , "Ru", "H" , - "H" , + "H 999asdasd" , "H" , "H" }; @@ -93,7 +93,7 @@ int test_write(const char* file_name, const back_end_t backend) { assert (rc == TREXIO_SUCCESS); rc = trexio_write_nucleus_coord(file,coord); assert (rc == TREXIO_SUCCESS); - if (backend == TREXIO_HDF5) rc = trexio_write_nucleus_label(file,labelxxx, 4); + if (backend == TREXIO_HDF5) rc = trexio_write_nucleus_label(file,labelxxx, 32); assert (rc == TREXIO_SUCCESS); if (backend == TREXIO_HDF5) rc = trexio_write_nucleus_point_group(file, sym, 32); @@ -181,12 +181,10 @@ int test_read(const char* file_name, const back_end_t backend) { labelxxx = (char*) malloc(num*4*sizeof(char)); - rc = trexio_read_nucleus_label(file,labelxxx, 4); - //rc = trexio_read_nucleus_label(file,label); + rc = trexio_read_nucleus_label(file,labelxxx, 2); assert (rc == TREXIO_SUCCESS); printf("%s\n", labelxxx); - //assert( strcmp(label[1], "Na") == 0 ); char * pch; pch = strtok(labelxxx, TREXIO_DELIM); assert( strcmp(pch, "C") == 0 );