summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2002-03-29 23:46:56 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2002-03-29 23:46:56 (GMT)
commit1c1653aa40acb537d91f37013e5de7ee83e8e052 (patch)
tree2f1f7f3cd1c028ae79265749d890bf1e1d51ba32 /test
parent65d52eaf8e3126d11d8fe2992b12942c01df1776 (diff)
downloadhdf5-1c1653aa40acb537d91f37013e5de7ee83e8e052.zip
hdf5-1c1653aa40acb537d91f37013e5de7ee83e8e052.tar.gz
hdf5-1c1653aa40acb537d91f37013e5de7ee83e8e052.tar.bz2
[svn-r5123]
Purpose: Bug fix(#697) Description: Variable-length string wasn't treated as string. Solution: Added character set and padding into VL string type. Platforms tested: FreeBSD
Diffstat (limited to 'test')
-rw-r--r--test/tvlstr.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/test/tvlstr.c b/test/tvlstr.c
index e17b0c8..3c09746 100644
--- a/test/tvlstr.c
+++ b/test/tvlstr.c
@@ -41,6 +41,8 @@
#define SPACE2_DIM1 10
#define SPACE2_DIM2 10
+#define VLSTR_TYPE "vl_string_type"
+
/* String for testing attributes */
static const char *string_att = "This is the string for the attribute";
@@ -226,6 +228,75 @@ test_vlstrings_basic(void)
/****************************************************************
**
+** test_vlstring_type(): Test VL string type.
+** Tests if VL string is treated as string.
+**
+****************************************************************/
+static void test_vlstring_type(void)
+{
+ hid_t fid; /* HDF5 File IDs */
+ hid_t tid_vlstr, str;
+ H5T_cset_t cset;
+ H5T_str_t pad;
+ size_t size;
+ herr_t ret;
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing VL String type\n"));
+
+ /* Create file */
+ fid = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create a datatype to refer to */
+ tid_vlstr = H5Tcopy(H5T_C_S1);
+ CHECK(tid_vlstr, FAIL, "H5Tcopy");
+
+ /* Change padding and verify it */
+ ret = H5Tset_strpad(tid_vlstr, H5T_STR_NULLPAD);
+ CHECK(ret, FAIL, "H5Tset_strpad");
+ pad = H5Tget_strpad(tid_vlstr);
+ VERIFY(pad, H5T_STR_NULLPAD, "H5Tget_strpad");
+
+ /* Convert to variable-length string */
+ ret = H5Tset_size(tid_vlstr, H5T_VARIABLE);
+ CHECK(ret, FAIL, "H5Tset_size");
+
+ /* Check default character set and padding */
+ cset = H5Tget_cset(tid_vlstr);
+ VERIFY(cset, H5T_CSET_ASCII, "H5Tget_cset");
+ pad = H5Tget_strpad(tid_vlstr);
+ VERIFY(pad, H5T_STR_NULLPAD, "H5Tget_strpad");
+
+ /* Commit variable-length string datatype to storage */
+ ret = H5Tcommit(fid, VLSTR_TYPE, tid_vlstr);
+ CHECK(ret, FAIL, "H5Tcommit");
+
+ /* Close datatype */
+ ret = H5Tclose(tid_vlstr);
+ CHECK(ret, FAIL, "H5Tclose");
+
+
+ /* Open the variable-length string datatype just created */
+ tid_vlstr = H5Topen(fid, VLSTR_TYPE);
+ CHECK(tid_vlstr, FAIL, "H5Topen");
+
+ /* Verify character set and padding */
+ cset = H5Tget_cset(tid_vlstr);
+ VERIFY(cset, H5T_CSET_ASCII, "H5Tget_cset");
+ pad = H5Tget_strpad(tid_vlstr);
+ VERIFY(pad, H5T_STR_NULLPAD, "H5Tget_strpad");
+
+ /* Close datatype and file */
+ ret = H5Tclose(tid_vlstr);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* end test_vlstring_type() */
+
+/****************************************************************
+**
** test_write_vl_string_attribute(): Test basic VL string code.
** Tests writing VL strings as attributes
**
@@ -353,7 +424,9 @@ test_vlstrings(void)
MESSAGE(5, ("Testing Variable-Length Strings\n"));
/* These next tests use the same file */
- test_vlstrings_basic(); /* Test basic VL string datatype */
+ /* Test basic VL string datatype */
+ test_vlstrings_basic();
+ test_vlstring_type();
/* Test using VL strings in attributes */
test_write_vl_string_attribute();