summaryrefslogtreecommitdiffstats
path: root/tools/h5dump/h5dumpgentest.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2012-05-23 18:31:42 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2012-05-23 18:31:42 (GMT)
commit588c5107ced043b2fbef5bad6334873d3107722e (patch)
treef4c6c2729b16c89050c5f4ab339257b70ed298c4 /tools/h5dump/h5dumpgentest.c
parent58d14b196b9aef988a6593a01a445e62d92ad636 (diff)
downloadhdf5-588c5107ced043b2fbef5bad6334873d3107722e.zip
hdf5-588c5107ced043b2fbef5bad6334873d3107722e.tar.gz
hdf5-588c5107ced043b2fbef5bad6334873d3107722e.tar.bz2
[svn-r22397] Merge trunk changes for HDFFV-7999 and h5dump test script to branch
Diffstat (limited to 'tools/h5dump/h5dumpgentest.c')
-rw-r--r--tools/h5dump/h5dumpgentest.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 013d63e..98700b0 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -97,6 +97,7 @@
#define FILE65 "tattrreg.h5"
#define FILE66 "packedbits.h5"
#define FILE67 "zerodim.h5"
+#define FILE68 "charsets.h5"
@@ -7096,6 +7097,54 @@ gent_packedbits(void)
}
/*-------------------------------------------------------------------------
+ * Function: gent_charsets
+ *
+ * Purpose: Generate a file to be used in the character set test
+ * Contains:
+ * 1) a ascii datatype
+ * 2) a utf8 datatype
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+gent_charsets(void)
+{
+ hid_t fid, did, sid;
+ herr_t status;
+ hsize_t dim[] = {1}; /* Dataspace dimensions */
+ typedef struct CharSetInfo {
+ const char *ascii_p_;
+ const char *utf8_p_;
+ } CharSetInfo;
+
+ sid = H5Screate_simple( 1, dim, NULL );
+ fid = H5Fcreate( FILE68, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
+
+ hid_t charset_dtid = H5Tcreate( H5T_COMPOUND, sizeof( CharSetInfo ) );
+
+ hid_t ascii_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE );
+ status = H5Tset_cset( ascii_dtid, H5T_CSET_ASCII );
+ H5Tinsert( charset_dtid, "ascii", HOFFSET(CharSetInfo, ascii_p_ ), ascii_dtid );
+
+ hid_t utf8_dtid = H5Tcreate( H5T_STRING, H5T_VARIABLE );
+ status = H5Tset_cset( utf8_dtid, H5T_CSET_UTF8 );
+ H5Tinsert( charset_dtid, "utf8", HOFFSET( CharSetInfo, utf8_p_ ), utf8_dtid );
+
+ did = H5Dcreate2( fid, "CharSets", charset_dtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
+
+ const char * writeData[] = { "ascii", "utf8", };
+ status = H5Dwrite( did, charset_dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, writeData );
+
+ H5Tclose( charset_dtid );
+ H5Tclose( ascii_dtid );
+ H5Tclose( utf8_dtid );
+ H5Sclose( sid );
+ H5Dclose( did );
+ H5Fclose( fid );
+}
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
*-------------------------------------------------------------------------
@@ -7170,6 +7219,7 @@ int main(void)
gent_fpformat();
gent_extlinks();
gent_packedbits();
+ gent_charsets();
return 0;
}