summaryrefslogtreecommitdiffstats
path: root/hl/test/test_lite.c
diff options
context:
space:
mode:
Diffstat (limited to 'hl/test/test_lite.c')
-rw-r--r--hl/test/test_lite.c130
1 files changed, 121 insertions, 9 deletions
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index 7d91267..f4e9aab 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -1049,6 +1049,8 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
static int test_integers(void)
{
hid_t dtype;
+ char* dt_str;
+ size_t str_len;
TESTING3("\n text for integer types");
@@ -1063,6 +1065,16 @@ static int test_integers(void)
goto out;
if(!H5Tequal(dtype, H5T_STD_I8BE))
goto out;
+
+ if(H5LTdtype_to_text(dtype, NULL, &str_len)<0)
+ goto out;
+ dt_str = (char*)calloc(str_len, sizeof(char));
+ if(H5LTdtype_to_text(dtype, dt_str, &str_len)<0)
+ goto out;
+ if(strcmp(dt_str, "H5T_STD_I8BE"))
+ goto out;
+ free(dt_str);
+
if(H5Tclose(dtype)<0)
goto out;
@@ -1088,6 +1100,8 @@ out:
static int test_fps(void)
{
hid_t dtype;
+ char* dt_str;
+ size_t str_len;
TESTING3(" text for floating-point types");
@@ -1102,6 +1116,16 @@ static int test_fps(void)
goto out;
if(!H5Tequal(dtype, H5T_IEEE_F32BE))
goto out;
+
+ if(H5LTdtype_to_text(dtype, NULL, &str_len)<0)
+ goto out;
+ dt_str = (char*)calloc(str_len, sizeof(char));
+ if(H5LTdtype_to_text(dtype, dt_str, &str_len)<0)
+ goto out;
+ if(strcmp(dt_str, "H5T_IEEE_F32BE"))
+ goto out;
+ free(dt_str);
+
if(H5Tclose(dtype)<0)
goto out;
@@ -1131,6 +1155,8 @@ static int test_strings(void)
H5T_str_t str_pad;
H5T_cset_t str_cset;
H5T_class_t type_class;
+ char* dt_str;
+ size_t str_len;
TESTING3(" text for string types");
@@ -1154,15 +1180,26 @@ static int test_strings(void)
if(str_cset != H5T_CSET_ASCII)
goto out;
+ if(H5LTdtype_to_text(dtype, NULL, &str_len)<0)
+ goto out;
+ dt_str = (char*)calloc(str_len, sizeof(char));
+ if(H5LTdtype_to_text(dtype, dt_str, &str_len)<0)
+ goto out;
+ if(strcmp(dt_str, "H5T_STRING {\n CTYPE H5T_C_S1;\n STRSIZE 13;\n STRPAD H5T_STR_NULLTERM;\n CSET H5T_CSET_ASCII;\n }")) {
+ printf("dt=\n%s\n", dt_str);
+ goto out;
+ }
+ free(dt_str);
+
if(H5Tclose(dtype)<0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_STRING { CTYPE H5T_FORTRAN_S1; STRSIZE H5T_VARIABLE; STRPAD H5T_STR_NULLPAD; CSET H5T_CSET_ASCII; }"))<0)
+ if((dtype = H5LTtext_to_dtype("H5T_STRING { CTYPE H5T_C_S1; STRSIZE H5T_VARIABLE; STRPAD H5T_STR_NULLPAD; CSET H5T_CSET_ASCII; }"))<0)
goto out;
if(!H5Tis_variable_str(dtype))
goto out;
-
+
str_pad = H5Tget_strpad(dtype);
if(str_pad != H5T_STR_NULLPAD)
goto out;
@@ -1170,7 +1207,18 @@ static int test_strings(void)
str_cset = H5Tget_cset(dtype);
if(str_cset != H5T_CSET_ASCII)
goto out;
-
+
+ if(H5LTdtype_to_text(dtype, NULL, &str_len)<0)
+ goto out;
+ dt_str = (char*)calloc(str_len, sizeof(char));
+ if(H5LTdtype_to_text(dtype, dt_str, &str_len)<0)
+ goto out;
+ if(strcmp(dt_str, "H5T_STRING {\n CTYPE H5T_C_S1;\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n }")) {
+ printf("dt=\n%s\n", dt_str);
+ goto out;
+ }
+ free(dt_str);
+
if(H5Tclose(dtype)<0)
goto out;
@@ -1192,10 +1240,12 @@ static int test_opaques(void)
size_t opq_size;
char *opq_tag = NULL;
H5T_class_t type_class;
+ char* dt_str;
+ size_t str_len;
TESTING3(" text for opaque types");
- if((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }\n"))<0)
+ if((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }"))<0)
goto out;
if((type_class = H5Tget_class(dtype))<0)
@@ -1214,6 +1264,17 @@ static int test_opaques(void)
goto out;
free(opq_tag);
+ if(H5LTdtype_to_text(dtype, NULL, &str_len)<0)
+ goto out;
+ dt_str = (char*)calloc(str_len, sizeof(char));
+ if(H5LTdtype_to_text(dtype, dt_str, &str_len)<0)
+ goto out;
+ if(strcmp(dt_str, "H5T_OPAQUE {\n OPQ_SIZE 19;\n OPQ_TAG \"This is a tag for opaque type\";\n }")) {
+ printf("dt=\n%s\n", dt_str);
+ goto out;
+ }
+ free(dt_str);
+
if(H5Tclose(dtype)<0)
goto out;
@@ -1238,6 +1299,8 @@ static int test_enums(void)
char *name2 = "WHITE";
int value2;
H5T_class_t type_class;
+ char* dt_str;
+ size_t str_len;
TESTING3(" text for enum types");
@@ -1259,6 +1322,17 @@ static int test_enums(void)
if(value2 != 8)
goto out;
+ if(H5LTdtype_to_text(dtype, NULL, &str_len)<0)
+ goto out;
+ dt_str = (char*)calloc(str_len, sizeof(char));
+ if(H5LTdtype_to_text(dtype, dt_str, &str_len)<0)
+ goto out;
+ /*if(strcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) {
+ printf("dt=\n%s\n", dt_str);
+ goto out;
+ }*/
+ free(dt_str);
+
if(H5Tclose(dtype)<0)
goto out;
@@ -1278,6 +1352,8 @@ static int test_variables(void)
{
hid_t dtype;
H5T_class_t type_class;
+ char* dt_str;
+ size_t str_len;
TESTING3(" text for variable types");
@@ -1295,12 +1371,23 @@ static int test_variables(void)
if(H5Tclose(dtype)<0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_VLEN { H5T_STD_I32BE } }\n"))<0)
+ if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_VLEN { H5T_STD_I32BE } }"))<0)
goto out;
if(H5Tis_variable_str(dtype))
goto out;
+ if(H5LTdtype_to_text(dtype, NULL, &str_len)<0)
+ goto out;
+ dt_str = (char*)calloc(str_len, sizeof(char));
+ if(H5LTdtype_to_text(dtype, dt_str, &str_len)<0)
+ goto out;
+ if(strcmp(dt_str, "H5T_VLEN {\n H5T_VLEN {\n H5T_STD_I32BE\n }\n }")) {
+ printf("dt=\n%s\n", dt_str);
+ goto out;
+ }
+ free(dt_str);
+
if(H5Tclose(dtype)<0)
goto out;
@@ -1322,6 +1409,8 @@ static int test_arrays(void)
int ndims;
hsize_t dims[3];
H5T_class_t type_class;
+ char* dt_str;
+ size_t str_len;
TESTING3(" text for array types");
@@ -1343,10 +1432,20 @@ static int test_arrays(void)
if(dims[0] != 5 || dims[1] != 7 || dims[2] != 13)
goto out;
+ if(H5LTdtype_to_text(dtype, NULL, &str_len)<0)
+ goto out;
+ dt_str = (char*)calloc(str_len, sizeof(char));
+ if(H5LTdtype_to_text(dtype, dt_str, &str_len)<0)
+ goto out;
+ /*if(strcmp(dt_str, "H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE \"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }")) {
+ printf("dt=\n%s\n", dt_str);
+ goto out;
+ }*/
+ free(dt_str);
+
if(H5Tclose(dtype)<0)
goto out;
-
PASSED();
return 0;
@@ -1366,6 +1465,8 @@ static int test_compounds(void)
char *memb_name = NULL;
H5T_class_t memb_class;
H5T_class_t type_class;
+ char* dt_str;
+ size_t str_len;
TESTING3(" text for compound types");
@@ -1381,7 +1482,18 @@ static int test_compounds(void)
goto out;
if(nmembs != 2)
goto out;
-
+
+ if(H5LTdtype_to_text(dtype, NULL, &str_len)<0)
+ goto out;
+ dt_str = (char*)calloc(str_len, sizeof(char));
+ if(H5LTdtype_to_text(dtype, dt_str, &str_len)<0)
+ goto out;
+ if(strcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\";\n H5T_STD_U8LE \"two_field\";\n }")) {
+ printf("dt=\n%s\n", dt_str);
+ goto out;
+ }
+ free(dt_str);
+
if(H5Tclose(dtype)<0)
goto out;
@@ -1417,10 +1529,10 @@ static int test_text_dtype(void)
if(test_integers()<0)
goto out;
-
+
if(test_fps()<0)
goto out;
-
+
if(test_strings()<0)
goto out;