summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/CMakeLists.txt7
-rw-r--r--tools/h5dump/h5dumpgentest.c50
-rw-r--r--tools/h5dump/testh5dump.sh.in5
3 files changed, 62 insertions, 0 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt
index a6e452d..ad19ba4 100644
--- a/tools/h5dump/CMakeLists.txt
+++ b/tools/h5dump/CMakeLists.txt
@@ -43,6 +43,7 @@ IF (BUILD_TESTING)
# Copy all the HDF5 files from the test directory into the source directory
# --------------------------------------------------------------------
SET (HDF5_REFERENCE_FILES
+ charsets.ddl
file_space.ddl
filter_fail.ddl
packedbits.ddl
@@ -239,6 +240,7 @@ IF (BUILD_TESTING)
tvlstr.h5.xml
)
SET (HDF5_REFERENCE_TEST_FILES
+ charsets.h5
file_space.h5
filter_fail.h5
packedbits.h5
@@ -676,6 +678,8 @@ IF (BUILD_TESTING)
COMMAND ${CMAKE_COMMAND}
-E remove
h5dump-help.out
+ charsets.out
+ charsets.out.err
file_space.out
file_space.out.err
filter_fail.out
@@ -1060,6 +1064,9 @@ IF (BUILD_TESTING)
# test printing characters in ASCII instead of decimal
ADD_H5_TEST (tchar1 0 --enable-error-stack -r tchar.h5)
+ # test datatypes in ASCII and UTF8
+ ADD_H5_TEST (charsets 0 --enable-error-stack charsets.h5)
+
# rev. 2004
# tests for super block
ADD_H5_TEST (tboot1 0 --enable-error-stack -H -B -d dset tfcontents1.h5)
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index b28f3de..4fab379 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -97,6 +97,7 @@
#define FILE65 "file_space.h5"
#define FILE66 "packedbits.h5"
#define FILE67 "zerodim.h5"
+#define FILE68 "charsets.h5"
@@ -7132,6 +7133,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
*
*-------------------------------------------------------------------------
@@ -7207,6 +7256,7 @@ int main(void)
gent_extlinks();
gent_fs_strategy_threshold();
gent_packedbits();
+ gent_charsets();
return 0;
}
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 5441e25..016b4f1 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -75,6 +75,7 @@ test -d $TESTDIR || mkdir $TESTDIR
# Comment '#' without space can be used.
# --------------------------------------------------------------------
LIST_HDF5_TEST_FILES="
+$SRC_H5DUMP_TESTFILES/charsets.h5
$SRC_H5DUMP_TESTFILES/file_space.h5
$SRC_H5DUMP_TESTFILES/filter_fail.h5
$SRC_H5DUMP_TESTFILES/packedbits.h5
@@ -161,6 +162,7 @@ $SRC_H5DUMP_TESTFILES/tvms.h5
"
LIST_OTHER_TEST_FILES="
+$SRC_H5DUMP_TESTFILES/charsets.ddl
$SRC_H5DUMP_TESTFILES/file_space.ddl
$SRC_H5DUMP_TESTFILES/filter_fail.ddl
$SRC_H5DUMP_TESTFILES/packedbits.ddl
@@ -691,6 +693,9 @@ TOOLTEST tno-subset.ddl --no-compact-subset -d "AHFINDERDIRECT::ah_centroid_t[0]
# test printing characters in ASCII instead of decimal
TOOLTEST tchar1.ddl --enable-error-stack -r tchar.h5
+# test datatypes in ASCII and UTF8
+TOOLTEST charsets.ddl --enable-error-stack charsets.h5
+
# rev. 2004
# tests for super block