diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2021-02-08 16:56:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-08 16:56:16 (GMT) |
commit | 22c67ff6570f16050f0a5654cf1c84df917bb598 (patch) | |
tree | 38fb63aa498b250c2543fe7e22a511706de96a42 /c++/test | |
parent | 551f15f8ae02ca9c995619b216121081eb07633e (diff) | |
download | hdf5-22c67ff6570f16050f0a5654cf1c84df917bb598.zip hdf5-22c67ff6570f16050f0a5654cf1c84df917bb598.tar.gz hdf5-22c67ff6570f16050f0a5654cf1c84df917bb598.tar.bz2 |
1.8/master (#317)hdf5-1_8_22
* Revert incorrect bool type
* Correct grep text for filter test
* Check sizeof type to use correct ref_type
* h5dump reg ref chnages has no error file
* Fix comment
* Remove unneeded files
* Verify the decoded version for "all" and "none" selection.
* Remove double entry
* Add missing include
* Snapshot version 1.8 release 22 (snap4)
Update version to 1.8-snap5
* Fixes for test failures with --disable-tests --disable-tools options.
Don't test ph5diff if tests are disabled.
* Correct conditions for parallel builds with and without tests.
* Snapshot version 1.8 release 22 (snap5)
Update version to 1.8.22-snap6
* TRILAB-192 merging warnings changes from develop
* Autotools reconfigure update
* Restore page ejects.
* Restore page eject chars
* Fix orphaned token
* Update LT files
* Correct extra flags and merge TRILAB-24
* Update release note for CMake warnings
* H5repack bug fixes from develop
* TRILAB-192 - merge changes from develop
Single source, config files, for warnings for both autotools and CMake.
Update CMake libraries, tools, tests to use correct flags.
* Add missing m4 file
* Remove 128bit config check fo 1.8
* TRILAB-192 update LTparse files
* A fix in the cleaning up code for datatype when datatype initialization via H5D__init_type() fails.
The code to fix the problem is the same as what is done in H5D__open_oid().
* Add missing " and update function calls incorrectly
named load_gcc_arguments.
Commit changes to gnu-cxxflags to remove unmatched " and to gnu-fflags
to not add C warnings flags to H5_FCFLAGS.
* TRILAB-192 - cleanup edits and match CMake CXX to autotools
* Fix shadowed type
* TRILAB-192 correct fortran commands
* TRILAB-192 version of std=f2008 special check
* Fix shadow variable
* Add prefix_relto_examplesdir function to set relative path to h5c++.
* TRILAB-192 - parser files cannot handle this warning
* Parallel Fortran tests now use the MPI module instead of including
mpif.h.
* Don't add general warnings flags for unsupported old versions of gcc and
g++ (older than gcc/g++ 4.2).
Correct gnu-cxxflags to determine warnings flags to be added based on
C++ compiler version instead of C compiler version.
* Snapshot version 1.8 release 22 (snap6)
Update version to 1.8.22-snap7
* TRILAB-244 separate CXX warnings and errors from C
* Fix NoFilter build
* Move ADD_H5_FLAGS macro from *CompilerFlags.cmake files to
config/cmake_ext_mod/HDFMacros.cmake for common use.
* Restrict errors to gcc 4.8 and above.
* OESS-65 replace szip with aec szip
* Correct CMake version
* Correct -Werror=unused-variable
* Add -Werror= flags to lists displayed in libhdf5.settings.
* Fix -Werror=unused-variable
* More fixes for unused variable
* Resolve warning errors from -Werror= flags:
-Werror=bad-function-cast
-Werror=bad-function-cast
-Werror=implicit-function-declaration
-Werror=nested-externs
* Remove verbose assignments in smoke_check 3 and 5 functions.
* Update to use optimization flags, C++ error flags, and correct
libhdf5.settings.in to remove unworkable changes.
* Update config/gnu-cxxflags.
* Add missing headers
* Fix ifort warning flag.
Restore AC_DEFUN([PAC_PROG_FC_DEFAULT_REALisDBLE] in m4/aclocal_fc.m4.
Add --enable-symbols, --enable-profiling, and --enable-optimization
options to autotools configure; all configure flags for
--enable-production and --disable-production should match HDF5 1.10 and
1.12 production and debug default flags.
* Add github actions file
* Correct path
* OESS-65 Fix packaging
* Update reference name
* Correct filename
* disable pr action and enable fail fast
* Snapshot 1.8.22-snap7
Update version to 1.8.22-snap8.
* Correct mingw path
* Correct mingw paths
* Revise gnu-*flags and cmake/HDF*CompilerFlags.cmake files to add warning
flags for GCC compilers version 4.8 and above.
Removed files from gnu-warnings that only apply to versions < 4.8.
Consolidated warnings from versions < 4.8 that apply to versions >= 4.8
into the 4.8 warnings files.
* Update MANIFEST for removal of older warnings files.
* Yanked all MPI-1 calls
Added batch scripts in bin/batch.
* Snapshot 1.8.22-snap8.
Update version to 1.8.22-snap9.
* Squashed commit of the following:
commit 45b0cbc71929930a874e1c09e0770aa64d0ae697
Author: Larry Knox <lrknox@hdfgroup.org>
Date: Thu Apr 23 13:14:56 2020 -0500
Add C++ warnings treated as error for autotools builds.
commit 6debcddcc766601799d5bd661bd60946f951a07e
Author: Larry Knox <lrknox@hdfgroup.org>
Date: Fri Jun 19 16:50:03 2020 -0500
Remove tests for develop branch from testh5cc.sh.in.
Add @H5_ECXXFLAGS@ to AM_CXXFLAGS.
commit fed497e7f207313b2a133d3b68c942b7d7104b90
Author: Larry Knox <lrknox@hdfgroup.org>
Date: Fri Jun 12 15:06:39 2020 -0500
Merge pull request #2646 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop
* commit '998c6470d78e14228695419c3b514c35ecf3d69e':
Remove unnecessary version conditions for Clang compilers.
commit 92e52ce5c211bd1d3991a3b8bb67287ac7b652aa
Author: Larry Knox <lrknox@hdfgroup.org>
Date: Wed Jun 10 18:53:45 2020 -0500
Merge pull request #2639 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop
* commit 'a33667faf226f5d8c9633bf537893e8fce1bf1f6':
Add c++ to --enable-sanitize-checks option.
commit 2e802534fb997b81fa98fdd1c7d97d4310898e0d
Author: Larry Knox <lrknox@hdfgroup.org>
Date: Wed Jun 10 15:18:36 2020 -0500
Merge pull request #2633 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop
* commit '20eab963899841c9a003baebead8e3bc07d9e127':
Remove duplicate entries in MANIFEST.
Make changes to CMake CompilerFlags.cmake files so extra flags are loaded for non-GNU compilers.
Update new clang files to not pick up clang as vendor for pgCC. Add new files to MANIFEST Temporary demotion of 2 -Werror warning flags that fail on macos 10.12 Remove Production flag unknown to Apple clang.
commit 96ef60a58a23847a7da89a891f2415055ec2ab60
Author: Larry Knox <lrknox@hdfgroup.org>
Date: Mon Jun 8 16:24:49 2020 -0500
Merge pull request #2631 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop
* commit 'b942a4d8a3e27317cac50ce37ff5302d477664d8':
Clean up code to get clang version in config/linux-gnulibc1
commit 8a7c687da568e8b50b38fa53da1ca63759be6ec4
Author: Larry Knox <lrknox@hdfgroup.org>
Date: Mon Jun 8 11:42:37 2020 -0500
Merge pull request #2623 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop
* commit 'c7626f79fdee4eee13925e240ef41e61f3367eab':
Add flags from config/clang-warnings/*general files to H5 C and CXX flags for all versions of Clang and Clang++ compilers. Switched from cut to awk in testcheck_version.sh.in to avoid dependence on tab vs. " " in version definitions in H5public.h.
Add files for adding warning flags for clang compilers in autotools configure.
commit db3ef7ff3c1ed79167cecef831501411cff8291f
Merge: 5a0f8d7 f9f1310
Author: Larry Knox <lrknox@hdfgroup.org>
Date: Fri Jun 19 14:46:22 2020 -0500
Merge branch 'hdf5_1_12' of https://bitbucket.hdfgroup.org/scm/~lrknox/hdf5_lrk into hdf5_1_12
commit 5a0f8d7940ae57b445f545a0abd7e303ce6924ee
Author: Larry Knox <lrknox@hdfgroup.org>
Date: Wed Jun 10 20:15:41 2020 -0500
Merge pull request #2636 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:HDFFV-11000-update-testh5cc.sh.in-for-version to develop
* commit '5c0bd670d6e9919c463fbc05de99e2ba55b0761e':
Add tests for all version to H5_NO_DEPRECATED_SYMBOLS section and to section for current version, with and without default API version flags.
HDFFV-11000: update-testh5cc.sh.in to test sample versioned functions in HDF5 1.10, 1.12 and develop.
* Update configure and Makefile.ins after bin/reconfigure.
* Fix MANIFEST
* Fix HDFFV-10591
Description:
h52gif produced a segfault when a buffer overflow occurred because
the data size was corrupted and became very large. This commit added
a check on the data size against the buffer size to prevent the segfault.
It also added error reporting to h52gif to display an error message
instead of silently exiting when the failure occurred.
Platforms tested:
Linux/64 (jelly)
* Snapshot 1.8.22-snap9. Update version to 1.8.22-snap10.
* Merge pull request #2686 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop
* commit '800f93f7c994f88dfa716746153ded4b1e690e3a':
Remove path to szip header file from AM_CPPFLAGS when configure check of libsz fails. Fix for HDFFV-10830.
* Regenerate configure.
* Merge from 1.10-1.12-dev - LT parse needs update
* Incorporate pull request #2693 from develop for the fix to HDFFV-11080:
(1) Patch up the file pointer when reading attribute of variable length datatype
(2) Test to verify the fix when doing multiple threads
(3) Update MANIFEST
(4) Add new test to Cmake
* Switch bison and flex update of LT files from bin/genltanalyse to
bin/genparser, and from automatically updating the LT files whenever
reconfigure is run to running only on man<F12>ual command.
* Update hl/sr/H5LT files.
Add bin/genparser to MANIFEST; remove bin/genltanalyze.
* Fix to the merge of PR #2708 for HDFFV-11080 to the 1.8 branch.
Need to checkin test/Makefile.in for the new file added.
* Fix HDFFV-11120 and HDFFV-11121 (CVE-2018-13870 and CVE-2018-13869)
Description:
When a buffer overflow occurred because a name length was corrupted
and became very large, h5dump produced a segfault on one file and a
memcpy parameter overlap on another file. This commit added checks
that detect a read pass the end of the buffer to prevent these error
conditions.
Platforms tested:
Linux/64 (jelly)
* Fixed typo
* Check for header szlib.h only when libsz passes AC_CHECK_LIB, so that
H5_HAVE_SALIB_H is not defined when szip is not enabled, to prevent
compile failures for incompatible szlib.
* HDFFV-11127 - force RTLD_LOCAL in dlopen
* spelling
* Remove extra parens
* Remove unnecessary assignment freom configure.ac.
* Add hypen to subrelease regex
* Add special case when H5_VERS_SUBRELEASE is 0
* Revert H5_VERS_SUBRELEASE check
* The version string has a second use for packaging
* MinGW uses "MinGW Makefiles"
* Snapshot 1.8.22-snap10. Update version to 1.8.22-snap11.
* Merge clang-format changes from develop
* remove stray file
* Source formatted
* Add options to github actions.
* Add back file, remove py file
* HDFFV-11096 Correct h5dump usage text
* Update formating
* remove autogen for 1.8 branch
* Fix comment whitespace
* Change '==' to 'eq' in test script
* Merge from develop
github updates
bin scripts
parser updates
* Snapshot 1.8.22-snap11. Update version to 1.8.22-snap12.
* Merge from 1.10
Comments, whitespace
Simple init and if block brackets.
Minimal code changes limited to return value and spelling
* Update autotools files
* Update FD source
* More merges from 1.10 comments and inits
* Comment fixes
* Fix macro argument
* Remove autogen file and cache dir
* Revert autotools files to previous version
* Correct boolean value and missing define
* URL and options corrections
* revert autoconf files
* Fix compile issues with vfd drivers.
* Fix HDFS test
* Remove extra #endif
* Move init above execution
* Multiple changes to bring branch up-to-date (#87)
Correct TARGET variable and CMake config file location.
Add option to allow filter plugins to be built inline.
Update CMake tools macros.
* hdf5 1 8 release text (#113)
* Multiple changes to bring branch up-to-date
Correct TARGET variable and CMake config file location.
Add option to allow filter plugins to be built inline.
Update CMake tools macros.
* release text updates - mostly whitespace
* Fixed HDFFV-10480 and HDFFV-11159 (#145)
* Fixed HDFFV-10480 and HDFFV-11159
Description
Checked against buffer size to prevent segfault, in case of data corruption.
+ HDFFV-11159 CVE-2018-14033 Buffer over-read in H5O_layout_decode
+ HDFFV-10480 CVE-2018-11206 Buffer over-read in H5O_fill_new[/old]_decode and
A user's patch was applied to this previously, but it is redone
for a more correct fix, that is the check now accounted for the
previous advance of the buffer pointer.
Platforms tested:
Linux/64 (jelly)
* Fixed typo
* Update HDF5 1.8 copyright headers with updated copyright URL (#148)
* Update URL for COPYING file in copyright headers.
* Make fortran copyright headers uniformly spaced.
* Update url for Copyright file in c++/src/footer.html.
* OESS-98 Update plugin build option (#171)
* 1.8 has extra fortran CMake option (#176)
* 1.8 has extra fortran CMake option
* Update license URL
* OESS-98 fix tools test for plugins (#180)
* Hdf5 1 8 (#169)
* Fixed HDFFV-10480 and HDFFV-11159
Description
Checked against buffer size to prevent segfault, in case of data corruption.
+ HDFFV-11159 CVE-2018-14033 Buffer over-read in H5O_layout_decode
+ HDFFV-10480 CVE-2018-11206 Buffer over-read in H5O_fill_new[/old]_decode and
A user's patch was applied to this previously, but it is redone
for a more correct fix, that is the check now accounted for the
previous advance of the buffer pointer.
Platforms tested:
Linux/64 (jelly)
* Fixed typo
* Fixed HDFFV-11150
Description
Replaced an HDassert with a check for null pointer in H5O_dec_rc() to
catch null pointer in corrupted data situation.
Reversed the fix in svn-r24463 in which a check for null pointer prior
to calling H5O_dec_rc()
Platforms tested:
Linux/64 (jelly)
* HDF5 1 8 fix fortran build on macs (#186)
* Correct fortran and shared libs option
* Fix for no shared fortran build
* OESS-98 fix hdf5 link target (#191)
* Partial changes to RELEASE.txt for release. (#185)
* Partial changes to RELEASE.txt for release.
* Update supported and tested platforms.
* Update version to 1.8.22-12.
* close #195. (#196)
* Update HDF5PluginMacros.cmake
* Update HDF5PluginMacros.cmake
* Update directory for SZ filter in HDF5PluginMacros.cmake.
Updates for release:
Switch configure default to production mode.
Set HDF5_GENERATE_HEADERS to OFF.
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Restores maintainer mode in the autotools (#200) (#203)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
* Hdf5 1 8 22 (#212)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Brings ttsafe_attr_vlen.c changes from develop (#214)
Fixes exposed pthread problem on Windows.
* Update SO numbers for Hdf5 1 8 22 (#215)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Hdf5 1 8 22 (#224)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
* Update CMake/HDF5Examples version in bin/release
* Update CMake/HDF5Examples version number in bin/release (#225)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
* Fixed typo in an error message. (#228)
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
* Bring 3 small changes from Hdf5 1.8 to 1.8.22 (#241)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
* Stat st blocks fix 1822 (#251)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
* Fixes Autotools detection of the st_blocks field in stat (#246)
* Fixes Autotools detection of the st_blocks field in stat
The Autotools and CMake will now both correctly determine if the
stat struct has the st_blocks field and set H5_HAVE_STAT_ST_BLOCKS
appropriately.
* Fixes a typo in configure.ac
* Restore lines in RELEASE.txt.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
* Stat st blocks fix 1822 (#256)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
* Fixes Autotools detection of the st_blocks field in stat (#246)
* Fixes Autotools detection of the st_blocks field in stat
The Autotools and CMake will now both correctly determine if the
stat struct has the st_blocks field and set H5_HAVE_STAT_ST_BLOCKS
appropriately.
* Fixes a typo in configure.ac
* Restore lines in RELEASE.txt.
* Updated configure with reconfigure.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
* RELEASE.txt cleanup.
* Hdf5 1 8 22 (#261)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
* RELEASE.txt cleanup.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
* Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14.
* )Update version.
* Hdf5 1 8 22 (#266)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
* RELEASE.txt cleanup.
* Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14.
* )Update version.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
* Reverts lock/unlock callback signature to 1.8.21 version (#254)
* Reverts lock/unlock callback signature to 1.8.21 version
This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs
that have the lock callback implemented and that is just as no-op stubs.
These stubs were removed so the callbacks are now NULL pointers, like
the other VFDs in 1.8.
* Trivial whitespace fix
* Update version to 1.8.22-14.
* Hdf5 1 8 22 - Reverts lock/unlock callback signature to 1.8.21 version (#267)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
* RELEASE.txt cleanup.
* Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14.
* )Update version.
* Reverts lock/unlock callback signature to 1.8.21 version (#254)
* Reverts lock/unlock callback signature to 1.8.21 version
This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs
that have the lock callback implemented and that is just as no-op stubs.
These stubs were removed so the callbacks are now NULL pointers, like
the other VFDs in 1.8.
* Trivial whitespace fix
* Update version to 1.8.22-14.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
* Update version in H5public.h
* Hdf5 1 8 22 (#269)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
* RELEASE.txt cleanup.
* Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14.
* )Update version.
* Reverts lock/unlock callback signature to 1.8.21 version (#254)
* Reverts lock/unlock callback signature to 1.8.21 version
This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs
that have the lock callback implemented and that is just as no-op stubs.
These stubs were removed so the callbacks are now NULL pointers, like
the other VFDs in 1.8.
* Trivial whitespace fix
* Update version to 1.8.22-14.
* Update version in H5public.h
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
* Set version 1.8.22 for release.
* dd RELEASE.txt entry for HDFFV-10741.
* Hdf5 1 8 22 (#279)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
* RELEASE.txt cleanup.
* Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14.
* )Update version.
* Reverts lock/unlock callback signature to 1.8.21 version (#254)
* Reverts lock/unlock callback signature to 1.8.21 version
This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs
that have the lock callback implemented and that is just as no-op stubs.
These stubs were removed so the callbacks are now NULL pointers, like
the other VFDs in 1.8.
* Trivial whitespace fix
* Update version to 1.8.22-14.
* Update version in H5public.h
* Set version 1.8.22 for release.
* dd RELEASE.txt entry for HDFFV-10741.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
* Improve performance of multiple calls to H5Sget_select_elem_pointlist (#270) (#277)
* Cache the pointer to the next point to process after the last call to
H5S__get_select_elem_pointlist. This allows the normal process of
iterating over the points in batches to be much more efficient, as the
library does not need to traverse the entirety of the preceding points
every time the funciton is re-entered.
* Update RELEASE.txt for point selection iteration performance fix.
* Hdf5 1 8 22 (#281)
* Restores maintainer mode in the autotools (#200)
Maintainer mode should be enabled in development branches.
Also adds helpful commenting.
Add bin/switch_maint_mode
Disable maintainer mode for release.
Fix incomplete merge for stub functions in H5Fdhdfs.c
* Update configure for Restores maintainer mode in the autotools (#200).
* Update MANIFEST for switch_maint_mode script.
* Update so numbers for 1.8.22 release.
* Add so numbers changes in Makefile.ins for 1.8.22 release.
* Update pkgconfig settings with version - #218 (#223)
* Add notice of final HDFF5 1.8 release.
Add solaris 64bit alignment issue to "Known Problems".
* Update 1.8 final release notice.
* Update CMake/HDF5Examples version in bin/release
* Fixed typo in an error message. (#227)
* Remove duplicate setting (#239)
* RELEASE.txt cleanup.
* Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14.
* )Update version.
* Reverts lock/unlock callback signature to 1.8.21 version (#254)
* Reverts lock/unlock callback signature to 1.8.21 version
This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs
that have the lock callback implemented and that is just as no-op stubs.
These stubs were removed so the callbacks are now NULL pointers, like
the other VFDs in 1.8.
* Trivial whitespace fix
* Update version to 1.8.22-14.
* Update version in H5public.h
* Set version 1.8.22 for release.
* dd RELEASE.txt entry for HDFFV-10741.
* Improve performance of multiple calls to H5Sget_select_elem_pointlist (#270) (#277)
* Cache the pointer to the next point to process after the last call to
H5S__get_select_elem_pointlist. This allows the normal process of
iterating over the points in batches to be much more efficient, as the
library does not need to traverse the entirety of the preceding points
every time the funciton is re-entered.
* Update RELEASE.txt for point selection iteration performance fix.
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
Co-authored-by: Neil Fortner <nfortne2@hdfgroup.org>
* Hdf5 1 8 22 (#284)
* Fixed typo in an error message.
* Updated for HDFFV-11150, HDFFV-10480, and HDFFV-11159
* Update "Support for New Platforms and Compilers" section in RELEASE.txt;
add check_version workaround for binary compatibility to "Known
Problems".
* Add SUSE Linux to tested platforms.
* Update numbers in config/lt_vers.am and run bin/reconfigure for so
numbers.
* Update version in 3 files missed by merge.
Co-authored-by: Allen Byrne <byrn@hdfgroup.org>
Co-authored-by: Vailin Choi <vchoi@hdfgroup.org>
Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org>
Co-authored-by: hdftest <hdftest@hdfgroup.org>
Co-authored-by: Jordan Henderson <jhenderson@hdfgroup.org>
Co-authored-by: Dana Robinson <derobins@hdfgroup.org>
Co-authored-by: Binh-Minh Ribler <bmribler@hdfgroup.org>
Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com>
Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com>
Co-authored-by: H. Joe Lee <hyoklee@hdfgroup.org>
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: Neil Fortner <nfortne2@hdfgroup.org>
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/CMakeLists.txt | 46 | ||||
-rw-r--r-- | c++/test/CMakeTests.cmake | 61 | ||||
-rw-r--r-- | c++/test/CMakeVFDTests.cmake | 73 | ||||
-rw-r--r-- | c++/test/H5srcdir_str.h.in | 2 | ||||
-rw-r--r-- | c++/test/Makefile.am | 2 | ||||
-rw-r--r-- | c++/test/Makefile.in | 28 | ||||
-rw-r--r-- | c++/test/dsets.cpp | 672 | ||||
-rw-r--r-- | c++/test/h5cpputil.cpp | 101 | ||||
-rw-r--r-- | c++/test/h5cpputil.h | 97 | ||||
-rw-r--r-- | c++/test/tarray.cpp | 232 | ||||
-rw-r--r-- | c++/test/tattr.cpp | 893 | ||||
-rw-r--r-- | c++/test/tcompound.cpp | 466 | ||||
-rw-r--r-- | c++/test/tdspl.cpp | 71 | ||||
-rw-r--r-- | c++/test/testhdf5.cpp | 66 | ||||
-rw-r--r-- | c++/test/tfile.cpp | 469 | ||||
-rw-r--r-- | c++/test/tfilter.cpp | 105 | ||||
-rw-r--r-- | c++/test/th5s.cpp | 303 | ||||
-rw-r--r-- | c++/test/tlinks.cpp | 285 | ||||
-rw-r--r-- | c++/test/tobject.cpp | 177 | ||||
-rw-r--r-- | c++/test/trefer.cpp | 393 | ||||
-rw-r--r-- | c++/test/ttypes.cpp | 262 | ||||
-rw-r--r-- | c++/test/tvlstr.cpp | 286 |
22 files changed, 2554 insertions, 2536 deletions
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index 665a49f..80f7543 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -1,5 +1,6 @@ -cmake_minimum_required (VERSION 3.10) -PROJECT (HDF5_CPP_TEST) +cmake_minimum_required (VERSION 3.12) +project (HDF5_CPP_TEST CXX) + # -------------------------------------------------------------------- # Notes: When creating unit test executables they should be prefixed # with "cpp_". This allows for easier filtering of the test suite when @@ -11,7 +12,7 @@ PROJECT (HDF5_CPP_TEST) #----------------------------------------------------------------------------- # Define Sources #----------------------------------------------------------------------------- -set (CPP_TEST_SRCS +set (CPP_TEST_SOURCES ${HDF5_CPP_TEST_SOURCE_DIR}/testhdf5.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/tarray.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/tattr.cpp @@ -35,16 +36,33 @@ set (CPP_TEST_SRCS set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}) configure_file (${HDF5_CPP_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY) -add_executable (cpp_testhdf5 ${CPP_TEST_SRCS} ) -TARGET_C_PROPERTIES (cpp_testhdf5 STATIC " " " ") -target_link_libraries (cpp_testhdf5 - ${HDF5_CPP_LIB_TARGET} - ${HDF5_LIB_TARGET} - ${HDF5_TEST_LIB_TARGET} -) -set_target_properties (cpp_testhdf5 PROPERTIES - FOLDER test/cpp - INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" +add_executable (cpp_testhdf5 ${CPP_TEST_SOURCES} ${HDF5_CPP_TEST_SOURCE_DIR}/h5cpputil.h) +target_include_directories (cpp_testhdf5 PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_compile_options(cpp_testhdf5 PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") +target_compile_definitions(cpp_testhdf5 + PRIVATE $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings ) +if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (cpp_testhdf5 STATIC) + target_link_libraries (cpp_testhdf5 PRIVATE ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) +else () + TARGET_C_PROPERTIES (cpp_testhdf5 SHARED) + target_link_libraries (cpp_testhdf5 PRIVATE ${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET}) + if (MINGW AND HDF5_MINGW_STATIC_GCC_LIBS) + target_link_options (${HDF5_CPP_LIBSH_TARGET} + PRIVATE -static-libgcc -static-libstdc++ + ) + endif () +endif () +set_target_properties (cpp_testhdf5 PROPERTIES FOLDER test/cpp) + +#----------------------------------------------------------------------------- +# Add Target to clang-format +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_FORMATTERS) + clang_format (HDF5_CPP_TEST_cpp_testhdf5_FORMAT cpp_testhdf5) +endif () -include (CMakeTests.cmake) +if (HDF5_TEST_CPP AND HDF5_TEST_SERIAL) + include (CMakeTests.cmake) +endif () diff --git a/c++/test/CMakeTests.cmake b/c++/test/CMakeTests.cmake index 11463a0..ca5f6bd 100644 --- a/c++/test/CMakeTests.cmake +++ b/c++/test/CMakeTests.cmake @@ -5,7 +5,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -31,9 +31,10 @@ add_test ( ) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME CPP_testhdf5 COMMAND $<TARGET_FILE:cpp_testhdf5>) + add_test (NAME CPP_testhdf5 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:cpp_testhdf5>) else () add_test (NAME CPP_testhdf5 COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$<TARGET_FILE:cpp_testhdf5>" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -46,54 +47,12 @@ else () endif () set_tests_properties (CPP_testhdf5 PROPERTIES DEPENDS CPP_testhdf5-clear-objects) -if (HDF5_TEST_VFD) - - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) - - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () - - macro (ADD_VFD_TEST vfdname resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") - add_test ( - NAME CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tattr_basic.h5 - tattr_compound.h5 - tattr_dtype.h5 - tattr_multi.h5 - tattr_scalar.h5 - tfattrs.h5 - ) - add_test ( - NAME CPP_VFD-${vfdname}-cpp_testhdf5 - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:cpp_testhdf5>" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=cpp_testhdf5" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects) - set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES TIMEOUT 30) - endif () - endmacro () - - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () +############################################################################## +############################################################################## +### V F D T E S T S ### +############################################################################## +############################################################################## +if (HDF5_TEST_VFD) + include (CMakeVFDTests.cmake) endif () diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake new file mode 100644 index 0000000..70556ba --- /dev/null +++ b/c++/test/CMakeVFDTests.cmake @@ -0,0 +1,73 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + +set (VFD_LIST + sec2 + stdio + core + split + multi + family +) + +if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) +endif () + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + +macro (ADD_VFD_TEST vfdname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") + add_test ( + NAME CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove + tattr_basic.h5 + tattr_compound.h5 + tattr_dtype.h5 + tattr_multi.h5 + tattr_scalar.h5 + tfattrs.h5 + titerate.h5 + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${vfdname} + ) + add_test ( + NAME CPP_VFD-${vfdname}-cpp_testhdf5 + COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" + -D "TEST_PROGRAM=$<TARGET_FILE:cpp_testhdf5>" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-cpp_testhdf5.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects) + set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES TIMEOUT ${CTEST_SHORT_TIMEOUT}) + endif () +endmacro () + +# Run test with different Virtual File Driver +foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) +endforeach () diff --git a/c++/test/H5srcdir_str.h.in b/c++/test/H5srcdir_str.h.in index bab1df3..988c065 100644 --- a/c++/test/H5srcdir_str.h.in +++ b/c++/test/H5srcdir_str.h.in @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/c++/test/Makefile.am b/c++/test/Makefile.am index a9fcfdf..1e5091e 100644 --- a/c++/test/Makefile.am +++ b/c++/test/Makefile.am @@ -6,7 +6,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. ## diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in index 4ea9261..aa5352f 100644 --- a/c++/test/Makefile.in +++ b/c++/test/Makefile.in @@ -22,7 +22,7 @@ # This file is part of HDF5. The full HDF5 copyright notice, including # terms governing use, modification, and redistribution, is contained in # the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# distribution tree, or in https://www.hdfgroup.org/licenses. # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # @@ -405,12 +405,12 @@ AMTAR = @AMTAR@ # AM_CFLAGS is an automake construct which should be used by Makefiles # instead of CFLAGS, as CFLAGS is reserved solely for the user to define. # This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well. -AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ +AM_CFLAGS = @AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@ # Include src, test, and c++/src directories AM_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ -I$(top_srcdir)/src \ -I$(top_srcdir)/test -I$(top_srcdir)/c++/src -AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ +AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ @H5_ECXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ AM_LDFLAGS = @AM_LDFLAGS@ @H5_LDFLAGS@ @@ -425,6 +425,7 @@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CC_VERSION = @CC_VERSION@ CFLAGS = @CFLAGS@ +CLANG_SANITIZE_CHECKS = @CLANG_SANITIZE_CHECKS@ CLEARFILEBUF = @CLEARFILEBUF@ CODESTACK = @CODESTACK@ CONFIG_DATE = @CONFIG_DATE@ @@ -443,6 +444,7 @@ DEFAULT_API_VERSION = @DEFAULT_API_VERSION@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@ +DEV_WARNINGS = @DEV_WARNINGS@ DIRECT_VFD = @DIRECT_VFD@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ @@ -470,6 +472,8 @@ GREP = @GREP@ H5_CFLAGS = @H5_CFLAGS@ H5_CPPFLAGS = @H5_CPPFLAGS@ H5_CXXFLAGS = @H5_CXXFLAGS@ +H5_ECFLAGS = @H5_ECFLAGS@ +H5_ECXXFLAGS = @H5_ECXXFLAGS@ H5_FCFLAGS = @H5_FCFLAGS@ H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@ H5_LDFLAGS = @H5_LDFLAGS@ @@ -477,9 +481,12 @@ H5_VERSION = @H5_VERSION@ HADDR_T = @HADDR_T@ HAVE_DMALLOC = @HAVE_DMALLOC@ HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@ +HAVE_LIBHDFS = @HAVE_LIBHDFS@ HAVE_PTHREAD = @HAVE_PTHREAD@ HDF5_HL = @HDF5_HL@ HDF5_INTERFACES = @HDF5_INTERFACES@ +HDF5_TESTS = @HDF5_TESTS@ +HDF5_TOOLS = @HDF5_TOOLS@ HDF_CXX = @HDF_CXX@ HDF_FORTRAN = @HDF_FORTRAN@ HDF_FORTRAN2003 = @HDF_FORTRAN2003@ @@ -495,6 +502,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTRUMENT = @INSTRUMENT@ INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@ +JNI_LDFLAGS = @JNI_LDFLAGS@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ @@ -516,6 +524,7 @@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJECT_NAMELEN_DEFAULT_F = @OBJECT_NAMELEN_DEFAULT_F@ OBJEXT = @OBJEXT@ +OPTIMIZATION = @OPTIMIZATION@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ @@ -528,8 +537,10 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PARALLEL = @PARALLEL@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ +PROFILING = @PROFILING@ RANLIB = @RANLIB@ ROOT = @ROOT@ +ROS3_VFD = @ROS3_VFD@ RUNPARALLEL = @RUNPARALLEL@ RUNSERIAL = @RUNSERIAL@ R_INTEGER = @R_INTEGER@ @@ -543,6 +554,7 @@ STATIC_EXEC = @STATIC_EXEC@ STATIC_SHARED = @STATIC_SHARED@ STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ +SYMBOLS = @SYMBOLS@ TESTPARALLEL = @TESTPARALLEL@ THREADSAFE = @THREADSAFE@ TIME = @TIME@ @@ -584,6 +596,7 @@ docdir = $(exec_prefix)/doc dvidir = @dvidir@ enable_shared = @enable_shared@ enable_static = @enable_static@ +examplesdir = @examplesdir@ exec_prefix = @exec_prefix@ fortran_linux_linker_option = @fortran_linux_linker_option@ host = @host@ @@ -686,11 +699,11 @@ testhdf5_SOURCES = testhdf5.cpp dsets.cpp tattr.cpp tarray.cpp \ # Tell conclude.am that these are C++ tests. CXX_API = yes -# Automake needs to be taught how to build lib, dyn, progs, and tests targets. +# Automake needs to be taught how to build lib, progs and tests targets. # These will be filled in automatically for the most part (e.g., # lib_LIBRARIES are built for lib target), but EXTRA_LIB, EXTRA_PROG, and # EXTRA_TEST variables are supplied to allow the user to force targets to -# be built at certain times. +# be built at certain times. LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \ $(noinst_LTLIBRARIES) $(check_LIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LIB) @@ -1186,6 +1199,7 @@ mostlyclean-local: @if test -d ii_files; then \ $(RM) -rf ii_files; \ fi + # lib/progs/tests targets recurse into subdirectories. build-* targets # build files in this directory. build-lib: $(LIB) @@ -1221,7 +1235,7 @@ all-local: $(EXTRA_LIB) $(EXTRA_PROG) $(chk_TESTS) # make install-doc doesn't do anything outside of doc directory, but # Makefiles should recognize it. # UPDATE: docs no longer reside in this build tree, so this target -# is depreciated. +# is deprecated. install-doc uninstall-doc: @echo "Nothing to be done." @@ -1382,7 +1396,7 @@ build-check-p: $(LIB) $(PROGS) $(chk_TESTS) echo "**** Hint ****"; \ echo "Parallel test files reside in the current directory" \ "by default."; \ - echo "Set HDF5_PARAPREFIX to use another directory. E.g.,"; \ + echo "Set HDF5_PARAPREFIX to use another directory. e.g.,"; \ echo " HDF5_PARAPREFIX=/PFS/user/me"; \ echo " export HDF5_PARAPREFIX"; \ echo " make check"; \ diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 0a187ef..cb6afa7 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -32,28 +32,28 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILE1("dataset.h5"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_DEFAULT_NAME_PATH("/default"); -const H5std_string DSET_CHUNKED_NAME("chunked"); -const H5std_string DSET_SIMPLE_IO_NAME("simple_io"); -const H5std_string DSET_TCONV_NAME ("tconv"); -const H5std_string DSET_COMPRESS_NAME("compressed"); -const H5std_string DSET_BOGUS_NAME ("bogus"); +const H5std_string FILE1("dataset.h5"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_DEFAULT_NAME_PATH("/default"); +const H5std_string DSET_CHUNKED_NAME("chunked"); +const H5std_string DSET_SIMPLE_IO_NAME("simple_io"); +const H5std_string DSET_TCONV_NAME("tconv"); +const H5std_string DSET_COMPRESS_NAME("compressed"); +const H5std_string DSET_BOGUS_NAME("bogus"); /* Temporary filter IDs used for testing */ const int H5Z_FILTER_BOGUS = 305; -static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); +static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf); // H5_ATTR_UNUSED variables caused warning, but taking them out caused failure. - /*------------------------------------------------------------------------- * Function: test_create * @@ -68,10 +68,10 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, * *------------------------------------------------------------------------- */ -const H5std_string DSET_COMMENT ("This is a dataset"); -const H5std_string NON_EXISTING_DSET ("does_not_exist"); +const H5std_string DSET_COMMENT("This is a dataset"); +const H5std_string NON_EXISTING_DSET("does_not_exist"); static herr_t -test_create( H5File& file) +test_create(H5File &file) { SUBTEST("Create, open, close"); @@ -79,18 +79,16 @@ test_create( H5File& file) DataSet *dataset = NULL; try { // Create a data space - hsize_t dims[2]; + hsize_t dims[2]; dims[0] = 256; dims[1] = 512; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a dataset using the default dataset creation properties. - dataset = new DataSet (file.createDataSet - (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); - + dataset = new DataSet(file.createDataSet(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); // Add a comment to the dataset - file.setComment (DSET_DEFAULT_NAME, DSET_COMMENT); + file.setComment(DSET_DEFAULT_NAME, DSET_COMMENT); // Close the dataset delete dataset; @@ -100,18 +98,19 @@ test_create( H5File& file) // dataset can only be created once. If an exception is not thrown for // this action by createDataSet, then throw an invalid action exception. try { - dataset = new DataSet (file.createDataSet - (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); + dataset = new DataSet(file.createDataSet(DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("H5File::createDataSet", + "Library allowed overwrite of existing dataset"); } - catch (FileIException& E) // catching invalid creating dataset - {} // do nothing, exception expected + catch (FileIException &E) // catching invalid creating dataset + { + } // do nothing, exception expected // Open the dataset we created above and then close it. This is one // way to open an existing dataset for accessing. - dataset = new DataSet (file.openDataSet (DSET_DEFAULT_NAME)); + dataset = new DataSet(file.openDataSet(DSET_DEFAULT_NAME)); // Get and verify the name of this dataset, using // H5std_string getObjName() @@ -127,30 +126,31 @@ test_create( H5File& file) delete dataset; // This is another way to open an existing dataset for accessing. - DataSet another_dataset(file.openDataSet (DSET_DEFAULT_NAME)); + DataSet another_dataset(file.openDataSet(DSET_DEFAULT_NAME)); // Try opening a non-existent dataset. This should fail so if an // exception is not thrown for this action by openDataSet, then // display failure information and throw an exception. try { - dataset = new DataSet (file.openDataSet(NON_EXISTING_DSET)); + dataset = new DataSet(file.openDataSet(NON_EXISTING_DSET)); // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::openDataSet", "Attempted to open a non-existent dataset"); } - catch (FileIException& E ) // catching opening non-existent dataset - {} // do nothing, exception expected + catch (FileIException &E) // catching opening non-existent dataset + { + } // do nothing, exception expected // Create a new dataset that uses chunked storage instead of the // default layout. DSetCreatPropList create_parms; - hsize_t csize[2]; + hsize_t csize[2]; csize[0] = 5; csize[1] = 100; - create_parms.setChunk( 2, csize ); + create_parms.setChunk(2, csize); - dataset = new DataSet (file.createDataSet - (DSET_CHUNKED_NAME, PredType::NATIVE_DOUBLE, space, create_parms)); + dataset = + new DataSet(file.createDataSet(DSET_CHUNKED_NAME, PredType::NATIVE_DOUBLE, space, create_parms)); // Note: this one has no error message in C when failure occurs? // clean up and return with success @@ -158,10 +158,9 @@ test_create( H5File& file) PASSED(); return 0; - } // outer most try block + } // outer most try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -171,8 +170,7 @@ test_create( H5File& file) return -1; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_create", __LINE__, __FILE__); // clean up and return with failure @@ -180,9 +178,8 @@ test_create( H5File& file) delete dataset; return -1; } -} // test_create +} // test_create - /*------------------------------------------------------------------------- * Function: test_simple_io * @@ -200,79 +197,75 @@ test_create( H5File& file) *------------------------------------------------------------------------- */ static herr_t -test_simple_io( H5File& file) +test_simple_io(H5File &file) { SUBTEST("Simple I/O"); int points[100][200]; int check[100][200]; - int i, j, n; + int i, j, n; // Initialize the dataset - for (i = n = 0; i < 100; i++) - { + for (i = n = 0; i < 100; i++) { for (j = 0; j < 200; j++) { points[i][j] = n++; } } - char* tconv_buf = new char [1000]; - try - { + char *tconv_buf = new char[1000]; + try { // Create the data space hsize_t dims[2]; dims[0] = 100; dims[1] = 200; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a small conversion buffer to test strip mining DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer(1000, tconv_buf, NULL); // Create the dataset - DataSet dataset (file.createDataSet (DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space)); + DataSet dataset(file.createDataSet(DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space)); // Write the data to the dataset - dataset.write(static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); // Read the dataset back - dataset.read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < 100; i++) - for (j = 0; j < 200; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < 200; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("DataSet::read"); } // clean up and return with success - delete [] tconv_buf; + delete[] tconv_buf; PASSED(); return 0; - } // end try + } // end try // catch all dataset, space, plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; // clean up and return with failure if (tconv_buf) - delete [] tconv_buf; + delete[] tconv_buf; return -1; } -} // test_simple_io +} // test_simple_io - /*------------------------------------------------------------------------- * Function: test_datasize * - * Purpose: Tests DataSet::getInMemDataSize(). + * Purpose: Tests DataSet::getInMemDataSize(). * * Return: Success: 0 * @@ -287,22 +280,20 @@ static herr_t test_datasize(FileAccPropList &fapl) { SUBTEST("DataSet::getInMemDataSize()"); - try - { + try { // Open FILE1. H5File file(FILE1, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); // Open dataset DSET_SIMPLE_IO_NAME. - DataSet dset = file.openDataSet (DSET_SIMPLE_IO_NAME); + DataSet dset = file.openDataSet(DSET_SIMPLE_IO_NAME); // Get the dataset's dataspace to calculate the size for verification. DataSpace space(dset.getSpace()); // Get the dimension sizes. hsize_t dims[2]; - int n_dims = space.getSimpleExtentDims(dims); - if (n_dims < 0) - { + int n_dims = space.getSimpleExtentDims(dims); + if (n_dims < 0) { throw Exception("test_compression", "DataSpace::getSimpleExtentDims() failed"); } @@ -314,8 +305,7 @@ test_datasize(FileAccPropList &fapl) size_t ds_size = dset.getInMemDataSize(); // Verify the data size. - if (ds_size != expected_size) - { + if (ds_size != expected_size) { H5_FAILED(); cerr << " Expected data size = " << expected_size; cerr << " but dset.getInMemDataSize() returned " << ds_size << endl; @@ -324,19 +314,17 @@ test_datasize(FileAccPropList &fapl) PASSED(); return 0; - } // end try + } // end try // catch all dataset, space, plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; return -1; } -} // test_datasize +} // test_datasize - /*------------------------------------------------------------------------- * Function: test_tconv * @@ -352,81 +340,76 @@ test_datasize(FileAccPropList &fapl) *------------------------------------------------------------------------- */ static herr_t -test_tconv(H5File& file) +test_tconv(H5File &file) { // Prepare buffers for input/output - char *out=NULL, *in=NULL; - out = new char [4*1000000]; + char *out = NULL, *in = NULL; + out = new char[4 * 1000000]; // assert (out); - should use exception handler for new - BMR - in = new char [4*1000000]; - //assert (in); + in = new char[4 * 1000000]; + // assert (in); SUBTEST("Data type conversion"); // Initialize the dataset for (int i = 0; i < 1000000; i++) { - out[i*4+0] = 0x11; - out[i*4+1] = 0x22; - out[i*4+2] = 0x33; - out[i*4+3] = 0x44; + out[i * 4 + 0] = 0x11; + out[i * 4 + 1] = 0x22; + out[i * 4 + 2] = 0x33; + out[i * 4 + 3] = 0x44; } - try - { + try { // Create the data space hsize_t dims[1]; dims[0] = 1000000; - DataSpace space (1, dims, NULL); + DataSpace space(1, dims, NULL); // Create the data set - DataSet dataset (file.createDataSet (DSET_TCONV_NAME, PredType::STD_I32LE, space)); + DataSet dataset(file.createDataSet(DSET_TCONV_NAME, PredType::STD_I32LE, space)); // Write the data to the dataset - dataset.write (static_cast<void*>(out), PredType::STD_I32LE); + dataset.write(static_cast<void *>(out), PredType::STD_I32LE); // Read data with byte order conversion - dataset.read (static_cast<void*>(in), PredType::STD_I32BE); + dataset.read(static_cast<void *>(in), PredType::STD_I32BE); // Check for (int i = 0; i < 1000000; i++) { - if (in[4*i+0]!=out[4*i+3] || - in[4*i+1]!=out[4*i+2] || - in[4*i+2]!=out[4*i+1] || - in[4*i+3]!=out[4*i+0]) - { + if (in[4 * i + 0] != out[4 * i + 3] || in[4 * i + 1] != out[4 * i + 2] || + in[4 * i + 2] != out[4 * i + 1] || in[4 * i + 3] != out[4 * i + 0]) { throw Exception("DataSet::read", "Read with byte order conversion failed"); } } // clean up and return with success - delete [] out; - delete [] in; + delete[] out; + delete[] in; PASSED(); return 0; - } // end try + } // end try // catch all dataset and space exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; // clean up and return with failure - delete [] out; - delete [] in; + delete[] out; + delete[] in; return -1; } -} // test_tconv +} // test_tconv /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encode and decode enabled */ - "bogus", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)filter_bogus, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encode and decode enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)filter_bogus, /* The actual filter function */ }}; /*------------------------------------------------------------------------- @@ -444,15 +427,13 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ *------------------------------------------------------------------------- */ static size_t -filter_bogus(unsigned int flags, size_t cd_nelmts, - const unsigned int cd_values[], size_t nbytes, - size_t *buf_size, void **buf) +filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[], size_t nbytes, + size_t *buf_size, void **buf) // H5_ATTR_UNUSED variables caused warning, but taking them out caused failure. { return nbytes; } - /*------------------------------------------------------------------------- * Function: test_compression * @@ -471,68 +452,65 @@ filter_bogus(unsigned int flags, size_t cd_nelmts, *------------------------------------------------------------------------- */ static herr_t -test_compression(H5File& file) +test_compression(H5File &file) { #ifndef H5_HAVE_FILTER_DEFLATE - const char *not_supported; + const char *not_supported; not_supported = " Deflate compression is not enabled."; #endif /* H5_HAVE_FILTER_DEFLATE */ - int points[100][200]; - int check[100][200]; - hsize_t i, j, n; + int points[100][200]; + int check[100][200]; + hsize_t i, j, n; // Initialize the dataset - for (i = n = 0; i < 100; i++) - { + for (i = n = 0; i < 100; i++) { for (j = 0; j < 200; j++) { points[i][j] = (int)n++; } } - char* tconv_buf = new char [1000]; - DataSet* dataset = NULL; - try - { - const hsize_t size[2] = {100, 200}; + char * tconv_buf = new char[1000]; + DataSet *dataset = NULL; + try { + const hsize_t size[2] = {100, 200}; // Create the data space DataSpace space1(2, size, NULL); // Create a small conversion buffer to test strip mining DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer(1000, tconv_buf, NULL); // Use chunked storage with compression DSetCreatPropList dscreatplist; - const hsize_t chunk_size[2] = {2, 25}; - dscreatplist.setChunk (2, chunk_size); - dscreatplist.setDeflate (6); + const hsize_t chunk_size[2] = {2, 25}; + dscreatplist.setChunk(2, chunk_size); + dscreatplist.setDeflate(6); #ifdef H5_HAVE_FILTER_DEFLATE SUBTEST("Compression (setup)"); // Create the dataset - dataset = new DataSet (file.createDataSet - (DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist)); + dataset = + new DataSet(file.createDataSet(DSET_COMPRESS_NAME, PredType::NATIVE_INT, space1, dscreatplist)); PASSED(); /*---------------------------------------------------------------------- - * STEP 1: Read uninitialized data. It should be zero. - *---------------------------------------------------------------------- - */ + * STEP 1: Read uninitialized data. It should be zero. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (uninitialized read)"); - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - for (i=0; i<size[0]; i++) { - for (j=0; j<size[1]; j++) { - if (0!=check[i][j]) { + for (i = 0; i < size[0]; i++) { + for (j = 0; j < size[1]; j++) { + if (0 != check[i][j]) { H5_FAILED(); cerr << " Read a non-zero value." << endl; - cerr << " At index " << (unsigned long)i << "," << - (unsigned long)j << endl; + cerr << " At index " << (unsigned long)i << "," << (unsigned long)j << endl; throw Exception("test_compression", "Failed in uninitialized read"); } } @@ -540,38 +518,36 @@ test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * STEP 2: Test compression by setting up a chunked dataset and writing - * to it. - *---------------------------------------------------------------------- - */ + * STEP 2: Test compression by setting up a chunked dataset and writing + * to it. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (write)"); - for (i=n=0; i<size[0]; i++) - { - for (j=0; j<size[1]; j++) - { + for (i = n = 0; i < size[0]; i++) { + for (j = 0; j < size[1]; j++) { points[i][j] = (int)n++; } } - dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); PASSED(); /*---------------------------------------------------------------------- - * STEP 3: Try to read the data we just wrote. - *---------------------------------------------------------------------- - */ + * STEP 3: Try to read the data we just wrote. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (read)"); // Read the dataset back - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in read"); } @@ -579,31 +555,29 @@ test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * STEP 4: Write new data over the top of the old data. The new data is - * random thus not very compressible, and will cause the chunks to move - * around as they grow. We only change values for the left half of the - * dataset although we rewrite the whole thing. - *---------------------------------------------------------------------- - */ + * STEP 4: Write new data over the top of the old data. The new data is + * random thus not very compressible, and will cause the chunks to move + * around as they grow. We only change values for the left half of the + * dataset although we rewrite the whole thing. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (modify)"); - for (i=0; i<size[0]; i++) - { - for (j=0; j<size[1]/2; j++) - { - points[i][j] = rand (); + for (i = 0; i < size[0]; i++) { + for (j = 0; j < size[1] / 2; j++) { + points[i][j] = rand(); } } - dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); // Read the dataset back and check it - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in modify"); } @@ -611,66 +585,63 @@ test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * STEP 5: Close the dataset and then open it and read it again. This - * insures that the compression message is picked up properly from the - * object header. - *---------------------------------------------------------------------- - */ + * STEP 5: Close the dataset and then open it and read it again. This + * insures that the compression message is picked up properly from the + * object header. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (re-open)"); // close this dataset to reuse the var delete dataset; - dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME)); - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset = new DataSet(file.openDataSet(DSET_COMPRESS_NAME)); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in re-open"); } PASSED(); - /*---------------------------------------------------------------------- - * STEP 6: Test partial I/O by writing to and then reading from a - * hyperslab of the dataset. The hyperslab does not line up on chunk - * boundaries (we know that case already works from above tests). - *---------------------------------------------------------------------- - */ + * STEP 6: Test partial I/O by writing to and then reading from a + * hyperslab of the dataset. The hyperslab does not line up on chunk + * boundaries (we know that case already works from above tests). + *---------------------------------------------------------------------- + */ SUBTEST("Compression (partial I/O)"); - const hsize_t hs_size[2] = {4, 50}; - const hsize_t hs_offset[2] = {7, 30}; + const hsize_t hs_size[2] = {4, 50}; + const hsize_t hs_offset[2] = {7, 30}; for (i = 0; i < hs_size[0]; i++) { for (j = 0; j < hs_size[1]; j++) { - points[hs_offset[0]+i][hs_offset[1]+j] = rand (); + points[hs_offset[0] + i][hs_offset[1] + j] = rand(); } } - space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset ); - dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, space1, space1, xfer); - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, space1, space1, xfer); + space1.selectHyperslab(H5S_SELECT_SET, hs_size, hs_offset); + dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, space1, space1, xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, space1, space1, xfer); // Check that the values read are the same as the values written - for (i=0; i<hs_size[0]; i++) { - for (j=0; j<hs_size[1]; j++) { - if (points[hs_offset[0]+i][hs_offset[1]+j] != - check[hs_offset[0]+i][hs_offset[1]+j]) { - H5_FAILED(); - cerr << " Read different values than written.\n" << endl; - cerr << " At index " << (unsigned long)(hs_offset[0]+i) << - "," << (unsigned long)(hs_offset[1]+j) << endl; - - cerr << " At original: " << (int)points[hs_offset[0]+i][hs_offset[1]+j] << endl; - cerr << " At returned: " << (int)check[hs_offset[0]+i][hs_offset[1]+j] << endl; - throw Exception("test_compression", "Failed in partial I/O"); - } - } // for j - } // for i + for (i = 0; i < hs_size[0]; i++) { + for (j = 0; j < hs_size[1]; j++) { + if (points[hs_offset[0] + i][hs_offset[1] + j] != check[hs_offset[0] + i][hs_offset[1] + j]) { + H5_FAILED(); + cerr << " Read different values than written.\n" << endl; + cerr << " At index " << (unsigned long)(hs_offset[0] + i) << "," + << (unsigned long)(hs_offset[1] + j) << endl; + + cerr << " At original: " << (int)points[hs_offset[0] + i][hs_offset[1] + j] << endl; + cerr << " At returned: " << (int)check[hs_offset[0] + i][hs_offset[1] + j] << endl; + throw Exception("test_compression", "Failed in partial I/O"); + } + } // for j + } // for i delete dataset; dataset = NULL; @@ -684,29 +655,30 @@ test_compression(H5File& file) #endif /*---------------------------------------------------------------------- - * STEP 7: Register an application-defined compression method and use it - * to write and then read the dataset. - *---------------------------------------------------------------------- - */ + * STEP 7: Register an application-defined compression method and use it + * to write and then read the dataset. + *---------------------------------------------------------------------- + */ SUBTEST("Compression (app-defined method)"); - if (H5Zregister (H5Z_BOGUS)<0) - throw Exception("test_compression", "Failed in app-defined method"); - if (H5Pset_filter (dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL)<0) + if (H5Zregister(H5Z_BOGUS) < 0) + throw Exception("test_compression", "Failed in app-defined method"); + if (H5Pset_filter(dscreatplist.getId(), H5Z_FILTER_BOGUS, 0, 0, NULL) < 0) throw Exception("test_compression", "Failed in app-defined method"); - dscreatplist.setFilter (H5Z_FILTER_BOGUS, 0, 0, NULL); + dscreatplist.setFilter(H5Z_FILTER_BOGUS, 0, 0, NULL); - DataSpace space2 (2, size, NULL); - dataset = new DataSet (file.createDataSet (DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist)); + DataSpace space2(2, size, NULL); + dataset = + new DataSet(file.createDataSet(DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist)); - dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write(static_cast<void *>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, + xfer); + dataset->read(static_cast<void *>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_compression", "Failed in app-defined method"); } @@ -714,17 +686,16 @@ test_compression(H5File& file) PASSED(); /*---------------------------------------------------------------------- - * Cleanup - *---------------------------------------------------------------------- - */ + * Cleanup + *---------------------------------------------------------------------- + */ delete dataset; - delete [] tconv_buf; + delete[] tconv_buf; return 0; } // end try // catch all dataset, file, space, and plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -732,12 +703,11 @@ test_compression(H5File& file) if (dataset != NULL) delete dataset; if (tconv_buf) - delete [] tconv_buf; + delete[] tconv_buf; return -1; } -} // test_compression +} // test_compression - /*------------------------------------------------------------------------- * Function: test_nbit_methods * @@ -752,18 +722,19 @@ test_compression(H5File& file) * *------------------------------------------------------------------------- */ -const H5std_string DSET_NBIT_NAME("nbit_dataset"); -const hsize_t DIM1 = 2; -const hsize_t DIM2 = 5; -static herr_t test_nbit_compression(H5File& file) +const H5std_string DSET_NBIT_NAME("nbit_dataset"); +const hsize_t DIM1 = 2; +const hsize_t DIM2 = 5; +static herr_t +test_nbit_compression(H5File &file) { typedef struct { - int i; - char c; + int i; + char c; short s; } s1_t; - const hsize_t size[2] = {DIM1, DIM2}; + const hsize_t size[2] = {DIM1, DIM2}; const hsize_t chunk_size[2] = {DIM1, DIM2}; s1_t orig_data[DIM1][DIM2]; s1_t new_data[DIM1][DIM2]; @@ -771,8 +742,7 @@ static herr_t test_nbit_compression(H5File& file) SUBTEST("N-bit compression (setup)"); - try - { + try { // Define datatypes of members of compound datatype IntType i_type(PredType::NATIVE_INT); IntType c_type(PredType::NATIVE_CHAR); @@ -791,7 +761,7 @@ static herr_t test_nbit_compression(H5File& file) mem_cmpd.insertMember("s", HOFFSET(s1_t, s), s_type); // Set order of dataset compound datatype - //cmpd.setOrder(H5T_ORDER_BE); only for atomic type? + // cmpd.setOrder(H5T_ORDER_BE); only for atomic type? // Create the data space DataSpace space(2, size); @@ -806,36 +776,33 @@ static herr_t test_nbit_compression(H5File& file) // Initialize data, assuming size of long long >= size of member datatypes for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { + for (j = 0; j < size[1]; j++) { orig_data[i][j].i = static_cast<int>(i * j); orig_data[i][j].c = static_cast<char>('a' + i); orig_data[i][j].s = static_cast<short>(i + j); // Some even-numbered integer values are negative - if ((i*size[1]+j+1)%2 == 0) { + if ((i * size[1] + j + 1) % 2 == 0) { orig_data[i][j].i = -orig_data[i][j].i; orig_data[i][j].s = static_cast<short>(-orig_data[i][j].s); } } // Write to the dataset - dataset.write(static_cast<void*>(orig_data), mem_cmpd); + dataset.write(static_cast<void *>(orig_data), mem_cmpd); // Read the dataset back */ - dataset.read(static_cast<void*>(new_data), mem_cmpd); + dataset.read(static_cast<void *>(new_data), mem_cmpd); // Check that the values read are the same as the values written. for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - if((new_data[i][j].i != orig_data[i][j].i) || - (new_data[i][j].c != orig_data[i][j].c) || - (new_data[i][j].s != orig_data[i][j].s)) - { + for (j = 0; j < size[1]; j++) { + if ((new_data[i][j].i != orig_data[i][j].i) || (new_data[i][j].c != orig_data[i][j].c) || + (new_data[i][j].s != orig_data[i][j].s)) { H5_FAILED(); printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", static_cast<unsigned long>(i), static_cast<unsigned long>(j)); + printf(" At index %lu,%lu\n", static_cast<unsigned long>(i), + static_cast<unsigned long>(j)); } } @@ -844,8 +811,7 @@ static herr_t test_nbit_compression(H5File& file) } // end try block // catch all dataset, file, space, and plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -853,7 +819,6 @@ static herr_t test_nbit_compression(H5File& file) } } // test_nbit_compression - /*------------------------------------------------------------------------- * Function: test_multiopen * @@ -872,30 +837,30 @@ static herr_t test_nbit_compression(H5File& file) *------------------------------------------------------------------------- */ static herr_t -test_multiopen (H5File& file) +test_multiopen(H5File &file) { SUBTEST("Multi-open with extending"); - DataSpace* space = NULL; + DataSpace *space = NULL; try { // Create a dataset creation property list DSetCreatPropList dcpl; // Set chunk size to given size - hsize_t cur_size[1] = {10}; - dcpl.setChunk (1, cur_size); + hsize_t cur_size[1] = {10}; + dcpl.setChunk(1, cur_size); // Create a simple data space with unlimited size hsize_t max_size[1] = {H5S_UNLIMITED}; - space = new DataSpace (1, cur_size, max_size); + space = new DataSpace(1, cur_size, max_size); // Create first dataset - DataSet dset1 = file.createDataSet ("multiopen", PredType::NATIVE_INT, *space, dcpl); + DataSet dset1 = file.createDataSet("multiopen", PredType::NATIVE_INT, *space, dcpl); // Open again the first dataset from the file to another DataSet object. - DataSet dset2 = file.openDataSet ("multiopen"); + DataSet dset2 = file.openDataSet("multiopen"); // Relieve the dataspace delete space; @@ -903,17 +868,15 @@ test_multiopen (H5File& file) // Extend the dimensionality of the first dataset cur_size[0] = 20; - dset1.extend (cur_size); + dset1.extend(cur_size); // Get the size from the second handle - space = new DataSpace (dset2.getSpace()); + space = new DataSpace(dset2.getSpace()); - hsize_t tmp_size[1]; - space->getSimpleExtentDims (tmp_size); - if (cur_size[0]!=tmp_size[0]) - { - cerr << " Got " << (int)tmp_size[0] << " instead of " - << (int)cur_size[0] << "!" << endl; + hsize_t tmp_size[1]; + space->getSimpleExtentDims(tmp_size); + if (cur_size[0] != tmp_size[0]) { + cerr << " Got " << (int)tmp_size[0] << " instead of " << (int)cur_size[0] << "!" << endl; throw Exception("test_multiopen", "Failed in multi-open with extending"); } @@ -924,8 +887,7 @@ test_multiopen (H5File& file) } // end try block // catch all dataset, file, space, and plist exceptions - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -934,9 +896,8 @@ test_multiopen (H5File& file) delete space; return -1; } -} // test_multiopen +} // test_multiopen - /*------------------------------------------------------------------------- * Function: test_types * @@ -952,24 +913,24 @@ test_multiopen (H5File& file) *------------------------------------------------------------------------- */ static herr_t -test_types(H5File& file) +test_types(H5File &file) { SUBTEST("Various datatypes"); - size_t i; - DataSet* dset = NULL; + size_t i; + DataSet *dset = NULL; try { // Create a group in the file that was passed in from the caller - Group grp = file.createGroup ("typetests"); + Group grp = file.createGroup("typetests"); /* bitfield_1 */ - unsigned char buf[32]; - hsize_t nelmts = sizeof(buf); - DataType type; + unsigned char buf[32]; + hsize_t nelmts = sizeof(buf); + DataType type; try { // block of bitfield_1 // test copying a predefined type - type.copy (PredType::STD_B8LE); + type.copy(PredType::STD_B8LE); // Test copying a user-defined type using DataType::copy DataType copied_type; @@ -980,7 +941,7 @@ test_types(H5File& file) another_copied_type = type; // Test copying a user-defined int type using DataType::operator= - IntType orig_int(PredType::STD_B8LE); + IntType orig_int(PredType::STD_B8LE); DataType generic_type; generic_type = orig_int; @@ -991,45 +952,45 @@ test_types(H5File& file) IntType another_int_type; another_int_type = new_int_type; - DataSpace space (1, &nelmts); + DataSpace space(1, &nelmts); dset = new DataSet(grp.createDataSet("bitfield_1", type, space)); // Fill buffer - for (i=0; i<sizeof buf; i++) + for (i = 0; i < sizeof buf; i++) buf[i] = (unsigned char)0xff ^ (unsigned char)i; // Write data from buf using all default dataspaces and property list - dset->write (buf, type); + dset->write(buf, type); // no failure in bitfield_1, close this dataset delete dset; } // end try block of bitfield_1 // catch exceptions thrown in try block of bitfield_1 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "bitfield_1: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "bitfield_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; return -1; } /* bitfield_2 */ - nelmts = sizeof(buf)/2; + nelmts = sizeof(buf) / 2; try { // bitfield_2 block - type.copy (PredType::STD_B16LE); - DataSpace space (1, &nelmts); + type.copy(PredType::STD_B16LE); + DataSpace space(1, &nelmts); dset = new DataSet(grp.createDataSet("bitfield_2", type, space)); // Fill buffer - for (i=0; i<sizeof(buf); i++) + for (i = 0; i < sizeof(buf); i++) buf[i] = (unsigned char)0xff ^ (unsigned char)i; // Write data from buf using all default dataspaces and property // list; if writing fails, deallocate dset and return. - dset->write (buf, type); + dset->write(buf, type); // no failure in bitfield_2, close this dataset and reset for // variable reuse @@ -1038,44 +999,46 @@ test_types(H5File& file) } // end try block of bitfield_2 // catch exceptions thrown in try block of bitfield_2 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "bitfield_2: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "bitfield_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; throw E; // propagate the exception } /* opaque_1 */ - DataType* optype = NULL; + DataType *optype = NULL; try { // opaque_1 block optype = new DataType(H5T_OPAQUE, 1); nelmts = sizeof(buf); - DataSpace space (1, &nelmts); - optype->setTag ("testing 1-byte opaque type"); + DataSpace space(1, &nelmts); + optype->setTag("testing 1-byte opaque type"); dset = new DataSet(grp.createDataSet("opaque_1", *optype, space)); // Fill buffer - for (i=0; i<sizeof buf; i++) + for (i = 0; i < sizeof buf; i++) buf[i] = (unsigned char)0xff ^ (unsigned char)i; // Write data from buf using all default dataspaces and property // list; if writing fails, deallocate dset and return. - dset->write (buf, *optype); + dset->write(buf, *optype); // no failure in opaque_1 - delete dset; dset = NULL; - delete optype; optype = NULL; + delete dset; + dset = NULL; + delete optype; + optype = NULL; } // end try block of opaque_1 // catch exceptions thrown in try block of opaque_1 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "opaque_1: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "opaque_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; if (optype != NULL) @@ -1085,31 +1048,33 @@ test_types(H5File& file) /* opaque_2 */ try { // block opaque_2 - nelmts = sizeof(buf)/4; - DataSpace space (1, &nelmts); + nelmts = sizeof(buf) / 4; + DataSpace space(1, &nelmts); optype = new DataType(H5T_OPAQUE, 4); - optype->setTag ("testing 4-byte opaque type"); + optype->setTag("testing 4-byte opaque type"); dset = new DataSet(grp.createDataSet("opaque_2", *optype, space)); // Fill buffer - for (i=0; i<sizeof(buf); i++) + for (i = 0; i < sizeof(buf); i++) buf[i] = (unsigned char)0xff ^ (unsigned char)i; // Write data from buf using all default dataspaces and property // list; if writing fails, deallocate dset and return. - dset->write (buf, *optype); + dset->write(buf, *optype); // no failure in opaque_1 - delete dset; dset = NULL; - delete optype; optype = NULL; - } //end try block of opaque_2 + delete dset; + dset = NULL; + delete optype; + optype = NULL; + } // end try block of opaque_2 // catch exceptions thrown in try block of opaque_2 - catch (Exception& E) - { + catch (Exception &E) { cerr << " FAILED" << endl; - cerr << " <<< " << "opaque_2: " << E.getFuncName() - << " - " << E.getDetailMsg() << " >>>" << endl << endl; + cerr << " <<< " + << "opaque_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl + << endl; if (dset != NULL) delete dset; if (optype != NULL) @@ -1121,13 +1086,11 @@ test_types(H5File& file) return 0; } // end top try block - catch (Exception& E) - { + catch (Exception &E) { return -1; } -} // test_types +} // test_types - /*------------------------------------------------------------------------- * Function: test_dset * @@ -1150,16 +1113,15 @@ test_types(H5File& file) * *------------------------------------------------------------------------- */ -extern "C" -void test_dset() +extern "C" void +test_dset() { - hid_t fapl_id; + hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template - int nerrors=0; // keep track of number of failures occurr + int nerrors = 0; // keep track of number of failures occurr - try - { + try { // Use the file access template id to create a file access prop. // list object to pass in H5File::H5File FileAccPropList fapl(fapl_id); @@ -1167,16 +1129,16 @@ void test_dset() H5File file(FILE1, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Cause the library to emit initial messages - Group grp = file.createGroup( "emit diagnostics", 0); + Group grp = file.createGroup("emit diagnostics", 0); grp.setComment("Causes diagnostic messages to be emitted"); - nerrors += test_create(file) < 0 ? 1:0; - nerrors += test_simple_io(file) < 0 ? 1:0; - nerrors += test_tconv(file) < 0 ? 1:0; - nerrors += test_compression(file) < 0 ? 1:0; - nerrors += test_nbit_compression(file) < 0 ? 1:0; - nerrors += test_multiopen (file) < 0 ? 1:0; - nerrors += test_types(file) < 0 ? 1:0; + nerrors += test_create(file) < 0 ? 1 : 0; + nerrors += test_simple_io(file) < 0 ? 1 : 0; + nerrors += test_tconv(file) < 0 ? 1 : 0; + nerrors += test_compression(file) < 0 ? 1 : 0; + nerrors += test_nbit_compression(file) < 0 ? 1 : 0; + nerrors += test_multiopen(file) < 0 ? 1 : 0; + nerrors += test_types(file) < 0 ? 1 : 0; // Close group "emit diagnostics". grp.close(); @@ -1184,16 +1146,15 @@ void test_dset() // Close the file before testing data size. file.close(); - nerrors += test_datasize(fapl) <0 ? 1:0; + nerrors += test_datasize(fapl) < 0 ? 1 : 0; } - catch (Exception& E) - { + catch (Exception &E) { test_report(nerrors, H5std_string(" Dataset")); } // Clean up data file cleanup_dsets(); -} // test_dset +} // test_dset /*------------------------------------------------------------------------- * Function: cleanup_dsets @@ -1206,9 +1167,8 @@ void test_dset() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_dsets() +extern "C" void +cleanup_dsets() { HDremove(FILE1.c_str()); } // cleanup_dsets - diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp index 9f81895..a0dd077 100644 --- a/c++/test/h5cpputil.cpp +++ b/c++/test/h5cpputil.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,13 +28,12 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5test.h" #include "h5cpputil.h" - /*------------------------------------------------------------------------- * Function: test_report * @@ -51,24 +50,21 @@ using namespace H5; * *------------------------------------------------------------------------- */ -int test_report( int nerrors, const H5std_string& testname ) +int +test_report(int nerrors, const H5std_string &testname) { - if (nerrors) - { - nerrors = MAX(1, nerrors); + if (nerrors) { + nerrors = MAX(1, nerrors); if (1 == nerrors) - cerr << "***** " << nerrors << testname - << " TEST FAILED! *****" << endl; + cerr << "***** " << nerrors << testname << " TEST FAILED! *****" << endl; else - cerr << "***** " << nerrors << testname - << " TESTS FAILED! *****" << endl; - return 1; - } - else - { - cerr << "All" << testname << " tests passed." << endl; - return 0; - } + cerr << "***** " << nerrors << testname << " TESTS FAILED! *****" << endl; + return 1; + } + else { + cerr << "All" << testname << " tests passed." << endl; + return 0; + } } /*------------------------------------------------------------------------- @@ -83,14 +79,14 @@ int test_report( int nerrors, const H5std_string& testname ) * *------------------------------------------------------------------------- */ -void issue_fail_msg(const char* where, int line, const char* file_name, - const char* message) +void +issue_fail_msg(const char *where, int line, const char *file_name, const char *message) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << ">>> FAILED in " << where << " at line " << line - << " in " << file_name << " - " << message << endl << endl; + cerr << ">>> FAILED in " << where << " at line " << line << " in " << file_name << " - " << message + << endl + << endl; } } @@ -106,15 +102,15 @@ void issue_fail_msg(const char* where, int line, const char* file_name, * *------------------------------------------------------------------------- */ -void issue_fail_msg(const char* where, int line, const char* file_name, - const char* func_name, const char* message) +void +issue_fail_msg(const char *where, int line, const char *file_name, const char *func_name, const char *message) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << ">>> FAILED in " << where << ": " << func_name << endl << - " at line " << line << " in " << file_name << endl << - " C library detail: " << message << endl << endl; + cerr << ">>> FAILED in " << where << ": " << func_name << endl + << " at line " << line << " in " << file_name << endl + << " C library detail: " << message << endl + << endl; } } @@ -137,13 +133,13 @@ void issue_fail_msg(const char* where, int line, const char* file_name, * *------------------------------------------------------------------------- */ -int check_values (hsize_t i, hsize_t j, int apoint, int acheck) +int +check_values(hsize_t i, hsize_t j, int apoint, int acheck) { - if (apoint != acheck) - { + if (apoint != acheck) { cerr << " Read different values than written.\n" << endl; - cerr << " At index " << static_cast<unsigned long>(i) << "," << - static_cast<unsigned long>(j) << endl; + cerr << " At index " << static_cast<unsigned long>(i) << "," << static_cast<unsigned long>(j) + << endl; return -1; } return 0; @@ -165,20 +161,18 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck) * *------------------------------------------------------------------------- */ -void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name) +void +verify_val(const char *x, const char *value, const char *where, int line, const char *file_name) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value " + << x << endl; } - if (strcmp(x, value) != 0) - { + if (strcmp(x, value) != 0) { cerr << endl; - cerr << "*** UNEXPECTED VALUE from " << where << " should be " - << value << ", but is " << x << " at line " << line - << " in " << file_name << endl; + cerr << "*** UNEXPECTED VALUE from " << where << " should be " << value << ", but is " << x + << " at line " << line << " in " << file_name << endl; IncTestNumErrs(); throw TestFailedException(where, ""); } @@ -187,7 +181,7 @@ void verify_val(const char* x, const char* value, const char* where, int line, c //-------------------------------------------------------------------------- // Function: InvalidActionException default constructor //-------------------------------------------------------------------------- -InvalidActionException::InvalidActionException():Exception(){} +InvalidActionException::InvalidActionException() : Exception() {} //-------------------------------------------------------------------------- // Function: InvalidActionException overloaded constructor @@ -199,7 +193,10 @@ InvalidActionException::InvalidActionException():Exception(){} // func - IN: Name of the function where failure should occur // message - IN: Message //-------------------------------------------------------------------------- -InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message) : Exception(func, message) {} +InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: InvalidActionException destructor @@ -209,7 +206,7 @@ InvalidActionException::~InvalidActionException() throw() {} //-------------------------------------------------------------------------- // Function: TestFailedException default constructor //-------------------------------------------------------------------------- -TestFailedException::TestFailedException():Exception(){} +TestFailedException::TestFailedException() : Exception() {} //-------------------------------------------------------------------------- // Function: TestFailedException overloaded constructor @@ -221,10 +218,12 @@ TestFailedException::TestFailedException():Exception(){} // func - IN: Name of the function where failure should occur // message - IN: Message //-------------------------------------------------------------------------- -TestFailedException::TestFailedException(const H5std_string func, const H5std_string message) : Exception(func, message) {} +TestFailedException::TestFailedException(const H5std_string func, const H5std_string message) + : Exception(func, message) +{ +} //-------------------------------------------------------------------------- // Function: TestFailedException destructor //-------------------------------------------------------------------------- TestFailedException::~TestFailedException() throw() {} - diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h index 53f1663..1f93290 100644 --- a/c++/test/h5cpputil.h +++ b/c++/test/h5cpputil.h @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -31,91 +31,94 @@ using std::cerr; using std::endl; #endif -#define MESSAGE(V,A) {if (HDGetTestVerbosity()>(V)) print_func A;} -#define SUBTEST(TEST) {printf(" Subtest: %-52s",TEST); fflush(stdout);} +#define MESSAGE(V, A) \ + { \ + if (HDGetTestVerbosity() > (V)) \ + print_func A; \ + } +#define SUBTEST(TEST) \ + { \ + printf(" Subtest: %-52s", TEST); \ + fflush(stdout); \ + } -int check_values (hsize_t i, hsize_t j, int apoint, int acheck); -int test_report (int, const H5std_string&); -void issue_fail_msg(const char* where, int line, const char* file_name, - const char* message=""); -void issue_fail_msg(const char* where, int line, const char* file_name, - const char* func_name, const char* message); +int check_values(hsize_t i, hsize_t j, int apoint, int acheck); +int test_report(int, const H5std_string &); +void issue_fail_msg(const char *where, int line, const char *file_name, const char *message = ""); +void issue_fail_msg(const char *where, int line, const char *file_name, const char *func_name, + const char *message); class InvalidActionException : public Exception { - public: - InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); - InvalidActionException(); - virtual ~InvalidActionException() throw(); + public: + InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); + InvalidActionException(); + virtual ~InvalidActionException() throw(); }; class TestFailedException : public Exception { - public: - TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); - TestFailedException(); - virtual ~TestFailedException() throw(); + public: + TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG); + TestFailedException(); + virtual ~TestFailedException() throw(); }; // Overloaded/Template functions to verify values and display proper info -void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name); +void verify_val(const char *x, const char *value, const char *where, int line, const char *file_name); template <class Type1, class Type2> - void verify_val(Type1 x, Type2 value, const char* where, int line, const char* file_name) +void +verify_val(Type1 x, Type2 value, const char *where, int line, const char *file_name) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value " + << x << endl; } - if (x != value) - { + if (x != value) { cerr << endl; - cerr << "*** UNEXPECTED VALUE from " << where << " should be " - << value << ", but is " << x << " at line " << line - << " in " << file_name << endl; + cerr << "*** UNEXPECTED VALUE from " << where << " should be " << value << ", but is " << x + << " at line " << line << " in " << file_name << endl; IncTestNumErrs(); throw TestFailedException(where, ""); } } template <class Type1, class Type2> - void verify_val(Type1 x, Type2 value, const char* msg, const char* file_name, int line) +void +verify_val(Type1 x, Type2 value, const char *msg, const char *file_name, int line) { - if (x != value) - { + if (x != value) { cerr << endl; - cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line - << ":" << msg << " different: " << x << ", should be " << value - << endl; + cerr << "*** UNEXPECTED VALUE: " << file_name << ":line " << line << ":" << msg << " different: " << x + << ", should be " << value << endl; IncTestNumErrs(); throw TestFailedException(file_name, msg); } } template <class Type1, class Type2> - void verify_val_noteq(Type1 x, Type2 value, const char* where, int line, const char* file_name) +void +verify_val_noteq(Type1 x, Type2 value, const char *where, int line, const char *file_name) { - if (GetTestVerbosity()>=VERBO_HI) - { + if (GetTestVerbosity() >= VERBO_HI) { cerr << endl; - cerr << " Call to routine: " << where << " at line " << line - << " in " << file_name << " had value " << x << endl; + cerr << " Call to routine: " << where << " at line " << line << " in " << file_name << " had value " + << x << endl; } - if (x == value) - { + if (x == value) { cerr << endl; - cerr << "*** UNEXPECTED VALUE from " << where << " should not be " - << value << " at line " << line << " in " << file_name << endl; + cerr << "*** UNEXPECTED VALUE from " << where << " should not be " << value << " at line " << line + << " in " << file_name << endl; IncTestNumErrs(); throw TestFailedException(where, ""); } } template <class Type1, class Type2> - void CHECK(Type1 x, Type2 value, const char* msg, int line, const char* file_name) +void +CHECK(Type1 x, Type2 value, const char *msg, int line, const char *file_name) { - if (x == value) - { + if (x == value) { cerr << endl; cerr << "*** Function " << msg << " FAILED at line " << line << endl; IncTestNumErrs(); @@ -123,7 +126,6 @@ template <class Type1, class Type2> } } - /* Prototypes for the test routines */ extern "C" { void test_array(); @@ -154,7 +156,6 @@ void cleanup_object(); void cleanup_reference(); void cleanup_types(); void cleanup_vlstrings(); - } /* not yet diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index 218e4e5..07b60af 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,28 +26,35 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILENAME("tarray.h5"); -const H5std_string ARRAYTYPE_NAME("/Array type 1"); -const int SPACE1_RANK = 1; -const hsize_t SPACE1_DIM1 = 4; -const int ARRAY1_RANK = 1; -const hsize_t ARRAY1_DIM1 = 4; +const H5std_string FILENAME("tarray.h5"); +const H5std_string ARRAYTYPE_NAME("/Array type 1"); +const int SPACE1_RANK = 1; +const hsize_t SPACE1_DIM1 = 4; +const int ARRAY1_RANK = 1; +const hsize_t ARRAY1_DIM1 = 4; -typedef enum flt_t { - FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER -} flt_t; +typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t; typedef enum int_t { - INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, - INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER + INT_CHAR, + INT_UCHAR, + INT_SHORT, + INT_USHORT, + INT_INT, + INT_UINT, + INT_LONG, + INT_ULONG, + INT_LLONG, + INT_ULLONG, + INT_OTHER } int_t; - /*------------------------------------------------------------------------- * Function: test_array_compound_array * @@ -60,29 +67,29 @@ typedef enum int_t { * *------------------------------------------------------------------------- */ -static void test_array_compound_array() +static void +test_array_compound_array() { SUBTEST("ArrayType::getArrayNDims & ArrayType::getArrayDims"); - typedef struct { // Typedef for compound datatype */ - int i; + typedef struct { // Typedef for compound datatype */ + int i; float f[ARRAY1_DIM1]; } s1_t; - s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write - s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int nmemb; // Number of compound members - int ii; // counting variables - hsize_t idxi, idxj, idxk; // dimension indicing variables - H5T_class_t mclass; // Datatype class for field + s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write + s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int nmemb; // Number of compound members + int ii; // counting variables + hsize_t idxi, idxj, idxk; // dimension indicing variables + H5T_class_t mclass; // Datatype class for field // Initialize array data to write - for (idxi =0; idxi < SPACE1_DIM1; idxi++) + for (idxi = 0; idxi < SPACE1_DIM1; idxi++) for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { wdata[idxi][idxj].i = idxi * 10 + idxj; - for(idxk = 0; idxk < ARRAY1_DIM1; idxk++) - { - float temp = idxi * 10.0 + idxj * 2.5 + idxk; + for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) { + float temp = idxi * 10.0 + idxj * 2.5 + idxk; wdata[idxi][idxj].f[idxk] = temp; } } // end for @@ -158,8 +165,8 @@ static void test_array_compound_array() // Verify that it is an array of compounds DataType dstype = dataset.getDataType(); - mclass = dstype.getClass(); - verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); + mclass = dstype.getClass(); + verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); dstype.close(); @@ -175,11 +182,12 @@ static void test_array_compound_array() atype_check.getArrayDims(rdims1); // Check the array dimensions - for (ii =0; ii <ndims; ii++) - if (rdims1[ii]!=tdims1[ii]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii, rdims1[ii], ii, tdims1[ii]); - continue; - } // end if + for (ii = 0; ii < ndims; ii++) + if (rdims1[ii] != tdims1[ii]) { + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", + ii, rdims1[ii], ii, tdims1[ii]); + continue; + } // end if // Test ArrayType::ArrayType(const hid_t existing_id) ArrayType new_arrtype(atype_check.getId()); @@ -194,9 +202,10 @@ static void test_array_compound_array() // Check the array dimensions for (ii = 0; ii < ndims; ii++) if (rdims1[ii] != tdims1[ii]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", ii, rdims1[ii], ii, tdims1[ii]); - continue; - } // end if + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", + ii, rdims1[ii], ii, tdims1[ii]); + continue; + } // end if /* * Check the compound datatype and the array of floats datatype @@ -205,28 +214,28 @@ static void test_array_compound_array() // Get the compound datatype, which is the base datatype of the // array datatype atype_check. DataType base_type = atype_check.getSuper(); - mclass = base_type.getClass(); - verify_val(mclass==H5T_COMPOUND, true, "atype_check.getClass", __LINE__, __FILE__); + mclass = base_type.getClass(); + verify_val(mclass == H5T_COMPOUND, true, "atype_check.getClass", __LINE__, __FILE__); // Verify the compound datatype info CompType ctype_check(base_type.getId()); base_type.close(); - + // Check the number of members nmemb = ctype_check.getNmembers(); verify_val(nmemb, 2, "ctype_check.getNmembers", __LINE__, __FILE__); // Check the 2nd field's name H5std_string field2_name = ctype_check.getMemberName(1); - if (HDstrcmp(field2_name.c_str(),"f") != 0) - TestErrPrintf("Compound field name doesn't match!, field2_name=%s\n",field2_name.c_str()); + if (HDstrcmp(field2_name.c_str(), "f") != 0) + TestErrPrintf("Compound field name doesn't match!, field2_name=%s\n", field2_name.c_str()); // Get the 2nd field's datatype DataType f2_type = ctype_check.getMemberDataType(1); // Get the 2nd field's class, this 2nd field should have an array type mclass = f2_type.getClass(); - verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); + verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); f2_type.close(); // Get the 2nd field, array of floats datatype, to check @@ -243,7 +252,8 @@ static void test_array_compound_array() // Check the array dimensions for (ii = 0; ii < ndims; ii++) if (rdims1[ii] != tdims1[ii]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", ii, rdims1[ii], ii, tdims1[ii]); + TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n", + ii, rdims1[ii], ii, tdims1[ii]); continue; } // end if @@ -258,26 +268,26 @@ static void test_array_compound_array() for (idxi = 0; idxi < SPACE1_DIM1; idxi++) { for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { if (wdata[idxi][idxj].i != rdata[idxi][idxj].i) { - TestErrPrintf("Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n",idxi,idxj,wdata[idxi][idxj].i,idxi,idxj,rdata[idxi][idxj].i); + TestErrPrintf( + "Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n", + idxi, idxj, wdata[idxi][idxj].i, idxi, idxj, rdata[idxi][idxj].i); continue; } // end if - } // end for - } // end for + } // end for + } // end for // Close all atype_check.close(); dataset.close(); file1.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_array_compound_array", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_array_compound_array() - /*------------------------------------------------------------------------- * Function: test_array_assignment * @@ -296,16 +306,19 @@ static void test_array_compound_array() /* * Helper routine to demonstrate the issue in HDFFV-9562 */ -H5::DataType getArr() +H5::DataType +getArr() { - hsize_t *dims = new hsize_t; - *dims = 5; - H5::ArrayType ret; - ret = H5::ArrayType(H5::PredType::NATIVE_INT, 1, dims); - delete[] dims; - return ret; } - -static void test_array_assignment() + hsize_t *dims = new hsize_t; + *dims = 5; + H5::ArrayType ret; + ret = H5::ArrayType(H5::PredType::NATIVE_INT, 1, dims); + delete[] dims; + return ret; +} + +static void +test_array_assignment() { hsize_t sdims1[] = {SPACE1_DIM1}; SUBTEST("ArrayType::operator="); @@ -342,14 +355,12 @@ static void test_array_assignment() file1.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_array_assignment", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_array_assignment() - /*------------------------------------------------------------------------- * Function: test_array_info * @@ -362,29 +373,27 @@ static void test_array_assignment() * *------------------------------------------------------------------------- */ -static void test_array_info() +static void +test_array_info() { SUBTEST("ArrayType Const Methods"); - typedef struct { // Typedef for compound datatype */ - int i; + typedef struct { // Typedef for compound datatype */ + int i; float f[ARRAY1_DIM1]; } s1_t; - s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write - s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in - hsize_t sdims1[] = {SPACE1_DIM1}; - hsize_t tdims1[] = {ARRAY1_DIM1}; - int nmemb; // Number of compound members - int ii; // counting variables - hsize_t idxi, idxj, idxk; // dimension indicing variables - H5T_class_t mclass; // Datatype class for field + s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int ii; // counting variables + hsize_t idxi, idxj, idxk; // dimension indicing variables + H5T_class_t mclass; // Datatype class for field // Initialize array data to write - for (idxi =0; idxi < SPACE1_DIM1; idxi++) + for (idxi = 0; idxi < SPACE1_DIM1; idxi++) for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) { wdata[idxi][idxj].i = idxi * 10 + idxj; - for(idxk = 0; idxk < ARRAY1_DIM1; idxk++) - { - float temp = idxi * 10.0 + idxj * 2.5 + idxk; + for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) { + float temp = idxi * 10.0 + idxj * 2.5 + idxk; wdata[idxi][idxj].f[idxk] = temp; } } // end for @@ -433,51 +442,51 @@ static void test_array_info() // Verify that it is an array of compounds DataType dstype = dataset.getDataType(); - mclass = dstype.getClass(); - verify_val(mclass==H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); + mclass = dstype.getClass(); + verify_val(mclass == H5T_ARRAY, true, "f2_type.getClass", __LINE__, __FILE__); dstype.close(); { // Let atype_check go out of scope - // Get the array datatype, declared as const - const ArrayType atype_check = dataset.getArrayType(); - - // Check the array rank with the const method - int ndims = atype_check.getArrayNDims(); - verify_val(ndims, ARRAY1_RANK, "atype_check.getArrayNDims", __LINE__, __FILE__); - - // Get the array dimensions with the const method - hsize_t rdims1[H5S_MAX_RANK]; - atype_check.getArrayDims(rdims1); - - // Check the array dimensions - for (ii =0; ii <ndims; ii++) - if (rdims1[ii]!=tdims1[ii]) { - TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii, rdims1[ii], ii, tdims1[ii]); - continue; - } // end if + // Get the array datatype, declared as const + const ArrayType atype_check = dataset.getArrayType(); + + // Check the array rank with the const method + int ndims = atype_check.getArrayNDims(); + verify_val(ndims, ARRAY1_RANK, "atype_check.getArrayNDims", __LINE__, __FILE__); + + // Get the array dimensions with the const method + hsize_t rdims1[H5S_MAX_RANK]; + atype_check.getArrayDims(rdims1); + + // Check the array dimensions + for (ii = 0; ii < ndims; ii++) + if (rdims1[ii] != tdims1[ii]) { + TestErrPrintf( + "Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii, + rdims1[ii], ii, tdims1[ii]); + continue; + } // end if } // Close all dataset.close(); file1.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_array_info", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_array_info() - /**************************************************************** ** ** test_array(): Main datatypes testing routine. ** ****************************************************************/ -extern "C" -void test_array() +extern "C" void +test_array() { // Output message about test being performed MESSAGE(5, ("Testing Array Datatypes\n")); @@ -491,9 +500,8 @@ void test_array() // Test const functions (HDFFV-9725) test_array_info(); -} // test_array() +} // test_array() - /*------------------------------------------------------------------------- * Function: cleanup_array * @@ -506,8 +514,8 @@ void test_array() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_array() +extern "C" void +cleanup_array() { HDremove(FILENAME.c_str()); -} // cleanup_array +} // cleanup_array diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 25b5ff8..1114568 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,22 +27,23 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file -const H5std_string FILE_BASIC("tattr_basic.h5"); -const H5std_string FILE_COMPOUND("tattr_compound.h5"); -const H5std_string FILE_SCALAR("tattr_scalar.h5"); -const H5std_string FILE_MULTI("tattr_multi.h5"); -const H5std_string FILE_DTYPE("tattr_dtype.h5"); -const H5std_string ATTR_TMP_NAME("temp_attr_name"); -const H5std_string FATTR_TMP_NAME("temp_fattr_name"); -const size_t ATTR_MAX_DIMS = 7; +const H5std_string FILE_BASIC("tattr_basic.h5"); +const H5std_string FILE_COMPOUND("tattr_compound.h5"); +const H5std_string FILE_SCALAR("tattr_scalar.h5"); +const H5std_string FILE_MULTI("tattr_multi.h5"); +const H5std_string FILE_DTYPE("tattr_dtype.h5"); +const H5std_string ATTR_TMP_NAME("temp_attr_name"); +const H5std_string FATTR_TMP_NAME("temp_fattr_name"); +const size_t ATTR_MAX_DIMS = 7; /* 3-D dataset with fixed dimensions */ -const int SPACE1_RANK = 3; +const int SPACE1_RANK = 3; const hsize_t SPACE1_DIM1 = 3; const hsize_t SPACE1_DIM2 = 15; const hsize_t SPACE1_DIM3 = 13; @@ -54,52 +55,54 @@ const H5std_string TYPE1_NAME("/Type"); /* Attribute Rank & Dimensions */ const H5std_string ATTR1_NAME("Attr1"); -const int ATTR1_RANK = 1; -const hsize_t ATTR1_DIM1 = 3; -int attr_data1[ATTR1_DIM1]={512,-234,98123}; /* Test data for 1st attribute */ +const int ATTR1_RANK = 1; +const hsize_t ATTR1_DIM1 = 3; +int attr_data1[ATTR1_DIM1] = {512, -234, 98123}; /* Test data for 1st attribute */ // File attribute, using the same rank and dimensions as ATTR1_NAME's const H5std_string FATTR1_NAME("File Attr1"); const H5std_string FATTR2_NAME("File Attr2"); const H5std_string ATTR2_NAME("Attr2"); -const int ATTR2_RANK = 2; -const hsize_t ATTR2_DIM1 = 2; -const hsize_t ATTR2_DIM2 = 2; -int attr_data2[ATTR2_DIM1][ATTR2_DIM2]={{7614,-416},{197814,-3}}; /* Test data for 2nd attribute */ +const int ATTR2_RANK = 2; +const hsize_t ATTR2_DIM1 = 2; +const hsize_t ATTR2_DIM2 = 2; +int attr_data2[ATTR2_DIM1][ATTR2_DIM2] = {{7614, -416}, {197814, -3}}; /* Test data for 2nd attribute */ const H5std_string ATTR3_NAME("Attr3"); -const int ATTR3_RANK = 3; -const hsize_t ATTR3_DIM1 = 2; -const hsize_t ATTR3_DIM2 = 2; -const hsize_t ATTR3_DIM3 = 2; -double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{2.3,-26.1},{0.123,-10.0}},{{981724.2,-0.91827},{2.0,23.0}}}; /* Test data for 3rd attribute */ +const int ATTR3_RANK = 3; +const hsize_t ATTR3_DIM1 = 2; +const hsize_t ATTR3_DIM2 = 2; +const hsize_t ATTR3_DIM3 = 2; +double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = { + {{2.3, -26.1}, {0.123, -10.0}}, {{981724.2, -0.91827}, {2.0, 23.0}}}; /* Test data for 3rd attribute */ const H5std_string ATTR4_NAME("Attr4"); -const int ATTR4_RANK = 2; -const hsize_t ATTR4_DIM1 = 2; -const hsize_t ATTR4_DIM2 = 2; +const int ATTR4_RANK = 2; +const hsize_t ATTR4_DIM1 = 2; +const hsize_t ATTR4_DIM2 = 2; const H5std_string ATTR4_FIELDNAME1("i"); const H5std_string ATTR4_FIELDNAME2("d"); const H5std_string ATTR4_FIELDNAME3("c"); -size_t attr4_field1_off=0; -size_t attr4_field2_off=0; -size_t attr4_field3_off=0; +size_t attr4_field1_off = 0; +size_t attr4_field2_off = 0; +size_t attr4_field3_off = 0; struct attr4_struct { - int i; + int i; double d; - char c; - } attr_data4[ATTR4_DIM1][ATTR4_DIM2]={{{3,-26.1,'d'},{-100000, 0.123,'3'}}, - {{-23,981724.2,'Q'},{0,2.0,'\n'}}}; // Test data for 4th attribute + char c; +} attr_data4[ATTR4_DIM1][ATTR4_DIM2] = { + {{3, -26.1, 'd'}, {-100000, 0.123, '3'}}, + {{-23, 981724.2, 'Q'}, {0, 2.0, '\n'}}}; // Test data for 4th attribute const H5std_string ATTR5_NAME("Attr5"); -const int ATTR5_RANK = 0; -float attr_data5 = (float)-5.123; // Test data for 5th attribute +const int ATTR5_RANK = 0; +float attr_data5 = (float)-5.123; // Test data for 5th attribute /* Info for another attribute */ const H5std_string ATTR1A_NAME("Attr1_a"); -int attr_data1a[ATTR1_DIM1]={256,11945,-22107}; +int attr_data1a[ATTR1_DIM1] = {256, 11945, -22107}; /**************************************************************** ** @@ -107,12 +110,13 @@ int attr_data1a[ATTR1_DIM1]={256,11945,-22107}; ** Tests integer attributes on both datasets and groups ** ****************************************************************/ -static void test_attr_basic_write() +static void +test_attr_basic_write() { - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2}; + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute hsize_t i; // Output message about test being performed @@ -120,10 +124,10 @@ static void test_attr_basic_write() try { // Create file - H5File fid1 (FILE_BASIC, H5F_ACC_TRUNC); + H5File fid1(FILE_BASIC, H5F_ACC_TRUNC); // Create dataspace for dataset - DataSpace ds_space (SPACE1_RANK, dims1); + DataSpace ds_space(SPACE1_RANK, dims1); /* * Test attribute with dataset @@ -133,55 +137,59 @@ static void test_attr_basic_write() DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space); // Create dataspace for attribute - DataSpace att_space (ATTR1_RANK, dims2); + DataSpace att_space(ATTR1_RANK, dims2); // Create a file attribute - Attribute file_attr2 = fid1.createAttribute (FATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute file_attr2 = fid1.createAttribute(FATTR1_NAME, PredType::NATIVE_INT, att_space); // Create a file attribute - Attribute file_attr1 = fid1.createAttribute (FATTR2_NAME, PredType::NATIVE_INT, att_space); + Attribute file_attr1 = fid1.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, att_space); // Create an attribute for the dataset - Attribute ds_attr1 = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr1 = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space); // Try creating an attribute that already exists. This should fail // since two attributes cannot have the same name. If an exception // is not thrown for this action by createAttribute, then throw an // invalid action exception. try { - Attribute invalid_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute invalid_attr = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("H5File::createDataSet", + "Library allowed overwrite of existing dataset"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write attribute information - ds_attr1.write (PredType::NATIVE_INT, attr_data1); + ds_attr1.write(PredType::NATIVE_INT, attr_data1); // Read attribute information immediately, without closing attribute - ds_attr1.read (PredType::NATIVE_INT, read_data1); + ds_attr1.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n", __LINE__, + i, attr_data1[i], i, read_data1[i]); // Create two more attributes for this dataset, but only write to one. - Attribute ds_attr2 = dataset.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, att_space); - Attribute ds_attr3 = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr2 = dataset.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr3 = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_INT, att_space); // Write attribute information - ds_attr2.write (PredType::NATIVE_INT, attr_data1a); + ds_attr2.write(PredType::NATIVE_INT, attr_data1a); // Read attribute information immediately, without closing attribute - ds_attr2.read (PredType::NATIVE_INT, read_data1); + ds_attr2.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1a[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1a[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1a[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n", + __LINE__, i, attr_data1a[i], i, read_data1[i]); // Close both attributes ds_attr1.close(); @@ -193,45 +201,45 @@ static void test_attr_basic_write() */ // Create group in file fid1 - Group group = fid1.createGroup (GROUP1_NAME); + Group group = fid1.createGroup(GROUP1_NAME); // Create dataspace for attribute DataSpace sid3(ATTR2_RANK, dims3); // Create an attribute for the group - Attribute gr_attr = group.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, sid3); + Attribute gr_attr = group.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, sid3); // Check storage size for attribute hsize_t attr_size = gr_attr.getStorageSize(); - verify_val((long)attr_size, (long)(ATTR2_DIM1*ATTR2_DIM2*sizeof(int)), - "Attribute::getStorageSize",__LINE__,__FILE__); + verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)), + "Attribute::getStorageSize", __LINE__, __FILE__); // Try to create the same attribute again (should fail) try { - Attribute invalid_attr = group.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, sid3); + Attribute invalid_attr = group.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, sid3); // continuation here, that means no exception has been thrown throw InvalidActionException("H5Group::createAttribute", - "Attempting to create an existing attribute"); + "Attempting to create an existing attribute"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write attribute information - gr_attr.write (PredType::NATIVE_INT, attr_data2); + gr_attr.write(PredType::NATIVE_INT, attr_data2); // Check storage size for attribute attr_size = gr_attr.getStorageSize(); - verify_val((long)attr_size, (long)(ATTR2_DIM1*ATTR2_DIM2*sizeof(int)), - "Attribute::getStorageSize", __LINE__, __FILE__); + verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)), + "Attribute::getStorageSize", __LINE__, __FILE__); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_basic_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_basic_write() +} // test_attr_basic_write() /**************************************************************** ** @@ -256,7 +264,8 @@ static void test_attr_basic_write() ** With buffer size equals the name's length, i.e., buf_size=0 ** ****************************************************************/ -static void test_attr_getname() +static void +test_attr_getname() { // Output message about test being performed SUBTEST("Testing all overloads of Attribute::getName"); @@ -274,7 +283,7 @@ static void test_attr_getname() if (attr_exists == false) throw InvalidActionException("H5File::attrExists", "Attribute should exist but does not"); - // Open attribute + // Open attribute Attribute fattr1(fid1.openAttribute(FATTR1_NAME)); // A. Get attribute name with @@ -282,36 +291,37 @@ static void test_attr_getname() // using different buffer sizes and verify against FATTR1_NAME (3 cases) // 1. With arbitrary buf_size that is larger than the name size - size_t buf_size = FATTR1_NAME.length() + 10; - char* fattr1_name = new char[buf_size+1]; - HDmemset(fattr1_name, 0, buf_size+1); + size_t buf_size = FATTR1_NAME.length() + 10; + char * fattr1_name = new char[buf_size + 1]; + HDmemset(fattr1_name, 0, buf_size + 1); ssize_t name_size = 0; // actual length of attribute name - name_size = fattr1.getName(fattr1_name, buf_size+1); + name_size = fattr1.getName(fattr1_name, buf_size + 1); CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__); verify_val((size_t)name_size, FATTR1_NAME.length(), "Attribute::getName", __LINE__, __FILE__); - verify_val((const char*)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); - delete []fattr1_name; + verify_val((const char *)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); + delete[] fattr1_name; // 2. With arbitrary buf_size that is smaller than the name's length. // Let's try 4 first characters in the name. - buf_size = 4; + buf_size = 4; char short_name[5] = "File"; // to verify the read name - fattr1_name = new char[buf_size+1]; - HDmemset(fattr1_name, 0, buf_size+1); - name_size = fattr1.getName(fattr1_name, buf_size+1); + fattr1_name = new char[buf_size + 1]; + HDmemset(fattr1_name, 0, buf_size + 1); + name_size = fattr1.getName(fattr1_name, buf_size + 1); CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__); verify_val((size_t)name_size, FATTR1_NAME.size(), "Attribute::getName", __LINE__, __FILE__); - verify_val((const char*)fattr1_name, (const char*)short_name, "Attribute::getName", __LINE__, __FILE__); - delete []fattr1_name; + verify_val((const char *)fattr1_name, (const char *)short_name, "Attribute::getName", __LINE__, + __FILE__); + delete[] fattr1_name; // 3. With a buf_size that equals the name's length. - buf_size = FATTR1_NAME.length(); - fattr1_name = new char[buf_size+1]; - HDmemset(fattr1_name, 0, buf_size+1); - name_size = fattr1.getName(fattr1_name, buf_size+1); + buf_size = FATTR1_NAME.length(); + fattr1_name = new char[buf_size + 1]; + HDmemset(fattr1_name, 0, buf_size + 1); + name_size = fattr1.getName(fattr1_name, buf_size + 1); CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__); verify_val(fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); - delete []fattr1_name; + delete[] fattr1_name; // B. Get attribute name with // ssize_t Attribute::getName(H5std_string& attr_name, size_t buf_size) @@ -349,7 +359,7 @@ static void test_attr_getname() // Open attribute Attribute attr1(dataset.openAttribute(ATTR1_NAME)); - size_t len = 4; + size_t len = 4; H5std_string dattr_name1 = attr1.getName(len); verify_val(dattr_name1, "Attr", "Attribute::getName", __LINE__, __FILE__); @@ -362,20 +372,20 @@ static void test_attr_getname() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_getname()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_getname() +} // test_attr_getname() /**************************************************************** ** ** test_attr_rename(): Test renaming attribute function. ** ****************************************************************/ -static void test_attr_rename() +static void +test_attr_rename() { - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading the attribute + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading the attribute hsize_t i; // Output message about test being performed @@ -429,12 +439,13 @@ static void test_attr_rename() verify_val(attr_name, ATTR_TMP_NAME, "Attribute::getName", __LINE__, __FILE__); // Read attribute information immediately, without closing attribute - attr1.read (PredType::NATIVE_INT, read_data1); + attr1.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n", __LINE__, + i, attr_data1[i], i, read_data1[i]); // Close attribute attr1.close(); @@ -452,12 +463,13 @@ static void test_attr_rename() verify_val(attr2_name, ATTR2_NAME, "Attribute::getName", __LINE__, __FILE__); // Read attribute information immediately, without closing attribute - attr2.read (PredType::NATIVE_INT, read_data1); + attr2.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1a[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1a[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1a[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n", + __LINE__, i, attr_data1a[i], i, read_data1[i]); // Close attribute attr2.close(); @@ -473,18 +485,18 @@ static void test_attr_rename() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_rename()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_rename() +} // test_attr_rename() /******************************************************************** ** ** test_attr_basic_read(): Test basic read attribute. ** ********************************************************************/ -static void test_attr_basic_read() +static void +test_attr_basic_read() { hsize_t i, j; @@ -503,16 +515,17 @@ static void test_attr_basic_read() verify_val(num_attrs, 3, "DataSet::getNumAttrs", __LINE__, __FILE__); // Open an attribute for the dataset - Attribute ds_attr=dataset.openAttribute(ATTR1_NAME); + Attribute ds_attr = dataset.openAttribute(ATTR1_NAME); // Read attribute information - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute ds_attr.read(PredType::NATIVE_INT, &read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", + __LINE__, i, attr_data1[i], i, read_data1[i]); /* * Test attribute with group @@ -528,35 +541,37 @@ static void test_attr_basic_read() Attribute gr_attr = group.openAttribute(ATTR2_NAME); // Buffer for reading 2nd attribute - int read_data2[ATTR2_DIM1][ATTR2_DIM2]={{0}}; + int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; // Read attribute information gr_attr.read(PredType::NATIVE_INT, read_data2); // Verify values read in - for(i=0; i<ATTR2_DIM1; i++) - for(j=0; j<ATTR2_DIM2; j++) - if(attr_data2[i][j]!=read_data2[i][j]) { - TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__, i,j,attr_data2[i][j],i,j,read_data2[i][j]); + for (i = 0; i < ATTR2_DIM1; i++) + for (j = 0; j < ATTR2_DIM2; j++) + if (attr_data2[i][j] != read_data2[i][j]) { + TestErrPrintf( + "%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n", + __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]); } PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_basic_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_basic_read() +} // test_attr_basic_read() /**************************************************************** ** ** test_attr_compound_write(): Tests compound datatype attributes ** ****************************************************************/ -static void test_attr_compound_write() +static void +test_attr_compound_write() { - // Output message about test being performed + // Output message about test being performed SUBTEST("Multiple Attribute Functions"); try { @@ -564,11 +579,11 @@ static void test_attr_compound_write() H5File fid1(FILE_COMPOUND.c_str(), H5F_ACC_TRUNC); // Create dataspace for dataset - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; DataSpace sid1(SPACE1_RANK, dims1); // Create a dataset - DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR,sid1); + DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, sid1); // Create the attribute datatype. CompType comp_type(sizeof(struct attr4_struct)); @@ -583,7 +598,7 @@ static void test_attr_compound_write() comp_type.insertMember(ATTR4_FIELDNAME3, attr4_field3_off, PredType::NATIVE_SCHAR); // Create dataspace for 1st attribute - hsize_t dims2[] = {ATTR4_DIM1,ATTR4_DIM2}; + hsize_t dims2[] = {ATTR4_DIM1, ATTR4_DIM2}; DataSpace sid2(ATTR4_RANK, dims2); // Create complex attribute for the dataset @@ -591,10 +606,11 @@ static void test_attr_compound_write() // Try to create the same attribute again (should fail) try { - Attribute invalid_attr = dataset.createAttribute (ATTR4_NAME, comp_type, sid2); + Attribute invalid_attr = dataset.createAttribute(ATTR4_NAME, comp_type, sid2); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write complex attribute data attr.write(comp_type, attr_data4); @@ -602,22 +618,22 @@ static void test_attr_compound_write() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_compound_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_compound_write() +} // test_attr_compound_write() /**************************************************************** ** ** test_attr_compound_read(): Test basic H5A (attribute) code. ** ****************************************************************/ -static void test_attr_compound_read() +static void +test_attr_compound_read() { - hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions - size_t size; // Attribute datatype size as stored in file - size_t offset; // Attribute datatype field offset + hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions + size_t size; // Attribute datatype size as stored in file + size_t offset; // Attribute datatype field offset struct attr4_struct read_data4[ATTR4_DIM1][ATTR4_DIM2]; // Buffer for reading 4th attribute // Output message about test being performed @@ -649,8 +665,8 @@ static void test_attr_compound_read() // Get the dims of the dataspace and verify them int ndims = space.getSimpleExtentDims(dims); verify_val(ndims, ATTR4_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val((long)dims[0], (long)ATTR4_DIM1, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); - verify_val((long)dims[1], (long)ATTR4_DIM2, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); + verify_val((long)dims[0], (long)ATTR4_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val((long)dims[1], (long)ATTR4_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Get the class of the datatype that is used by attr H5T_class_t type_class; @@ -669,13 +685,11 @@ static void test_attr_compound_read() // Verify that the fields have the same names as when the type // was created int j; - for(j=0; j<fields; j++) - { + for (j = 0; j < fields; j++) { H5std_string fieldname = datatype.getMemberName(j); - if(!((fieldname == ATTR4_FIELDNAME1) || - (fieldname == ATTR4_FIELDNAME2) || - (fieldname == ATTR4_FIELDNAME3))) - TestErrPrintf("%d:invalid field name for field #%d: %s\n",__LINE__,j,fieldname.c_str()); + if (!((fieldname == ATTR4_FIELDNAME1) || (fieldname == ATTR4_FIELDNAME2) || + (fieldname == ATTR4_FIELDNAME3))) + TestErrPrintf("%d:invalid field name for field #%d: %s\n", __LINE__, j, fieldname.c_str()); } /* end for */ offset = datatype.getMemberOffset(0); @@ -693,8 +707,8 @@ static void test_attr_compound_read() type_class = datatype.getMemberClass(0); verify_val(type_class, H5T_INTEGER, "DataType::getMemberClass", __LINE__, __FILE__); // Get and verify the order of this member's type - IntType i_type = datatype.getMemberIntType(0); - H5T_order_t order = i_type.getOrder(); + IntType i_type = datatype.getMemberIntType(0); + H5T_order_t order = i_type.getOrder(); verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__); // Get and verify the size of this member's type @@ -705,7 +719,7 @@ static void test_attr_compound_read() type_class = datatype.getMemberClass(1); verify_val(type_class, H5T_FLOAT, "DataType::getMemberClass", __LINE__, __FILE__); FloatType f_type = datatype.getMemberFloatType(1); - order = f_type.getOrder(); + order = f_type.getOrder(); verify_val(order, PredType::NATIVE_DOUBLE.getOrder(), "DataType::getOrder", __LINE__, __FILE__); size = f_type.getSize(); verify_val(size, PredType::NATIVE_DOUBLE.getSize(), "DataType::getSize", __LINE__, __FILE__); @@ -716,7 +730,7 @@ static void test_attr_compound_read() // Note: H5T_INTEGER is correct here! StrType s_type = datatype.getMemberStrType(2); - order = s_type.getOrder(); + order = s_type.getOrder(); verify_val(order, PredType::NATIVE_SCHAR.getOrder(), "DataType::getOrder", __LINE__, __FILE__); size = s_type.getSize(); verify_val(size, PredType::NATIVE_SCHAR.getSize(), "DataType::getSize", __LINE__, __FILE__); @@ -726,26 +740,30 @@ static void test_attr_compound_read() // Verify values read in hsize_t ii, jj; - for(ii=0; ii<ATTR4_DIM1; ii++) - for(jj=0; jj<ATTR4_DIM2; jj++) - if(HDmemcmp(&attr_data4[ii][jj],&read_data4[ii][jj],sizeof(struct attr4_struct))) { - TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",__LINE__,ii,jj,attr_data4[ii][jj].i,ii,jj,read_data4[ii][jj].i); - TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",__LINE__,ii,jj,attr_data4[ii][jj].d,ii,jj,read_data4[ii][jj].d); - TestErrPrintf("%d:attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",__LINE__,ii,jj,attr_data4[ii][jj].c,ii,jj,read_data4[ii][jj].c); - } /* end if */ + for (ii = 0; ii < ATTR4_DIM1; ii++) + for (jj = 0; jj < ATTR4_DIM2; jj++) + if (HDmemcmp(&attr_data4[ii][jj], &read_data4[ii][jj], sizeof(struct attr4_struct))) { + TestErrPrintf( + "%d:attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n", + __LINE__, ii, jj, attr_data4[ii][jj].i, ii, jj, read_data4[ii][jj].i); + TestErrPrintf( + "%d:attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n", + __LINE__, ii, jj, attr_data4[ii][jj].d, ii, jj, read_data4[ii][jj].d); + TestErrPrintf( + "%d:attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n", + __LINE__, ii, jj, attr_data4[ii][jj].c, ii, jj, read_data4[ii][jj].c); + } /* end if */ // Verify name H5std_string attr_name = attr.getName(); verify_val(attr_name, ATTR4_NAME, "Attribute::getName", __LINE__, __FILE__); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, E.getCDetailMsg()); } - try - { + try { // Now, try truncating the file to make sure reference counting is good. // If any references to ids in the previous block are left unterminated, // the truncating will fail, because the file will not be closed in @@ -755,18 +773,19 @@ static void test_attr_compound_read() PASSED(); } // end try block - catch (FileIException& E) - { - issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, "Unable to truncate file, possibly because some objects are left opened"); + catch (FileIException &E) { + issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, + "Unable to truncate file, possibly because some objects are left opened"); } -} // test_attr_compound_read() +} // test_attr_compound_read() /**************************************************************** ** ** test_attr_scalar_write(): Test scalar attribute writing functionality. ** ****************************************************************/ -static void test_attr_scalar_write() +static void +test_attr_scalar_write() { // Output message about test being performed SUBTEST("Basic Scalar Attribute Writing Functions"); @@ -776,11 +795,11 @@ static void test_attr_scalar_write() H5File fid1(FILE_SCALAR, H5F_ACC_TRUNC); // Create dataspace for dataset - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; DataSpace sid1(SPACE1_RANK, dims1); // Create a dataset - DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR,sid1); + DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, sid1); // Close dataset's dataspace sid1.close(); @@ -789,39 +808,41 @@ static void test_attr_scalar_write() DataSpace att_space(ATTR5_RANK, NULL); // Create an attribute for the dataset - Attribute ds_attr = dataset.createAttribute (ATTR5_NAME, PredType::NATIVE_FLOAT, att_space); + Attribute ds_attr = dataset.createAttribute(ATTR5_NAME, PredType::NATIVE_FLOAT, att_space); // Try creating an attribute that already exists. This should fail // since two attributes cannot have the same name. If an exception // is not thrown for this action by createAttribute, then throw an // invalid action exception. try { - Attribute invalid_attr = dataset.createAttribute (ATTR5_NAME, PredType::NATIVE_FLOAT, att_space); + Attribute invalid_attr = dataset.createAttribute(ATTR5_NAME, PredType::NATIVE_FLOAT, att_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("H5File::createDataSet", + "Library allowed overwrite of existing dataset"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write attribute information - ds_attr.write (PredType::NATIVE_FLOAT, &attr_data5); + ds_attr.write(PredType::NATIVE_FLOAT, &attr_data5); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_scalar_write() +} // test_attr_scalar_write() /**************************************************************** ** ** test_attr_scalar_read(): Test scalar attribute reading functionality. ** ****************************************************************/ -static void test_attr_scalar_read() +static void +test_attr_scalar_read() { // Output message about test being performed SUBTEST("Basic Scalar Attribute Reading Functions"); @@ -838,11 +859,11 @@ static void test_attr_scalar_read() verify_val(num_attrs, 1, "DataSet::getNumAttrs", __LINE__, __FILE__); // Open an attribute for the dataset - Attribute ds_attr=dataset.openAttribute(ATTR5_NAME); + Attribute ds_attr = dataset.openAttribute(ATTR5_NAME); // Read attribute information - float read_data2=0.0; // Buffer for reading 1st attribute - ds_attr.read(PredType::NATIVE_FLOAT,&read_data2); + float read_data2 = 0.0; // Buffer for reading 1st attribute + ds_attr.read(PredType::NATIVE_FLOAT, &read_data2); verify_val(read_data2, attr_data5, "Attribute::read", __LINE__, __FILE__); // Get the dataspace of the attribute @@ -855,98 +876,100 @@ static void test_attr_scalar_read() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_scalar_read() +} // test_attr_scalar_read() /**************************************************************** ** ** test_attr_mult_write(): Test multiple attributes ** ****************************************************************/ -static void test_attr_mult_write() +static void +test_attr_mult_write() { // Output message about test being performed SUBTEST("Multiple Attribute Writing Functions"); try { // Create file - H5File fid1 (FILE_MULTI, H5F_ACC_TRUNC); + H5File fid1(FILE_MULTI, H5F_ACC_TRUNC); // Create dataspace for dataset - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - DataSpace ds_space (SPACE1_RANK, dims1); + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + DataSpace ds_space(SPACE1_RANK, dims1); // Create a dataset DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space); // Create dataspace for 1st attribute - hsize_t dims2[] = {ATTR1_DIM1}; - DataSpace att_space (ATTR1_RANK, dims2); + hsize_t dims2[] = {ATTR1_DIM1}; + DataSpace att_space(ATTR1_RANK, dims2); // Create 1st attribute for the dataset - Attribute ds_attr = dataset.createAttribute (ATTR1_NAME, PredType::NATIVE_INT, att_space); + Attribute ds_attr = dataset.createAttribute(ATTR1_NAME, PredType::NATIVE_INT, att_space); // Write attribute information - ds_attr.write (PredType::NATIVE_INT, attr_data1); + ds_attr.write(PredType::NATIVE_INT, attr_data1); // Create dataspace for 2nd attribute - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - DataSpace att2_space (ATTR2_RANK, dims3); + hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2}; + DataSpace att2_space(ATTR2_RANK, dims3); // Create 2nd attribute for the dataset - Attribute ds_attr2 = dataset.createAttribute (ATTR2_NAME, PredType::NATIVE_INT, att2_space); + Attribute ds_attr2 = dataset.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, att2_space); // Write 2nd attribute information - ds_attr2.write (PredType::NATIVE_INT, attr_data2); + ds_attr2.write(PredType::NATIVE_INT, attr_data2); // Create dataspace for 3rd attribute - hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; - DataSpace att3_space (ATTR3_RANK, dims4); + hsize_t dims4[] = {ATTR3_DIM1, ATTR3_DIM2, ATTR3_DIM3}; + DataSpace att3_space(ATTR3_RANK, dims4); // Create 3rd attribute for the dataset - Attribute ds_attr3 = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); + Attribute ds_attr3 = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); // Try creating an attribute that already exists. This should fail // since two attributes cannot have the same name. If an exception // is not thrown for this action by createAttribute, then throw an // invalid action exception. try { - Attribute invalid_attr = dataset.createAttribute (ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); + Attribute invalid_attr = dataset.createAttribute(ATTR3_NAME, PredType::NATIVE_DOUBLE, att3_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::createAttribute", "Attempting to create a duplicate attribute"); + throw InvalidActionException("DataSet::createAttribute", + "Attempting to create a duplicate attribute"); } - catch (AttributeIException& E) // catching invalid creating attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid creating attribute + { + } // do nothing, exception expected // Write 3rd attribute information - ds_attr3.write (PredType::NATIVE_DOUBLE, attr_data3); + ds_attr3.write(PredType::NATIVE_DOUBLE, attr_data3); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_mult_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_mult_write() +} // test_attr_mult_write() /**************************************************************** ** ** test_attr_mult_read(): Test reading multiple attributes. ** ****************************************************************/ -static void test_attr_mult_read() +static void +test_attr_mult_read() { - int read_data1[ATTR1_DIM1]={0}; // Buffer for reading 1st attribute - int read_data2[ATTR2_DIM1][ATTR2_DIM2]={{0}}; // Buffer for reading 2nd attribute - double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{0}}}; // Buffer for reading 3rd attribute - hsize_t i,j,k; + int read_data1[ATTR1_DIM1] = {0}; // Buffer for reading 1st attribute + int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; // Buffer for reading 2nd attribute + double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {{{0}}}; // Buffer for reading 3rd attribute + hsize_t i, j, k; - // Output message about test being performed + // Output message about test being performed SUBTEST("Multiple Attribute Reading Functions"); try { @@ -973,10 +996,11 @@ static void test_attr_mult_read() verify_val(rank, ATTR1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Get the dims of the dataspace and verify them - hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions - int ndims = space.getSimpleExtentDims(dims); + hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions + int ndims = space.getSimpleExtentDims(dims); if ((long)dims[0] != (long)ATTR1_DIM1) - TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n",__LINE__,(int)dims[0],ATTR1_DIM1); + TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n", __LINE__, + (int)dims[0], ATTR1_DIM1); /* Verify Datatype */ @@ -1001,9 +1025,10 @@ static void test_attr_mult_read() attr.read(PredType::NATIVE_INT, read_data1); // Verify values read in - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]); + for (i = 0; i < ATTR1_DIM1; i++) + if (attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n", __LINE__, + i, attr_data1[i], i, read_data1[i]); // Verify Name H5std_string attr_name = attr.getName(); @@ -1027,8 +1052,8 @@ static void test_attr_mult_read() // Get the dims of the dataspace and verify them ndims = space.getSimpleExtentDims(dims); - verify_val((long)dims[0], (long)ATTR2_DIM1, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); - verify_val((long)dims[1], (long)ATTR2_DIM2, "DataSpace::getSimpleExtentDims",__LINE__, __FILE__); + verify_val((long)dims[0], (long)ATTR2_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val((long)dims[1], (long)ATTR2_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); /* Verify Datatype */ @@ -1051,13 +1076,15 @@ static void test_attr_mult_read() // Read attribute information attr.read(PredType::NATIVE_INT, read_data2); - //attr.read(i_type, read_data2); + // attr.read(i_type, read_data2); // Verify values read in - for(i=0; i<ATTR2_DIM1; i++) - for(j=0; j<ATTR2_DIM2; j++) - if(attr_data2[i][j]!=read_data2[i][j]) - TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__,i,j,attr_data2[i][j],i,j,read_data2[i][j]); + for (i = 0; i < ATTR2_DIM1; i++) + for (j = 0; j < ATTR2_DIM2; j++) + if (attr_data2[i][j] != read_data2[i][j]) + TestErrPrintf( + "%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n", + __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]); // Verify Name attr_name = attr.getName(); @@ -1079,9 +1106,9 @@ static void test_attr_mult_read() // Get the dims of the dataspace and verify them ndims = space.getSimpleExtentDims(dims); - verify_val((long)dims[0],(long)ATTR3_DIM1,"attribute dimensions",__FILE__,__LINE__); - verify_val((long)dims[1],(long)ATTR3_DIM2,"attribute dimensions",__FILE__,__LINE__); - verify_val((long)dims[2],(long)ATTR3_DIM3,"attribute dimensions",__FILE__,__LINE__); + verify_val((long)dims[0], (long)ATTR3_DIM1, "attribute dimensions", __FILE__, __LINE__); + verify_val((long)dims[1], (long)ATTR3_DIM2, "attribute dimensions", __FILE__, __LINE__); + verify_val((long)dims[2], (long)ATTR3_DIM3, "attribute dimensions", __FILE__, __LINE__); /* Verify Datatype */ @@ -1106,11 +1133,13 @@ static void test_attr_mult_read() attr.read(PredType::NATIVE_DOUBLE, read_data3); // Verify values read in - for(i=0; i<ATTR3_DIM1; i++) - for(j=0; j<ATTR3_DIM2; j++) - for(k=0; k<ATTR3_DIM3; k++) - if(attr_data3[i][j][k]!=read_data3[i][j][k]) - TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, read_data3[%d][%d][%d]=%f\n",__LINE__,i,j,k,attr_data3[i][j][k],i,j,k,read_data3[i][j][k]); + for (i = 0; i < ATTR3_DIM1; i++) + for (j = 0; j < ATTR3_DIM2; j++) + for (k = 0; k < ATTR3_DIM3; k++) + if (attr_data3[i][j][k] != read_data3[i][j][k]) + TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, " + "read_data3[%d][%d][%d]=%f\n", + __LINE__, i, j, k, attr_data3[i][j][k], i, j, k, read_data3[i][j][k]); // Verify Name attr_name = attr.getName(); @@ -1119,11 +1148,10 @@ static void test_attr_mult_read() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_mult_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_mult_read() +} // test_attr_mult_read() /**************************************************************** ** @@ -1131,10 +1159,10 @@ static void test_attr_mult_read() ** hdf5 objects. ** ****************************************************************/ -static void test_attr_delete() +static void +test_attr_delete() { - H5std_string attr_name; // Buffer for attribute names - int ii; + H5std_string attr_name; // Buffer for attribute names // Output message about test being performed SUBTEST("Removing Attribute Function"); @@ -1156,10 +1184,10 @@ static void test_attr_delete() // Verify the name of the only file attribute left Attribute fattr = fid1.openAttribute((unsigned)0); - attr_name = fattr.getName(); + attr_name = fattr.getName(); verify_val(attr_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); fattr.close(); - + // Test deleting non-existing attribute // Open the dataset @@ -1174,10 +1202,12 @@ static void test_attr_delete() dataset.removeAttr("Bogus"); // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::removeAttr", "Attempting to remove non-existing attribute"); + throw InvalidActionException("DataSet::removeAttr", + "Attempting to remove non-existing attribute"); } - catch (AttributeIException& E) // catching invalid removing attribute - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid removing attribute + { + } // do nothing, exception expected // Test deleting dataset's attributes @@ -1237,11 +1267,10 @@ static void test_attr_delete() PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_delete()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_delete() +} // test_attr_delete() /**************************************************************** ** @@ -1249,14 +1278,15 @@ static void test_attr_delete() ** in attributes. ** ****************************************************************/ -static void test_attr_dtype_shared() +static void +test_attr_dtype_shared() { - int data=8; /* Data to write */ - int rdata=0; /* Read read in */ + int data = 8; /* Data to write */ + int rdata = 0; /* Read read in */ #ifndef H5_NO_DEPRECATED_SYMBOLS - H5G_stat_t statbuf; /* Object's information */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - h5_stat_size_t filesize; /* Size of file after modifications */ + H5G_stat_t statbuf; /* Object's information */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + h5_stat_size_t filesize; /* Size of file after modifications */ // Output message about test being performed SUBTEST("Shared Datatypes with Attributes"); @@ -1269,7 +1299,7 @@ static void test_attr_dtype_shared() fid1.close(); // Get size of file - h5_stat_size_t empty_filesize; // Size of empty file + h5_stat_size_t empty_filesize; // Size of empty file empty_filesize = h5_get_file_size(FILE_DTYPE.c_str(), H5P_DEFAULT); if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); @@ -1282,76 +1312,77 @@ static void test_attr_dtype_shared() // scope, causing incorrect number of ref counts. { // First enclosed block - // Create a datatype to commit and use - IntType dtype(PredType::NATIVE_INT); + // Create a datatype to commit and use + IntType dtype(PredType::NATIVE_INT); - // Commit datatype to file - dtype.commit(fid1, TYPE1_NAME); + // Commit datatype to file + dtype.commit(fid1, TYPE1_NAME); - // Retrieve and verify information about the type - H5O_info_t oinfo; - dtype.getObjectInfo(TYPE1_NAME, &oinfo); - fid1.getObjectInfo(TYPE1_NAME, &oinfo); - if (oinfo.type != H5O_TYPE_NAMED_DATATYPE) - TestErrPrintf("Line %d: object type wrong!\n", __LINE__); - verify_val(oinfo.num_attrs, 0, "DataType::getObjinfo reference count", __LINE__, __FILE__); - verify_val((int)oinfo.rc, 1, "DataType::getObjinfo reference count", __LINE__, __FILE__); + // Retrieve and verify information about the type + H5O_info_t oinfo; + dtype.getObjectInfo(TYPE1_NAME, &oinfo); + fid1.getObjectInfo(TYPE1_NAME, &oinfo); + if (oinfo.type != H5O_TYPE_NAMED_DATATYPE) + TestErrPrintf("Line %d: object type wrong!\n", __LINE__); + verify_val(oinfo.num_attrs, 0, "DataType::getObjinfo reference count", __LINE__, __FILE__); + verify_val((int)oinfo.rc, 1, "DataType::getObjinfo reference count", __LINE__, __FILE__); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 1, "DataType::getObjinfo", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 1, "DataType::getObjinfo", __LINE__, __FILE__); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Create dataspace for dataset - DataSpace dspace; + // Create dataspace for dataset + DataSpace dspace; - DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace); + DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 2, "H5File::getObjinfo", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 2, "H5File::getObjinfo", __LINE__, __FILE__); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Create attribute on dataset - Attribute attr = dset.createAttribute(ATTR1_NAME,dtype,dspace); + // Create attribute on dataset + Attribute attr = dset.createAttribute(ATTR1_NAME, dtype, dspace); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Close attribute - attr.close(); + // Close attribute + attr.close(); - // Delete attribute - dset.removeAttr(ATTR1_NAME); + // Delete attribute + dset.removeAttr(ATTR1_NAME); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__, + __FILE__); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Create attribute on dataset - attr = dset.createAttribute(ATTR1_NAME,dtype,dspace); + // Create attribute on dataset + attr = dset.createAttribute(ATTR1_NAME, dtype, dspace); #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::createAttribute", __LINE__, __FILE__); + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 3, "DataSet::createAttribute", __LINE__, __FILE__); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - // Write data into the attribute - attr.write(PredType::NATIVE_INT,&data); + // Write data into the attribute + attr.write(PredType::NATIVE_INT, &data); - // Close attribute, dataset, dataspace, datatype, and file - attr.close(); - dset.close(); - dspace.close(); - dtype.close(); + // Close attribute, dataset, dataspace, datatype, and file + attr.close(); + dset.close(); + dspace.close(); + dtype.close(); } // end of first enclosing fid1.close(); @@ -1361,25 +1392,25 @@ static void test_attr_dtype_shared() { // Second enclosed block... - // Open dataset - DataSet *dset2 = new DataSet (fid1.openDataSet(DSET1_NAME)); + // Open dataset + DataSet *dset2 = new DataSet(fid1.openDataSet(DSET1_NAME)); - // Open attribute - Attribute *attr2 = new Attribute (dset2->openAttribute(ATTR1_NAME)); + // Open attribute + Attribute *attr2 = new Attribute(dset2->openAttribute(ATTR1_NAME)); - // Read data from the attribute - attr2->read(PredType::NATIVE_INT, &rdata); - verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__); + // Read data from the attribute + attr2->read(PredType::NATIVE_INT, &rdata); + verify_val(data, rdata, "Attribute::read", __LINE__, __FILE__); - // Close attribute and dataset - delete attr2; - delete dset2; + // Close attribute and dataset + delete attr2; + delete dset2; #ifndef H5_NO_DEPRECATED_SYMBOLS - // Check reference count on named datatype - fid1.getObjinfo(TYPE1_NAME, statbuf); - verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ + // Check reference count on named datatype + fid1.getObjinfo(TYPE1_NAME, statbuf); + verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ } // end of second enclosing // Unlink the dataset @@ -1402,21 +1433,18 @@ static void test_attr_dtype_shared() verify_val((long)filesize, (long)empty_filesize, "Checking file size", __LINE__, __FILE__); PASSED(); - } // end try block + } // end try block - catch (DataTypeIException& E) - { + catch (DataTypeIException &E) { issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); } - catch (FileIException& E) - { + catch (FileIException &E) { issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_dtype_shared() +} // test_attr_dtype_shared() /**************************************************************** ** @@ -1429,9 +1457,10 @@ const H5std_string ATTR1_FL_STR_NAME("String_attr 1"); const H5std_string ATTR2_FL_STR_NAME("String_attr 2"); const H5std_string ATTR_VL_STR_NAME("String_attr"); const H5std_string ATTRSTR_DATA("String Attribute"); -const int ATTR_LEN = 17; +const int ATTR_LEN = 17; -static void test_string_attr() +static void +test_string_attr() { // Output message about test being performed SUBTEST("I/O on FL and VL String Attributes"); @@ -1450,7 +1479,7 @@ static void test_string_attr() Group root = fid1.openGroup("/"); // Create dataspace for the attribute. - DataSpace att_space (H5S_SCALAR); + DataSpace att_space(H5S_SCALAR); /* Test Attribute::write(...,const void *buf) with Fixed len string */ @@ -1473,18 +1502,20 @@ static void test_string_attr() // Read and verify the attribute string as a string of chars. char flstring_att_check[ATTR_LEN]; gr_flattr1.read(fls_type, flstring_att_check); - if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); + if (HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); // Read and verify the attribute string as a string of chars; buffer // is dynamically allocated. size_t attr_size = gr_flattr1.getInMemDataSize(); - char *fl_dyn_string_att_check; - fl_dyn_string_att_check = new char[attr_size+1]; + char * fl_dyn_string_att_check; + fl_dyn_string_att_check = new char[attr_size + 1]; gr_flattr1.read(fls_type, fl_dyn_string_att_check); - if(HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check); - delete []fl_dyn_string_att_check; + if (HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check); + delete[] fl_dyn_string_att_check; /* Test Attribute::read(...,H5std_string& strg) with FL string */ @@ -1492,13 +1523,15 @@ static void test_string_attr() H5std_string read_flstr1; gr_flattr1.read(fls_type, read_flstr1); if (read_flstr1 != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr1.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_flstr1.c_str()); // Read and verify the attribute string as a string of chars. HDstrcpy(flstring_att_check, ""); gr_flattr2.read(fls_type, flstring_att_check); - if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); + if (HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); /* Test Attribute::read(...,H5std_string& strg) with FL string */ @@ -1506,7 +1539,8 @@ static void test_string_attr() H5std_string read_flstr2; gr_flattr2.read(fls_type, read_flstr2); if (read_flstr2 != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr2.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_flstr2.c_str()); // // Variable-lenth string attributes @@ -1524,8 +1558,9 @@ static void test_string_attr() // Read and verify the attribute string as a string of chars. char *string_att_check; gr_vlattr.read(vls_type, &string_att_check); - if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check); + if (HDstrcmp(string_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), string_att_check); HDfree(string_att_check); /* Test Attribute::read(...,H5std_string& strg) with VL string */ @@ -1533,15 +1568,15 @@ static void test_string_attr() H5std_string read_str; gr_vlattr.read(vls_type, read_str); if (read_str != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_str.c_str()); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_string_attr() +} // test_string_attr() /**************************************************************** ** @@ -1549,7 +1584,8 @@ static void test_string_attr() ** (additional attrExists tests are in test_attr_rename()) ** ****************************************************************/ -static void test_attr_exists() +static void +test_attr_exists() { // Output message about test being performed SUBTEST("Check Attribute Existence"); @@ -1564,12 +1600,14 @@ static void test_attr_exists() // Check for existence of attribute bool attr_exists = fid1.attrExists(ATTR1_FL_STR_NAME); if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not"); + throw InvalidActionException("H5File::attrExists", + "fid1, ATTR1_FL_STR_NAMEAttribute should exist but does not"); // Check for existence of attribute attr_exists = fid1.attrExists(FATTR1_NAME); if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "fid1,FATTR2_NAMEAttribute should exist but does not"); + throw InvalidActionException("H5File::attrExists", + "fid1,FATTR2_NAMEAttribute should exist but does not"); // Open a group. Group group = fid1.openGroup(GROUP1_NAME); @@ -1577,7 +1615,8 @@ static void test_attr_exists() // Check for existence of attribute, Group::attrExists attr_exists = group.attrExists(ATTR2_NAME); if (attr_exists == false) - throw InvalidActionException("H5File::attrExists", "group, ATTR2_NAMEAttribute should exist but does not"); + throw InvalidActionException("H5File::attrExists", + "group, ATTR2_NAMEAttribute should exist but does not"); // Open attribute Attribute attr = group.openAttribute(ATTR2_NAME); @@ -1586,20 +1625,19 @@ static void test_attr_exists() // Attribute::nameExists bool name_exists = attr.nameExists(GROUP1_NAME); if (name_exists == false) - throw InvalidActionException("Attribute::nameExists", "group GROUP1_NAME should exist but does not"); + throw InvalidActionException("Attribute::nameExists", + "group GROUP1_NAME should exist but does not"); PASSED(); } // end try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_exists() +} // test_attr_exists() /**************************************************************** ** @@ -1608,25 +1646,25 @@ static void test_attr_exists() ** ****************************************************************/ const H5std_string FILE_CRTPROPS("tattr_crt_properties.h5"); -const int NAME_BUF_SIZE = 1024; -const unsigned MAX_COMPACT_DEF = 8; -const unsigned MIN_DENSE_DEF = 6; +const int NAME_BUF_SIZE = 1024; +const unsigned MAX_COMPACT_DEF = 8; +const unsigned MIN_DENSE_DEF = 6; -static void test_attr_dense_create(FileCreatPropList& fcpl, - FileAccPropList& fapl) +static void +test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl) { // Output message about test being performed SUBTEST("Dense Attribute Storage Creation"); try { // Create file - H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + H5File fid1(FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); // Close file fid1.close(); // Get size of file - h5_stat_size_t empty_filesize; // Size of empty file + h5_stat_size_t empty_filesize; // Size of empty file empty_filesize = h5_get_file_size(FILE_CRTPROPS.c_str(), fapl.getId()); if (empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); @@ -1647,16 +1685,18 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // Retrieve limits for compact/dense attribute storage dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange", __LINE__, __FILE__); + verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange", __LINE__, __FILE__); // Set new compact/dense attribute storage limits to some random numbers dcpl.setAttrPhaseChange(7, 5); // Retrieve limits for compact/dense attribute storage and verify them dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, static_cast<unsigned>(7), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, static_cast<unsigned>(5), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(max_compact, static_cast<unsigned>(7), "DSetCreatPropList::getAttrPhaseChange", __LINE__, + __FILE__); + verify_val(min_dense, static_cast<unsigned>(5), "DSetCreatPropList::getAttrPhaseChange", __LINE__, + __FILE__); // Close property list dcpl.close(); @@ -1664,10 +1704,9 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // H5O_is_attr_dense_test - un-usable // Add attributes, until just before converting to dense storage - char attr_name[NAME_BUF_SIZE]; + char attr_name[NAME_BUF_SIZE]; unsigned attr_num; - for (attr_num = 0; attr_num < max_compact; attr_num++) - { + for (attr_num = 0; attr_num < max_compact; attr_num++) { // Create attribute sprintf(attr_name, "attr %02u", attr_num); Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); @@ -1689,26 +1728,26 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, } // Attempt to add attribute again, which should fail - try - { + try { // Create another attribute sprintf(attr_name, "attr %02u", attr_num); Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); // continuation here, that means no exception has been thrown - throw InvalidActionException("DataSet::createAttribute", "Maximum number of attributes has been reached"); + throw InvalidActionException("DataSet::createAttribute", + "Maximum number of attributes has been reached"); } - catch (AttributeIException& E) // catching invalid action - {} // do nothing, exception expected + catch (AttributeIException &E) // catching invalid action + { + } // do nothing, exception expected PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_dense_create()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_dense_create() +} // test_attr_dense_create() /**************************************************************** ** @@ -1716,23 +1755,23 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, ** Tests creating an object w/attribute creation order info ** ****************************************************************/ -static void test_attr_corder_create_basic(FileCreatPropList& fcpl, - FileAccPropList& fapl) +static void +test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl) { // Output message about test being performed SUBTEST("Basic Code for Attributes with Creation Order Info"); try { // Create file - H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + H5File fid1(FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); // Create dataset creation property list. DSetCreatPropList dcpl; // Get creation order indexing on object unsigned crt_order_flags = 0; - crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, 0, "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + crt_order_flags = dcpl.getAttrCrtOrder(); + verify_val(crt_order_flags, 0, "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); // Setting invalid combination of a attribute order creation order // indexing on should fail @@ -1740,16 +1779,19 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, dcpl.setAttrCrtOrder(H5P_CRT_ORDER_INDEXED); // continuation here, that means no exception has been thrown - throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", "Indexing cannot be set alone, order tracking is required"); + throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", + "Indexing cannot be set alone, order tracking is required"); } - catch (PropListIException& E) // catching invalid action - {} // do nothing, exception expected + catch (PropListIException &E) // catching invalid action + { + } // do nothing, exception expected // Set attribute creation order tracking & indexing for object then // verify them dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + verify_val(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), + "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); // Create dataspace for dataset DataSpace ds_space(H5S_SCALAR); @@ -1784,31 +1826,30 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, // Query the attribute creation properties crt_order_flags = dcpl.getAttrCrtOrder(); - verify_val(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + verify_val(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), + "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__); PASSED(); } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr_corder_create_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr_corder_create_basic() +} // test_attr_corder_create_basic() /**************************************************************** ** ** test_attr(): Main attribute testing routine. ** ****************************************************************/ -extern "C" -void test_attr() +extern "C" void +test_attr() { // Output message about test being performed - //MESSAGE("Testing Attributes\n"); + // MESSAGE("Testing Attributes\n"); MESSAGE(5, ("Testing Attributes\n")); - try - { + try { // Create a default file access property list FileAccPropList fapl; @@ -1830,45 +1871,41 @@ void test_attr() // Loop over using new group format hbool_t new_format; - for (new_format = FALSE; new_format <= TRUE; new_format++) - { + for (new_format = FALSE; new_format <= TRUE; new_format++) { FileAccPropList curr_fapl; // Set the file access proplist for the type of format - if (new_format) - { - MESSAGE(7, ("testing with new file format\n")); - curr_fapl = fapl_new; + if (new_format) { + MESSAGE(7, ("testing with new file format\n")); + curr_fapl = fapl_new; } - else - { - MESSAGE(7, ("testing with old file format\n")); - curr_fapl = fapl; + else { + MESSAGE(7, ("testing with old file format\n")); + curr_fapl = fapl; } - test_attr_basic_write(); // Test basic H5A writing code - test_attr_getname(); // Test overloads of Attribute::getName - test_attr_rename(); // Test renaming attribute - test_attr_basic_read(); // Test basic H5A reading code + test_attr_basic_write(); // Test basic H5A writing code + test_attr_getname(); // Test overloads of Attribute::getName + test_attr_rename(); // Test renaming attribute + test_attr_basic_read(); // Test basic H5A reading code test_attr_compound_write(); // Test complex datatype H5A writing code test_attr_compound_read(); // Test complex datatype H5A reading code - test_attr_scalar_write(); // Test scalar dataspace H5A writing code - test_attr_scalar_read(); // Test scalar dataspace H5A reading code + test_attr_scalar_write(); // Test scalar dataspace H5A writing code + test_attr_scalar_read(); // Test scalar dataspace H5A reading code - test_attr_mult_write(); // Test writing multiple attributes - test_attr_mult_read(); // Test reading multiple attributes - test_attr_delete(); // Test deleting attributes + test_attr_mult_write(); // Test writing multiple attributes + test_attr_mult_read(); // Test reading multiple attributes + test_attr_delete(); // Test deleting attributes - test_attr_dtype_shared(); // Test using shared datatypes in attributes + test_attr_dtype_shared(); // Test using shared datatypes in attributes - test_string_attr(); // Test read/write string attribute - test_attr_exists(); // Test H5Location::attrExists + test_string_attr(); // Test read/write string attribute + test_attr_exists(); // Test H5Location::attrExists // Test with new format - if (new_format) - { + if (new_format) { // Test dense attribute storage creation test_attr_dense_create(fcpl, curr_fapl); @@ -1876,14 +1913,13 @@ void test_attr() test_attr_corder_create_basic(fcpl, curr_fapl); } } // end for - } // end try block + } // end try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_attr() - +} // test_attr() + /*------------------------------------------------------------------------- * Function: cleanup_attr * @@ -1896,8 +1932,8 @@ void test_attr() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_attr() +extern "C" void +cleanup_attr() { HDremove(FILE_BASIC.c_str()); HDremove(FILE_COMPOUND.c_str()); @@ -1906,4 +1942,3 @@ void cleanup_attr() HDremove(FILE_DTYPE.c_str()); HDremove(FILE_CRTPROPS.c_str()); } - diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index ce2d061..7864b40 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,10 +26,11 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file /* Number of elements in each test */ #define NTESTELEM 100000 @@ -39,7 +40,6 @@ typedef struct complex_t { double im; } complex_t; - /*------------------------------------------------------------------------- * Function: test_compound_1 * @@ -52,7 +52,8 @@ typedef struct complex_t { * *------------------------------------------------------------------------- */ -static void test_compound_1() +static void +test_compound_1() { // Output message about test being performed SUBTEST("Compound Data Types"); @@ -64,15 +65,13 @@ static void test_compound_1() complex_type.insertMember("real", HOFFSET(complex_t, re), PredType::NATIVE_DOUBLE); complex_type.insertMember("imaginary", HOFFSET(complex_t, im), PredType::NATIVE_DOUBLE); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_1() +} // test_compound_1() - /*------------------------------------------------------------------------- * Function: test_compound_2 * @@ -87,7 +86,8 @@ static void test_compound_1() * *------------------------------------------------------------------------- */ -static void test_compound_2() +static void +test_compound_2() { typedef struct { int a, b, c[4], d, e; @@ -96,33 +96,33 @@ static void test_compound_2() int e, d, c[4], b, a; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - const int nelmts = NTESTELEM; - const hsize_t four = 4; - int i; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + const int nelmts = NTESTELEM; + const hsize_t four = 4; + int i; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; - ArrayType *array_dt = NULL; + ArrayType * array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Reordering"); try { // Sizes should be the same, but be careful just in case - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - s_ptr->a = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); // Build hdf5 datatypes array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -152,27 +152,20 @@ static void test_compound_2() st.convert(dt, (size_t)nelmts, buf, bkg); // Compare results - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - d_ptr = ((dst_typ_t*)buf) + i; - if (s_ptr->a != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; } } // Release resources @@ -184,18 +177,16 @@ static void test_compound_2() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_2() +} // test_compound_2() - /*------------------------------------------------------------------------- * Function: test_compound_3 * @@ -210,42 +201,43 @@ static void test_compound_2() * *------------------------------------------------------------------------- */ -static void test_compound_3() +static void +test_compound_3() { typedef struct { int a, b, c[4], d, e; } src_typ_t; typedef struct { - int a, c[4], e; + int a, c[4], e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - const hsize_t four = 4; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + int i; + const int nelmts = NTESTELEM; + const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; - ArrayType* array_dt = NULL; + ArrayType * array_dt = NULL; // Output message about test being performed SUBTEST("Compound Datatype Subset Conversions"); try { /* Initialize */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - s_ptr->a = i*8+0; - s_ptr->b = i*8+1; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = i*8+6; - s_ptr->e = i*8+7; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = i * 8 + 1; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = i * 8 + 6; + s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); /* Build hdf5 datatypes */ array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -273,27 +265,20 @@ static void test_compound_3() st.convert(dt, (size_t)nelmts, buf, bkg); /* Compare results */ - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - d_ptr = ((dst_typ_t*)buf) + i; - if (s_ptr->a != d_ptr->a || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->e != d_ptr->e) { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->a != d_ptr->a || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] || + s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->e != d_ptr->e) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << ", c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << "], d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << d_ptr->a - << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," - << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" - << d_ptr->e << "}" << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << ", c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << "], d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << d_ptr->a << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," + << d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" << d_ptr->e << "}" << endl; } // if - } // for + } // for /* Release resources */ HDfree(buf); @@ -304,18 +289,16 @@ static void test_compound_3() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_3() +} // test_compound_3() - /*------------------------------------------------------------------------- * Function: test_compound_4 * @@ -330,7 +313,8 @@ static void test_compound_3() * *------------------------------------------------------------------------- */ -static void test_compound_4() +static void +test_compound_4() { typedef struct { @@ -339,38 +323,38 @@ static void test_compound_4() typedef struct { short b; - int a, c[4]; + int a, c[4]; short d; - int e; + int e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - const hsize_t four = 4; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + int i; + const int nelmts = NTESTELEM; + const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; - ArrayType* array_dt = NULL; + ArrayType * array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Shrinking & Reordering"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - s_ptr->a = i*8+0; - s_ptr->b = (i*8+1) & 0x7fff; - s_ptr->c[0] = i*8+2; - s_ptr->c[1] = i*8+3; - s_ptr->c[2] = i*8+4; - s_ptr->c[3] = i*8+5; - s_ptr->d = (i*8+6) & 0x7fff; - s_ptr->e = i*8+7; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->a = i * 8 + 0; + s_ptr->b = (i * 8 + 1) & 0x7fff; + s_ptr->c[0] = i * 8 + 2; + s_ptr->c[1] = i * 8 + 3; + s_ptr->c[2] = i * 8 + 4; + s_ptr->c[3] = i * 8 + 5; + s_ptr->d = (i * 8 + 6) & 0x7fff; + s_ptr->e = i * 8 + 7; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); /* Build hdf5 datatypes */ array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -400,30 +384,22 @@ static void test_compound_4() st.convert(dt, (size_t)nelmts, buf, bkg); /* Compare results */ - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - d_ptr = ((dst_typ_t*)buf) + i; - if (s_ptr->a != d_ptr->a || - s_ptr->b != d_ptr->b || - s_ptr->c[0] != d_ptr->c[0] || - s_ptr->c[1] != d_ptr->c[1] || - s_ptr->c[2] != d_ptr->c[2] || - s_ptr->c[3] != d_ptr->c[3] || - s_ptr->d != d_ptr->d || - s_ptr->e != d_ptr->e) - { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] || + s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || + s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b - << "c=[" << s_ptr->c[0] << "," << s_ptr->c[1] << "," - << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" - << s_ptr->d << ", e=" << s_ptr->e << "}" << endl; - cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b - << "c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << "," - << d_ptr->c[2] << "," << d_ptr->c[3] << ", d=" - << d_ptr->d << ", e=" << d_ptr->e << "}" << endl; + cerr << " src={a=" << s_ptr->a << ", b=" << s_ptr->b << "c=[" << s_ptr->c[0] << "," + << s_ptr->c[1] << "," << s_ptr->c[2] << "," << s_ptr->c[3] << ", d=" << s_ptr->d + << ", e=" << s_ptr->e << "}" << endl; + cerr << " dst={a=" << d_ptr->a << ", b=" << d_ptr->b << "c=[" << d_ptr->c[0] << "," + << d_ptr->c[1] << "," << d_ptr->c[2] << "," << d_ptr->c[3] << ", d=" << d_ptr->d + << ", e=" << d_ptr->e << "}" << endl; } // if - } // for + } // for /* Release resources */ HDfree(buf); @@ -434,18 +410,16 @@ static void test_compound_4() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_4() +} // test_compound_4() - /*------------------------------------------------------------------------- * Function: test_compound_5 * @@ -461,27 +435,27 @@ static void test_compound_4() * *------------------------------------------------------------------------- */ -static void test_compound_5() +static void +test_compound_5() { typedef struct { - char name[16]; - short tdim; - short coll_ids[4]; + char name[16]; + short tdim; + short coll_ids[4]; } src_typ_t; typedef struct { - char name[16]; - short tdim; - int coll_ids[4]; + char name[16]; + short tdim; + int coll_ids[4]; } dst_typ_t; - hsize_t dims[1] = {4}; - src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, - {"two", 202, {204, 205, 206, 207}}}; + hsize_t dims[1] = {4}; + src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, {"two", 202, {204, 205, 206, 207}}}; dst_typ_t *dst; - void *buf = HDcalloc(2, sizeof(dst_typ_t)); - void *bkg = HDcalloc(2, sizeof(dst_typ_t)); - ArrayType* array_dt = NULL; + void * buf = HDcalloc(2, sizeof(dst_typ_t)); + void * bkg = HDcalloc(2, sizeof(dst_typ_t)); + ArrayType *array_dt = NULL; // Output message about test being performed SUBTEST("Optimized Struct Converter"); @@ -489,17 +463,17 @@ static void test_compound_5() /* Build datatypes */ array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims); - CompType short_array(4*sizeof(short)); + CompType short_array(4 * sizeof(short)); short_array.insertMember("_", 0, *array_dt); array_dt->close(); delete array_dt; - CompType int_array(4*sizeof(int)); + CompType int_array(4 * sizeof(int)); array_dt = new ArrayType(PredType::NATIVE_INT, 1, dims); int_array.insertMember("_", 0, *array_dt); array_dt->close(); - StrType strg(PredType::C_S1, 16); + StrType strg(PredType::C_S1, 16); CompType src_type(sizeof(src_typ_t)); src_type.insertMember("name", HOFFSET(src_typ_t, name), strg); src_type.insertMember("tdim", HOFFSET(src_typ_t, tdim), PredType::NATIVE_SHORT); @@ -513,7 +487,7 @@ static void test_compound_5() /* Convert data */ memcpy(buf, src, sizeof(src)); src_type.convert(dst_type, (size_t)2, buf, bkg); - dst = (dst_typ_t*)buf; + dst = (dst_typ_t *)buf; /* Cleanup */ src_type.close(); @@ -523,31 +497,27 @@ static void test_compound_5() int_array.close(); /* Check results */ - if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || - src[1].tdim!=dst[1].tdim || - src[1].coll_ids[0]!=dst[1].coll_ids[0] || - src[1].coll_ids[1]!=dst[1].coll_ids[1] || - src[1].coll_ids[2]!=dst[1].coll_ids[2] || - src[1].coll_ids[3]!=dst[1].coll_ids[3]) - { H5_FAILED(); } + if (memcmp(src[1].name, dst[1].name, sizeof(src[1].name)) || src[1].tdim != dst[1].tdim || + src[1].coll_ids[0] != dst[1].coll_ids[0] || src[1].coll_ids[1] != dst[1].coll_ids[1] || + src[1].coll_ids[2] != dst[1].coll_ids[2] || src[1].coll_ids[3] != dst[1].coll_ids[3]) { + H5_FAILED(); + } /* Free memory buffers */ HDfree(buf); HDfree(bkg); dst = NULL; PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } - if(array_dt) + if (array_dt) delete array_dt; -} // test_compound_5() +} // test_compound_5() - /*------------------------------------------------------------------------- * Function: test_compound_6 * @@ -562,7 +532,8 @@ static void test_compound_5() * *------------------------------------------------------------------------- */ -static void test_compound_6() +static void +test_compound_6() { typedef struct { short b; @@ -574,25 +545,25 @@ static void test_compound_6() long d; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; + src_typ_t * s_ptr; + dst_typ_t * d_ptr; + int i; + const int nelmts = NTESTELEM; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; // Output message about test being performed SUBTEST("Compound Element Growing"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - s_ptr->b = (i*8+1) & 0x7fff; - s_ptr->d = (i*8+6) & 0x7fff; + buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t)); + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + s_ptr->b = (i * 8 + 1) & 0x7fff; + s_ptr->d = (i * 8 + 6) & 0x7fff; } - memcpy(buf, orig, nelmts*sizeof(src_typ_t)); + memcpy(buf, orig, nelmts * sizeof(src_typ_t)); /* Build hdf5 datatypes */ CompType st(sizeof(src_typ_t)); @@ -607,20 +578,16 @@ static void test_compound_6() st.convert(dt, (size_t)nelmts, buf, bkg); /* Compare results */ - for (i=0; i<nelmts; i++) { - s_ptr = ((src_typ_t*)orig) + i; - d_ptr = ((dst_typ_t*)buf) + i; - if (s_ptr->b != d_ptr->b || - s_ptr->d != d_ptr->d) - { + for (i = 0; i < nelmts; i++) { + s_ptr = ((src_typ_t *)orig) + i; + d_ptr = ((dst_typ_t *)buf) + i; + if (s_ptr->b != d_ptr->b || s_ptr->d != d_ptr->d) { H5_FAILED(); cerr << " i=" << i << endl; - cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d - << "}" << endl; - cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d - << "}" << endl; + cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d << "}" << endl; + cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d << "}" << endl; } // if - } // for + } // for /* Release resources */ HDfree(buf); @@ -631,13 +598,12 @@ static void test_compound_6() st.close(); dt.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_6() +} // test_compound_6() /*------------------------------------------------------------------------- * Function: test_compound_7 @@ -652,18 +618,19 @@ static void test_compound_6() * *------------------------------------------------------------------------- */ -static void test_compound_7() +static void +test_compound_7() { typedef struct { - int a; + int a; float b; - long c; + long c; } s1_typ_t; typedef struct { - int a; - float b; - long c; + int a; + float b; + long c; double d; } s2_typ_t; @@ -672,9 +639,9 @@ static void test_compound_7() try { CompType tid1(sizeof(s1_typ_t)); - tid1.insertMember("a", HOFFSET(s1_typ_t,a),PredType::NATIVE_INT); - tid1.insertMember("b", HOFFSET(s1_typ_t,b),PredType::NATIVE_FLOAT); - tid1.insertMember("c", HOFFSET(s1_typ_t,c),PredType::NATIVE_LONG); + tid1.insertMember("a", HOFFSET(s1_typ_t, a), PredType::NATIVE_INT); + tid1.insertMember("b", HOFFSET(s1_typ_t, b), PredType::NATIVE_FLOAT); + tid1.insertMember("c", HOFFSET(s1_typ_t, c), PredType::NATIVE_LONG); size_t type_size = tid1.getSize(); verify_val(type_size, sizeof(s1_typ_t), "DataType::getSize", __LINE__, __FILE__); @@ -689,21 +656,23 @@ static void test_compound_7() try { tid2.insertMember("d", HOFFSET(s2_typ_t, d), PredType::NATIVE_DOUBLE); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("CompType::insertMember", "Attempted to insert field past end of compound data type."); - } catch (DataTypeIException& err) {} + throw InvalidActionException("CompType::insertMember", + "Attempted to insert field past end of compound data type."); + } + catch (DataTypeIException &err) { + } /* Release resources */ tid1.close(); tid2.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_7() - +} // test_compound_7() + /*------------------------------------------------------------------------- * Function: test_compound_set_size * @@ -717,7 +686,8 @@ static void test_compound_7() *------------------------------------------------------------------------- */ const H5std_string COMPFILE("tcompound_types.h5"); -static void test_compound_set_size() +static void +test_compound_set_size() { typedef struct { int a, b, c[4], d, e; @@ -784,14 +754,13 @@ static void test_compound_set_size() file.close(); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compound_set_size() - +} // test_compound_set_size() + /*------------------------------------------------------------------------- * Function: test_compound * @@ -804,23 +773,22 @@ static void test_compound_set_size() * *------------------------------------------------------------------------- */ -extern "C" -void test_compound() +extern "C" void +test_compound() { // Output message about test being performed MESSAGE(5, ("Testing Compound Data Type operations\n")); - test_compound_1(); // various things about compound data types - test_compound_2(); // compound element reordering - test_compound_3(); // compound datatype subset conversions - test_compound_4(); // compound element shrinking & reordering - test_compound_5(); // optimized struct converter - test_compound_6(); // compound element growing - test_compound_7(); // compound element insertion - test_compound_set_size(); // set size on compound data types -} // test_compound() - - + test_compound_1(); // various things about compound data types + test_compound_2(); // compound element reordering + test_compound_3(); // compound datatype subset conversions + test_compound_4(); // compound element shrinking & reordering + test_compound_5(); // optimized struct converter + test_compound_6(); // compound element growing + test_compound_7(); // compound element insertion + test_compound_set_size(); // set size on compound data types +} // test_compound() + /*------------------------------------------------------------------------- * Function: cleanup_compound * @@ -830,8 +798,8 @@ void test_compound() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_compound() +extern "C" void +cleanup_compound() { HDremove(COMPFILE.c_str()); -} // cleanup_file +} // cleanup_file diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp index 0a60a86..4170387 100644 --- a/c++/test/tdspl.cpp +++ b/c++/test/tdspl.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -27,19 +27,21 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file const H5std_string FILENAME("tdatatransform.h5"); -static void test_transfplist() +static void +test_transfplist() { - const char* c_to_f = "(9/5.0)*x + 32"; - const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ + const char *c_to_f = "(9/5.0)*x + 32"; + const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ /* inverses the utrans transform in init_test to get back original array */ - const char* utrans_inv = "(x/3)*4 - 100"; + const char *utrans_inv = "(x/3)*4 - 100"; SUBTEST("DSetMemXferPropList::set/getDataTransform()"); try { @@ -63,12 +65,12 @@ static void test_transfplist() // Find out the length of the transform expression, allocate the buffer // for it, then read and verify the expression from the copied plist - ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); - char *c_to_f_read = (char *)HDmalloc(tran_len+1); - HDmemset(c_to_f_read, 0, tran_len+1); - dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len+1); - verify_val((const char*)c_to_f_read, (const char*)c_to_f, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL); + char * c_to_f_read = (char *)HDmalloc(tran_len + 1); + HDmemset(c_to_f_read, 0, tran_len + 1); + dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len + 1); + verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform", + __LINE__, __FILE__); HDfree(c_to_f_read); // @@ -78,57 +80,54 @@ static void test_transfplist() // Get and verify the expression with: // ssize_t getDataTransform(char* exp, const size_t buf_size [default=0]) - tran_len = dxpl_c_to_f.getDataTransform(NULL); - c_to_f_read = (char *)HDmalloc(tran_len+1); - HDmemset(c_to_f_read, 0, tran_len+1); - dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len+1); - verify_val((const char*)c_to_f_read, (const char*)c_to_f, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + tran_len = dxpl_c_to_f.getDataTransform(NULL); + c_to_f_read = (char *)HDmalloc(tran_len + 1); + HDmemset(c_to_f_read, 0, tran_len + 1); + dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len + 1); + verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform", + __LINE__, __FILE__); HDfree(c_to_f_read); // Get and verify the expression with: // H5std_string DSetMemXferPropList::getDataTransform() H5std_string simple_read = dxpl_simple.getDataTransform(); - verify_val((const char*)simple_read.c_str(), (const char*)simple, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + verify_val((const char *)simple_read.c_str(), (const char *)simple, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); // Get and verify the expression with: // ssize_t getDataTransform(char* exp, const size_t buf_size) - tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); - char *utrans_inv_read = (char *)HDmalloc(tran_len+1); - HDmemset(utrans_inv_read, 0, tran_len+1); - dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len+1); - verify_val((const char*)utrans_inv_read, (const char*)utrans_inv, - "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); + tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0); + char *utrans_inv_read = (char *)HDmalloc(tran_len + 1); + HDmemset(utrans_inv_read, 0, tran_len + 1); + dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len + 1); + verify_val((const char *)utrans_inv_read, (const char *)utrans_inv, + "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__); HDfree(utrans_inv_read); PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_transfplist", __LINE__, __FILE__, E.getCDetailMsg()); } } - /**************************************************************** ** ** test_dsproplist(): Main dataset property list testing routine. ** ****************************************************************/ -extern "C" -void test_dsproplist() +extern "C" void +test_dsproplist() { // Output message about test being performed MESSAGE(5, ("Testing Generic Dataset Property Lists\n")); test_transfplist(); // test set/getDataTransform() -} // test_dsproplist() +} // test_dsproplist() - -extern "C" -void cleanup_dsproplist() +extern "C" void +cleanup_dsproplist() { HDremove(FILENAME.c_str()); } diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index b998f76..c516381 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -48,16 +48,16 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file int main(int argc, char *argv[]) { - try - { + try { // Turn of the auto-printing when failure occurs so that we can // handle the errors appropriately since sometime failures are // caused deliberately and expected. @@ -70,37 +70,36 @@ main(int argc, char *argv[]) // testing dataset functionalities in dset.cpp AddTest("dsets", test_dset, cleanup_dsets, "Dataset I/O Operations", NULL); // testing dataspace functionalities in th5s.cpp - AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); + AddTest("th5s", test_h5s, cleanup_h5s, "Dataspaces", NULL); // testing attribute functionalities in tattr.cpp - AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL); + AddTest("tattr", test_attr, cleanup_attr, "Attributes", NULL); // testing object functionalities in tobject.cpp - AddTest("tobject", test_object, cleanup_object, "Objects", NULL); + AddTest("tobject", test_object, cleanup_object, "Objects", NULL); // testing reference functionalities in trefer.cpp - AddTest("trefer", test_reference, cleanup_reference, "References", NULL); + AddTest("trefer", test_reference, cleanup_reference, "References", NULL); // testing variable-length strings in tvlstr.cpp - AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); - AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL); - AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL); - AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL); - AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL); - AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL); - AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL); -/* Comment out tests that are not done yet. - BMR, Feb 2001 - AddTest("select", test_select, cleanup_select, "Selections", NULL); - AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); - AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); - AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); - AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); - AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); - -Comment out tests that are not done yet */ - -/* Tentative - BMR 2007/1/12 - AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); -*/ + AddTest("tvlstr", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings", NULL); + AddTest("ttypes", test_types, cleanup_types, "Generic Data Types", NULL); + AddTest("tarray", test_array, cleanup_array, "Array Datatypes", NULL); + AddTest("tcompound", test_compound, cleanup_compound, "Compound Data Types", NULL); + AddTest("tdspl", test_dsproplist, cleanup_dsproplist, "Dataset Property List", NULL); + AddTest("tfilter", test_filters, cleanup_filters, "Various Filters", NULL); + AddTest("tlinks", test_links, cleanup_links, "Various Links", NULL); + /* Comment out tests that are not done yet. - BMR, Feb 2001 + AddTest("select", test_select, cleanup_select, "Selections", NULL); + AddTest("time", test_time, cleanup_time, "Time Datatypes", NULL); + AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes", NULL); + AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration", NULL); + AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties", NULL); + AddTest("id", test_ids, NULL, "User-Created Identifiers", NULL); + + Comment out tests that are not done yet */ + + /* Tentative - BMR 2007/1/12 + AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); + */ } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("Tests failed", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -108,7 +107,7 @@ Comment out tests that are not done yet */ TestInfo(argv[0]); /* Parse command line arguments */ - TestParseCmdLine(argc,argv); + TestParseCmdLine(argc, argv); /* Perform requested testing */ PerformTests(); @@ -121,5 +120,8 @@ Comment out tests that are not done yet */ if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP")) TestCleanup(); + /* Release test infrastructure */ + TestShutdown(); + return (GetTestNumErrs()); } diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index d5278d5..31a7aa0 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -30,37 +30,37 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file - -const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0; -const size_t F1_OFFSET_SIZE = sizeof(haddr_t); -const size_t F1_LENGTH_SIZE = sizeof(hsize_t); -const unsigned F1_SYM_LEAF_K = 4; -const unsigned F1_SYM_INTERN_K = 16; -const H5std_string FILE1("tfile1.h5"); - -const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512; -const size_t F2_OFFSET_SIZE = 8; -const size_t F2_LENGTH_SIZE = 8; -const unsigned F2_SYM_LEAF_K = 8; -const unsigned F2_SYM_INTERN_K = 32; -const unsigned F2_ISTORE = 64; -const H5std_string FILE2("tfile2.h5"); - -const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0; -const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE; -const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE; -const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K; -const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K; -const H5std_string FILE3("tfile3.h5"); - -const int KB = 1024; -const H5std_string FILE4("tfile4.h5"); - - +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file + +const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0; +const size_t F1_OFFSET_SIZE = sizeof(haddr_t); +const size_t F1_LENGTH_SIZE = sizeof(hsize_t); +const unsigned F1_SYM_LEAF_K = 4; +const unsigned F1_SYM_INTERN_K = 16; +const H5std_string FILE1("tfile1.h5"); + +const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512; +const size_t F2_OFFSET_SIZE = 8; +const size_t F2_LENGTH_SIZE = 8; +const unsigned F2_SYM_LEAF_K = 8; +const unsigned F2_SYM_INTERN_K = 32; +const unsigned F2_ISTORE = 64; +const H5std_string FILE2("tfile2.h5"); + +const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0; +const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE; +const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE; +const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K; +const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K; +const H5std_string FILE3("tfile3.h5"); + +const int KB = 1024; +const H5std_string FILE4("tfile4.h5"); + /*------------------------------------------------------------------------- * Function: test_file_create * @@ -81,7 +81,8 @@ const H5std_string FILE4("tfile4.h5"); * *------------------------------------------------------------------------- */ -static void test_file_create() +static void +test_file_create() { // Output message about test being performed SUBTEST("File Creation I/O"); @@ -94,21 +95,22 @@ static void test_file_create() remove(FILE1.c_str()); // Setting this to NULL for cleaning up in failure situations - H5File* file1 = NULL; + H5File *file1 = NULL; try { // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_EXCL); + file1 = new H5File(FILE1, H5F_ACC_EXCL); // Try to create the same file with H5F_ACC_TRUNC. This should fail // because file1 is the same file and is currently open. try { - H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E + H5File file2(FILE1, H5F_ACC_TRUNC); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempted to create an existing file."); } - catch (FileIException& E) // catch truncating existing file - {} // do nothing, FAIL expected + catch (FileIException &E) // catch truncating existing file + { + } // do nothing, FAIL expected // Close file1 delete file1; @@ -117,52 +119,56 @@ static void test_file_create() // Try again with H5F_ACC_EXCL. This should fail because the file // already exists from the previous steps. try { - H5File file2(FILE1, H5F_ACC_EXCL); // should throw E + H5File file2(FILE1, H5F_ACC_EXCL); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "File already exists."); } - catch (FileIException& E) // catching creating existing file - {} // do nothing, FAIL expected + catch (FileIException &E) // catching creating existing file + { + } // do nothing, FAIL expected // Test create with H5F_ACC_TRUNC. This will truncate the existing file. - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Try to create first file again. This should fail because file1 // is the same file and is currently open. try { - H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E + H5File file2(FILE1, H5F_ACC_TRUNC); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "H5F_ACC_TRUNC attempt on an opened file."); } - catch (FileIException& E) // catching truncating opened file - {} // do nothing, FAIL expected + catch (FileIException &E) // catching truncating opened file + { + } // do nothing, FAIL expected // Try with H5F_ACC_EXCL. This should fail too because the file already // exists. try { - H5File file3 (FILE1, H5F_ACC_EXCL); // should throw E + H5File file3(FILE1, H5F_ACC_EXCL); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "H5F_ACC_EXCL attempt on an existing file."); } - catch (FileIException& E) // catching H5F_ACC_EXCL on existing file - {} // do nothing, FAIL expected + catch (FileIException &E) // catching H5F_ACC_EXCL on existing file + { + } // do nothing, FAIL expected // Get the file-creation template FileCreatPropList tmpl1 = file1->getCreatePlist(); hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - size_t parm1, parm2; // file-creation parameters - tmpl1.getSizes( parm1, parm2); + size_t parm1, parm2; // file-creation parameters + tmpl1.getSizes(parm1, parm2); verify_val(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters - tmpl1.getSymk( iparm1, iparm2); + unsigned iparm1, iparm2; // file-creation parameters + tmpl1.getSymk(iparm1, iparm2); verify_val(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F1_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -172,85 +178,84 @@ static void test_file_create() // Close first file delete file1; } - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " *FAILED*" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; if (file1 != NULL) // clean up delete file1; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); if (file1 != NULL) // clean up delete file1; } // Setting this to NULL for cleaning up in failure situations - FileCreatPropList* tmpl1 = NULL; - try - { + FileCreatPropList *tmpl1 = NULL; + try { // Create a new file with a non-standard file-creation template tmpl1 = new FileCreatPropList; // Set the new file-creation parameters - tmpl1->setUserblock (F2_USERBLOCK_SIZE); - tmpl1->setSizes( F2_OFFSET_SIZE, F2_LENGTH_SIZE ); - tmpl1->setSymk( F2_SYM_INTERN_K, F2_SYM_LEAF_K ); + tmpl1->setUserblock(F2_USERBLOCK_SIZE); + tmpl1->setSizes(F2_OFFSET_SIZE, F2_LENGTH_SIZE); + tmpl1->setSymk(F2_SYM_INTERN_K, F2_SYM_LEAF_K); // Try to create second file, with non-standard file-creation template // params. - H5File file2( FILE2, H5F_ACC_TRUNC, *tmpl1 ); + H5File file2(FILE2, H5F_ACC_TRUNC, *tmpl1); // Release file-creation template delete tmpl1; tmpl1 = NULL; // Get the file-creation template - tmpl1 = new FileCreatPropList (file2.getCreatePlist()); + tmpl1 = new FileCreatPropList(file2.getCreatePlist()); // Get the file-creation parameters hsize_t ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - size_t parm1, parm2; // file-creation parameters - tmpl1->getSizes( parm1, parm2); + size_t parm1, parm2; // file-creation parameters + tmpl1->getSizes(parm1, parm2); verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters - tmpl1->getSymk( iparm1, iparm2); + unsigned iparm1, iparm2; // file-creation parameters + tmpl1->getSymk(iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); // Clone the file-creation template FileCreatPropList tmpl2; - tmpl2.copy (*tmpl1); + tmpl2.copy(*tmpl1); // Release file-creation template delete tmpl1; tmpl1 = NULL; // Set the new file-creation parameter - tmpl2.setUserblock( F3_USERBLOCK_SIZE ); + tmpl2.setUserblock(F3_USERBLOCK_SIZE); // Try to create second file, with non-standard file-creation template // params - H5File file3( FILE3, H5F_ACC_TRUNC, tmpl2 ); + H5File file3(FILE3, H5F_ACC_TRUNC, tmpl2); // Get the file-creation template - tmpl1 = new FileCreatPropList (file3.getCreatePlist()); + tmpl1 = new FileCreatPropList(file3.getCreatePlist()); // Get the file-creation parameters ublock = tmpl1->getUserblock(); - verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - tmpl1->getSizes( parm1, parm2); + tmpl1->getSizes(parm1, parm2); verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F3_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - tmpl1->getSymk( iparm1, iparm2); + tmpl1->getSymk(iparm1, iparm2); verify_val(iparm1, F3_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F3_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -259,15 +264,13 @@ static void test_file_create() PASSED(); } // catch all exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); - if (tmpl1 != NULL) // clean up + if (tmpl1 != NULL) // clean up delete tmpl1; } -} // test_file_create() +} // test_file_create() - /*------------------------------------------------------------------------- * Function: test_file_open * @@ -288,7 +291,8 @@ static void test_file_create() * *------------------------------------------------------------------------- */ -static void test_file_open() +static void +test_file_open() { // Output message about test being performed SUBTEST("File Opening I/O"); @@ -296,21 +300,22 @@ static void test_file_open() try { // Open first file - H5File file1 (FILE2, H5F_ACC_RDWR ); + H5File file1(FILE2, H5F_ACC_RDWR); // Get the file-creation template FileCreatPropList tmpl1 = file1.getCreatePlist(); // Get the file-creation parameters hsize_t ublock = tmpl1.getUserblock(); - verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); + verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, + __FILE__); - size_t parm1, parm2; // file-creation parameters + size_t parm1, parm2; // file-creation parameters tmpl1.getSizes(parm1, parm2); verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters + unsigned iparm1, iparm2; // file-creation parameters tmpl1.getSymk(iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -322,13 +327,14 @@ static void test_file_open() // Try truncating the file, and it should fail because the file is // still opened with file2. try { - H5File file3 (FILE2, H5F_ACC_TRUNC); // should throw E + H5File file3(FILE2, H5F_ACC_TRUNC); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempt truncating an opened file."); } - catch (FileIException& E) // catching H5F_ACC_TRUNC on opened file - {} // do nothing, FAIL expected + catch (FileIException &E) // catching H5F_ACC_TRUNC on opened file + { + } // do nothing, FAIL expected // Now, really close the file. file2.close(); @@ -345,15 +351,13 @@ static void test_file_open() H5File file4(FILE2, H5F_ACC_TRUNC); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_open()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_file_open() +} // test_file_open() - /*------------------------------------------------------------------------- * Function: test_file_size * @@ -366,7 +370,8 @@ static void test_file_open() * *------------------------------------------------------------------------- */ -static void test_file_size() +static void +test_file_size() { // Output message about test being performed SUBTEST("File Size"); @@ -385,27 +390,28 @@ static void test_file_size() // fapl.setSec2(); // Create a file - H5File file4( FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + H5File file4(FILE4, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Get file size hsize_t file_size = file4.getFileSize(); // Check if file size is reasonable. It's supposed to be 2KB now. - if (file_size < 1*KB || file_size > 4*KB) - issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFileSize() returned unreasonable value"); + if (file_size < 1 * KB || file_size > 4 * KB) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, + "getFileSize() returned unreasonable value"); // Get the amount of free space in the file hssize_t free_space = file4.getFreeSpace(); // Check if it's reasonable. It's 0 now. - if (free_space < 0 || free_space > 4*KB) - issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFreeSpace returned unreasonable value"); + if (free_space < 0 || free_space > 4 * KB) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, + "getFreeSpace returned unreasonable value"); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_size()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -414,9 +420,8 @@ static void test_file_size() if (ret < 0) issue_fail_msg("test_file_size()", __LINE__, __FILE__, "H5Pclose failed"); -} // test_file_size() +} // test_file_size() - /*------------------------------------------------------------------------- * Function: test_file_name * @@ -429,14 +434,14 @@ static void test_file_size() * *------------------------------------------------------------------------- */ -const int RANK = 2; -const int NX = 4; -const int NY = 5; -const H5std_string GROUPNAME ("group"); -const H5std_string DSETNAME ("dataset"); -const H5std_string DATTRNAME ("dataset attribute"); -const H5std_string FATTRNAME ("file attribute"); -const H5std_string DTYPENAME ("compound"); +const int RANK = 2; +const int NX = 4; +const int NY = 5; +const H5std_string GROUPNAME("group"); +const H5std_string DSETNAME("dataset"); +const H5std_string DATTRNAME("dataset attribute"); +const H5std_string FATTRNAME("file attribute"); +const H5std_string DTYPENAME("compound"); // Compound datatype typedef struct s1_t { @@ -444,7 +449,8 @@ typedef struct s1_t { float b; } s1_t; -static void test_file_name() +static void +test_file_name() { // Output message about test being performed. SUBTEST("File Name"); @@ -466,11 +472,11 @@ static void test_file_name() verify_val(file_name, FILE4, "Group::getFileName", __LINE__, __FILE__); // Create the data space. - hsize_t dims[RANK] = {NX, NY}; + hsize_t dims[RANK] = {NX, NY}; DataSpace space(RANK, dims); // Create a new dataset. - DataSet dataset(file4.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + DataSet dataset(file4.createDataSet(DSETNAME, PredType::NATIVE_INT, space)); // Get and verify file name via a dataset. file_name = dataset.getFileName(); @@ -484,7 +490,7 @@ static void test_file_name() verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); // Create a compound datatype. - CompType comp_type (sizeof(s1_t)); + CompType comp_type(sizeof(s1_t)); // Insert fields. comp_type.insertMember("a", HOFFSET(s1_t, a), PredType::NATIVE_INT); @@ -503,15 +509,13 @@ static void test_file_name() verify_val(finfo.sohm.hdr_size, 0, "H5File::getFileInfo", __LINE__, __FILE__); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_file_name() +} // test_file_name() - /*------------------------------------------------------------------------- * * Function: test_file_attribute @@ -521,15 +525,16 @@ static void test_file_name() * Return None *------------------------------------------------------------------------- */ -const int RANK1 = 1; -const int ATTR1_DIM1 = 3; -const H5std_string FILE5("tfattrs.h5"); -const H5std_string FATTR1_NAME ("file attribute 1"); -const H5std_string FATTR2_NAME ("file attribute 2"); -int fattr_data[ATTR1_DIM1]={512,-234,98123}; // Test data for file attribute -int dattr_data[ATTR1_DIM1]={256,-123,1000}; // Test data for dataset attribute - -static void test_file_attribute() +const int RANK1 = 1; +const int ATTR1_DIM1 = 3; +const H5std_string FILE5("tfattrs.h5"); +const H5std_string FATTR1_NAME("file attribute 1"); +const H5std_string FATTR2_NAME("file attribute 2"); +int fattr_data[ATTR1_DIM1] = {512, -234, 98123}; // Test data for file attribute +int dattr_data[ATTR1_DIM1] = {256, -123, 1000}; // Test data for dataset attribute + +static void +test_file_attribute() { int rdata[ATTR1_DIM1]; int i; @@ -543,7 +548,7 @@ static void test_file_attribute() H5File file5(FILE5, H5F_ACC_TRUNC); // Create the data space - hsize_t dims[RANK1] = {ATTR1_DIM1}; + hsize_t dims[RANK1] = {ATTR1_DIM1}; DataSpace space(RANK1, dims); // Create two attributes for the file @@ -556,13 +561,15 @@ static void test_file_attribute() // Try to create the same attribute again (should fail) Attribute fattr_dup(file5.createAttribute(FATTR2_NAME, PredType::NATIVE_INT, space)); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File createAttribute", "Attempted to create an existing attribute."); + throw InvalidActionException("H5File createAttribute", + "Attempted to create an existing attribute."); } - catch (AttributeIException& E) // catch creating existing attribute - {} // do nothing, FAIL expected + catch (AttributeIException &E) // catch creating existing attribute + { + } // do nothing, FAIL expected // Create a new dataset - DataSet dataset(file5.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + DataSet dataset(file5.createDataSet(DSETNAME, PredType::NATIVE_INT, space)); // Create an attribute for the dataset Attribute dattr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); @@ -588,7 +595,7 @@ static void test_file_attribute() verify_val(num_objs, 0, "H5File::getObjCount(H5F_OBJ_DATATYPE)", __LINE__, __FILE__); num_objs = file5.getObjCount(H5F_OBJ_FILE); verify_val(num_objs, 1, "H5File::getObjCount(H5F_OBJ_FILE)", __LINE__, __FILE__); - + // Get the file name using the attributes H5std_string fname = fattr1.getFileName(); verify_val(fname, FILE5, "H5File::getFileName()", __LINE__, __FILE__); @@ -630,29 +637,27 @@ static void test_file_attribute() if (rdata[i] != dattr_data[i]) { H5_FAILED(); cerr << endl; - cerr << "element [" << i << "] is " << rdata[i] << - "but should have been " << dattr_data[i] << endl; - } + cerr << "element [" << i << "] is " << rdata[i] << "but should have been " << dattr_data[i] + << endl; } + } PASSED(); - } // end of try block + } // end of try block // Catch creating existing attribute - catch (AttributeIException& E) - {} // do nothing, exception expected + catch (AttributeIException &E) { + } // do nothing, exception expected // Catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_file_attribute() +} // test_file_attribute() - -const H5std_string FILE6("tfile5.h5"); -const H5std_string ROOTGROUP("/"); -const H5std_string GROUP1("/G1"); -const H5std_string SUBGROUP3("/G1/G3"); +const H5std_string FILE6("tfile5.h5"); +const H5std_string ROOTGROUP("/"); +const H5std_string GROUP1("/G1"); +const H5std_string SUBGROUP3("/G1/G3"); /*------------------------------------------------------------------------- * Function: test_libver_bounds_real @@ -668,71 +673,70 @@ const H5std_string SUBGROUP3("/G1/G3"); * *------------------------------------------------------------------------- */ -static void test_libver_bounds_real( - H5F_libver_t libver_create, unsigned oh_vers_create, - H5F_libver_t libver_mod, unsigned oh_vers_mod) +static void +test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, H5F_libver_t libver_mod, + unsigned oh_vers_mod) { try { - /* - * Create a new file using the default creation property and access property - * with latest library version. - */ - FileAccPropList fapl; - fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST); - H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + /* + * Create a new file using the default creation property and access property + * with latest library version. + */ + FileAccPropList fapl; + fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST); + H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); - /* - * Make sure the root group has the correct object header version - */ - unsigned obj_version = file.childObjVersion(ROOTGROUP); - verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + /* + * Make sure the root group has the correct object header version + */ + unsigned obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - /* - * Reopen the file and make sure the root group still has the correct version - */ - file.close(); + /* + * Reopen the file and make sure the root group still has the correct version + */ + file.close(); - fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST); + fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST); - file.openFile(FILE6, H5F_ACC_RDWR, fapl); + file.openFile(FILE6, H5F_ACC_RDWR, fapl); - obj_version = file.childObjVersion(ROOTGROUP); - verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - /* - * Create a group named "/G1" in the file, and make sure it has the correct - * object header version - */ - Group group = file.createGroup(GROUP1); + /* + * Create a group named "/G1" in the file, and make sure it has the correct + * object header version + */ + Group group = file.createGroup(GROUP1); - obj_version = group.objVersion(); - verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); + obj_version = group.objVersion(); + verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); - group.close(); // close "/G1" + group.close(); // close "/G1" - /* - * Create a group named "/G1/G3" in the file, and make sure it has the - * correct object header version - */ - group = file.createGroup(SUBGROUP3); + /* + * Create a group named "/G1/G3" in the file, and make sure it has the + * correct object header version + */ + group = file.createGroup(SUBGROUP3); - obj_version = group.objVersion(); - verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); + obj_version = group.objVersion(); + verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); - group.close(); // close "/G1/G3" + group.close(); // close "/G1/G3" - /* - * Make sure the root group still has the correct object header version - */ - obj_version = file.childObjVersion(ROOTGROUP); - verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + /* + * Make sure the root group still has the correct object header version + */ + obj_version = file.childObjVersion(ROOTGROUP); + verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); - // Everything should be closed as they go out of scope - } // end of try block + // Everything should be closed as they go out of scope + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_libver_bounds_real()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -752,7 +756,8 @@ static void test_libver_bounds_real( * *------------------------------------------------------------------------- */ -static void test_libver_bounds() +static void +test_libver_bounds() { // Output message about test being performed SUBTEST("Setting library version bounds"); @@ -763,7 +768,6 @@ static void test_libver_bounds() PASSED(); } /* end test_libver_bounds() */ - /*------------------------------------------------------------------------- * Function: test_commonfg * @@ -776,7 +780,8 @@ static void test_libver_bounds() * *------------------------------------------------------------------------- */ -static void test_commonfg() +static void +test_commonfg() { // Output message about test being performed SUBTEST("Root group"); @@ -792,11 +797,11 @@ static void test_commonfg() Group group(rootgroup.createGroup(GROUPNAME, 0)); // Create the data space. - hsize_t dims[RANK] = {NX, NY}; + hsize_t dims[RANK] = {NX, NY}; DataSpace space(RANK, dims); // Create a new dataset. - DataSet dataset(group.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); + DataSet dataset(group.createDataSet(DSETNAME, PredType::NATIVE_INT, space)); // Get and verify file name via a dataset. H5std_string file_name = dataset.getFileName(); @@ -817,17 +822,15 @@ static void test_commonfg() verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); PASSED(); - } // end of try block + } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_commonfg()", __LINE__, __FILE__, E.getCDetailMsg()); } } /* end test_commonfg() */ - -const H5std_string FILE7("tfile7.h5"); +const H5std_string FILE7("tfile7.h5"); /*------------------------------------------------------------------------- * Function: test_file_info @@ -844,15 +847,13 @@ const H5std_string FILE7("tfile7.h5"); *------------------------------------------------------------------------- */ const hsize_t FSP_SIZE_DEF = 4096; -const hsize_t FSP_SIZE512 = 512; -static void test_file_info() +const hsize_t FSP_SIZE512 = 512; +static void +test_file_info() { // Output message about test being performed SUBTEST("File general information"); - hsize_t out_threshold = 0; // Free space section threshold to get - hbool_t out_persist = FALSE;// Persist free-space read - try { // Create a file using default properties. H5File tempfile(FILE7, H5F_ACC_TRUNC); @@ -883,7 +884,7 @@ static void test_file_info() fcpl.close(); // Get the file's version information. - file7.getFileInfo(finfo); // there's no C test for H5Fget_info + file7.getFileInfo(finfo); // there's no C test for H5Fget_info // Close the file. file7.close(); @@ -895,7 +896,7 @@ static void test_file_info() FileCreatPropList fcpl2 = file7.getCreatePlist(); // Get the file's version information. - file7.getFileInfo(finfo); // there's no C test for H5Fget_info + file7.getFileInfo(finfo); // there's no C test for H5Fget_info // Retrieve the property values & check them. hsize_t userblock = fcpl2.getUserblock(); @@ -915,14 +916,12 @@ static void test_file_info() verify_val(istore_ik, F2_ISTORE, "FileCreatPropList::getIstorek", __LINE__, __FILE__); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_filespace_info()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_file_info() */ +} /* test_file_info() */ - /*------------------------------------------------------------------------- * Function: test_file * @@ -935,23 +934,22 @@ static void test_file_info() * *------------------------------------------------------------------------- */ -extern "C" -void test_file() +extern "C" void +test_file() { // Output message about test being performed MESSAGE(5, ("Testing File I/O Operations\n")); - test_file_create(); // Test file creation (also creation templates) - test_file_open(); // Test file opening - test_file_size(); // Test file size - test_file_name(); // Test getting file's name - test_file_attribute(); // Test file attribute feature - test_libver_bounds(); // Test format version - test_commonfg(); // Test H5File as a root group - test_file_info(); // Test various file info -} // test_file() - - + test_file_create(); // Test file creation (also creation templates) + test_file_open(); // Test file opening + test_file_size(); // Test file size + test_file_name(); // Test getting file's name + test_file_attribute(); // Test file attribute feature + test_libver_bounds(); // Test format version + test_commonfg(); // Test H5File as a root group + test_file_info(); // Test various file info +} // test_file() + /*------------------------------------------------------------------------- * Function: cleanup_file * @@ -966,7 +964,8 @@ void test_file() #ifdef __cplusplus extern "C" #endif -void cleanup_file() + void + cleanup_file() { HDremove(FILE1.c_str()); HDremove(FILE2.c_str()); @@ -975,4 +974,4 @@ void cleanup_file() HDremove(FILE5.c_str()); HDremove(FILE6.c_str()); HDremove(FILE7.c_str()); -} // cleanup_file +} // cleanup_file diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index 2e3c07c..52ebfec 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,14 +25,15 @@ #include <string> #ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#endif // H5_NO_STD -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file #define DSET_DIM1 100 #define DSET_DIM2 200 @@ -59,13 +60,13 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, static size_t filter_bogus(size_t nbytes); /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_BOGUS, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "bogus", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)filter_bogus, /* The actual filter function */ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)filter_bogus, /* The actual filter function */ }}; /*------------------------------------------------------------------------- @@ -112,25 +113,26 @@ filter_bogus(size_t nbytes) // Chunk dimensions const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; -static void test_null_filter() +static void +test_null_filter() { // Output message about test being performed SUBTEST("'Null' filter"); try { - //hsize_t null_size; // Size of dataset with null filter + // hsize_t null_size; // Size of dataset with null filter // Prepare dataset create property list DSetCreatPropList dsplist; dsplist.setChunk(2, chunk_size); - if (H5Zregister (H5Z_BOGUS)<0) + if (H5Zregister(H5Z_BOGUS) < 0) throw Exception("test_null_filter", "H5Zregister failed"); // Set some pretent filter dsplist.setFilter(H5Z_FILTER_BOGUS); // this function is just a stub right now; will work on it later - BMR - //if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0) + // if(test_filter_internal(file,DSET_BOGUS_NAME,dc,DISABLE_FLETCHER32,DATA_NOT_CORRUPTED,&null_size)<0) // throw Exception("test_null_filter", "test_filter_internal failed"); // Close objects. @@ -139,11 +141,10 @@ static void test_null_filter() } // end of try // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_null_filter()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_null_filter +} // test_null_filter /*------------------------------------------------------------------------- * Function: test_szip_filter @@ -161,30 +162,31 @@ static void test_null_filter() *------------------------------------------------------------------------- */ -const H5std_string DSET_SZIP_NAME("szipped dataset"); +const H5std_string DSET_SZIP_NAME("szipped dataset"); -static void test_szip_filter(H5File& file1) +static void +test_szip_filter(H5File &file1) { #ifdef H5_HAVE_FILTER_SZIP int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2]; - unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block=4; + unsigned szip_options_mask = H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block = 4; // Output message about test being performed SUBTEST("szip filter (with encoder)"); - if ( h5_szip_can_encode() == 1) { - char* tconv_buf = new char [1000]; + if (h5_szip_can_encode() == 1) { + char *tconv_buf = new char[1000]; try { - const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; + const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; // Create the data space DataSpace space1(2, size, NULL); // Create a small conversion buffer to test strip mining (?) DSetMemXferPropList xfer; - xfer.setBuffer (1000, tconv_buf, NULL); + xfer.setBuffer(1000, tconv_buf, NULL); // Prepare dataset create property list DSetCreatPropList dsplist; @@ -194,27 +196,24 @@ static void test_szip_filter(H5File& file1) dsplist.setSzip(szip_options_mask, szip_pixels_per_block); // Create a dataset with szip compression - DataSpace space2 (2, size, NULL); - DataSet dataset(file1.createDataSet (DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist)); + DataSpace space2(2, size, NULL); + DataSet dataset(file1.createDataSet(DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist)); hsize_t i, j, n; - for (i=n=0; i<size[0]; i++) - { - for (j=0; j<size[1]; j++) - { + for (i = n = 0; i < size[0]; i++) { + for (j = 0; j < size[1]; j++) { points[i][j] = (int)n++; } } // Write to the dataset then read back the values - dataset.write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset.read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.write((void *)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.read((void *)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) - for (j = 0; j < size[1]; j++) - { - int status = check_values (i, j, points[i][j], check[i][j]); + for (j = 0; j < size[1]; j++) { + int status = check_values(i, j, points[i][j], check[i][j]); if (status == -1) throw Exception("test_szip_filter", "Failed in testing szip method"); } @@ -223,8 +222,7 @@ static void test_szip_filter(H5File& file1) } // end of try // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -234,32 +232,30 @@ static void test_szip_filter(H5File& file1) SKIPPED(); } -#else /* H5_HAVE_FILTER_SZIP */ +#else /* H5_HAVE_FILTER_SZIP */ SUBTEST("szip filter"); SKIPPED(); H5std_string fname = file1.getFileName(); cerr << " Szip filter not enabled for file '" << fname << "'" << endl; #endif /* H5_HAVE_FILTER_SZIP */ -} // test_szip_filter +} // test_szip_filter - /**************************************************************** ** ** test_filters(): Main routine for testing filters. ** ****************************************************************/ -const H5std_string FILE1("tfilters.h5"); -extern "C" -void test_filters() +const H5std_string FILE1("tfilters.h5"); +extern "C" void +test_filters() { // Output message about test being performed MESSAGE(5, ("Testing Various Filters\n")); - hid_t fapl_id; + hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template - try - { + try { // Use the file access template id to create a file access prop. list FileAccPropList fapl(fapl_id); @@ -269,11 +265,10 @@ void test_filters() test_null_filter(); test_szip_filter(file1); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_filters()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_filters() +} // test_filters() /*------------------------------------------------------------------------- * Function: cleanup_filters @@ -287,8 +282,8 @@ void test_filters() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_filters() +extern "C" void +cleanup_filters() { HDremove(FILE1.c_str()); } diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index 18cd460..fc8320c 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,42 +28,43 @@ #include <string> #ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#endif // H5_NO_STD -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file -#include "H5srcdir.h" // srcdir querying header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file +#include "H5srcdir.h" // srcdir querying header file -const H5std_string TESTFILE("th5s.h5"); -const H5std_string DATAFILE("th5s1.h5"); +const H5std_string TESTFILE("th5s.h5"); +const H5std_string DATAFILE("th5s1.h5"); /* 3-D dataset with fixed dimensions */ const H5std_string SPACE1_NAME("Space1"); -const int SPACE1_RANK = 3; -const int SPACE1_DIM1 = 3; -const int SPACE1_DIM2 = 15; -const int SPACE1_DIM3 = 13; +const int SPACE1_RANK = 3; +const int SPACE1_DIM1 = 3; +const int SPACE1_DIM2 = 15; +const int SPACE1_DIM3 = 13; /* 4-D dataset with one unlimited dimension */ const H5std_string SPACE2_NAME("Space2"); -const int SPACE2_RANK = 4; -const int SPACE2_DIM1 = 0; -const int SPACE2_DIM2 = 15; -const int SPACE2_DIM3 = 13; -const int SPACE2_DIM4 = 23; -const hsize_t SPACE2_MAX1 = H5S_UNLIMITED; -const hsize_t SPACE2_MAX2 = 15; -const hsize_t SPACE2_MAX3 = 13; -const hsize_t SPACE2_MAX4 = 23; +const int SPACE2_RANK = 4; +const int SPACE2_DIM1 = 0; +const int SPACE2_DIM2 = 15; +const int SPACE2_DIM3 = 13; +const int SPACE2_DIM4 = 23; +const hsize_t SPACE2_MAX1 = H5S_UNLIMITED; +const hsize_t SPACE2_MAX2 = 15; +const hsize_t SPACE2_MAX3 = 13; +const hsize_t SPACE2_MAX4 = 23; /* Scalar dataset with simple datatype */ const H5std_string SPACE3_NAME("Scalar1"); -const int SPACE3_RANK = 0; -unsigned space3_data=65; +const int SPACE3_RANK = 0; +unsigned space3_data = 65; /* Scalar dataset with compound datatype */ const H5std_string SPACE4_NAME("Scalar2"); @@ -71,16 +72,16 @@ const H5std_string SPACE4_FIELDNAME1("c1"); const H5std_string SPACE4_FIELDNAME2("u"); const H5std_string SPACE4_FIELDNAME3("f"); const H5std_string SPACE4_FIELDNAME4("c2"); -size_t space4_field1_off=0; -size_t space4_field2_off=0; -size_t space4_field3_off=0; -size_t space4_field4_off=0; +size_t space4_field1_off = 0; +size_t space4_field2_off = 0; +size_t space4_field3_off = 0; +size_t space4_field4_off = 0; struct space4_struct { - char c1; + char c1; unsigned u; - float f; - char c2; - } space4_data={'v',987123,(float)-3.14,'g'}; /* Test data for 4th dataspace */ + float f; + char c2; +} space4_data = {'v', 987123, (float)-3.14, 'g'}; /* Test data for 4th dataspace */ /* Null dataspace */ int space5_data = 7; @@ -108,48 +109,48 @@ int space5_data = 7; * size to be zero. So I took out the test against it. *------------------------------------------------------------------------- */ -static void test_h5s_basic() +static void +test_h5s_basic() { - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, - SPACE2_DIM4}; - hsize_t dims3[H5S_MAX_RANK+1]; - hsize_t tmax[4]; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}; + hsize_t dims3[H5S_MAX_RANK + 1]; + hsize_t tmax[4]; // Output message about test being performed SUBTEST("Dataspace Manipulation"); try { // Create simple dataspace sid1 - DataSpace sid1 (SPACE1_RANK, dims1 ); + DataSpace sid1(SPACE1_RANK, dims1); // Get simple extent npoints of the dataspace sid1 and verify it - hssize_t n; // Number of dataspace elements + hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); verify_val((long)n, (long)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3), - "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of dataspace sid1 and verify it - int rank; // Logical rank of dataspace + int rank; // Logical rank of dataspace rank = sid1.getSimpleExtentNdims(); verify_val(rank, SPACE1_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Retrieves dimension size of dataspace sid1 and verify it - int ndims; // Number of dimensions - hsize_t tdims[4]; // Dimension array to test with - ndims = sid1.getSimpleExtentDims( tdims ); + int ndims; // Number of dimensions + hsize_t tdims[4]; // Dimension array to test with + ndims = sid1.getSimpleExtentDims(tdims); verify_val(ndims, SPACE1_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); verify_val(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Create simple dataspace sid2 - hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4}; - DataSpace sid2 (SPACE2_RANK, dims2, max2); + hsize_t max2[] = {SPACE2_MAX1, SPACE2_MAX2, SPACE2_MAX3, SPACE2_MAX4}; + DataSpace sid2(SPACE2_RANK, dims2, max2); // Get simple extent npoints of dataspace sid2 and verify it n = sid2.getSimpleExtentNpoints(); verify_val((long)n, (long)(SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4), - "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); + "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Get the logical rank of dataspace sid2 and verify it rank = sid2.getSimpleExtentNdims(); @@ -157,34 +158,36 @@ static void test_h5s_basic() // Retrieves dimension size and max size of dataspace sid2 and // verify them - ndims = sid2.getSimpleExtentDims( tdims, tmax ); + ndims = sid2.getSimpleExtentDims(tdims, tmax); verify_val(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); - verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0, - "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); + verify_val(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0, "DataSpace::getSimpleExtentDims", + __LINE__, __FILE__); // Check to be sure we can't create a simple data space that has too // many dimensions. try { - DataSpace manydims_ds(H5S_MAX_RANK+1, dims3, NULL); + DataSpace manydims_ds(H5S_MAX_RANK + 1, dims3, NULL); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("DataSpace constructor", "Library allowed overwrite of existing dataset"); + throw InvalidActionException("DataSpace constructor", + "Library allowed overwrite of existing dataset"); } - catch (DataSpaceIException& E) // Simple data space with too many dims - {} // do nothing, exception expected - - /* - * Try reading a file that has been prepared that has a dataset with a - * higher dimensionality than what the library can handle. - * - * If this test fails and the H5S_MAX_RANK variable has changed, follow - * the instructions in space_overflow.c for regenating the th5s.h5 file. - */ - char *tmp_str = new char[TESTFILE.length()+1]; + catch (DataSpaceIException &E) // Simple data space with too many dims + { + } // do nothing, exception expected + + /* + * Try reading a file that has been prepared that has a dataset with a + * higher dimensionality than what the library can handle. + * + * If this test fails and the H5S_MAX_RANK variable has changed, follow + * the instructions in space_overflow.c for regenating the th5s.h5 file. + */ + char *tmp_str = new char[TESTFILE.length() + 1]; strcpy(tmp_str, TESTFILE.c_str()); const char *testfile = H5_get_srcdir_filename(tmp_str); - delete []tmp_str; + delete[] tmp_str; // Create file H5File fid1(testfile, H5F_ACC_RDONLY); @@ -192,31 +195,32 @@ static void test_h5s_basic() // Try to open the dataset that has higher dimensionality than // what the library can handle and this operation should fail. try { - DataSet dset1 = fid1.openDataSet( "dset" ); + DataSet dset1 = fid1.openDataSet("dset"); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5File::openDataSet", "Opening a dataset with higher dimensionality than what the library can handle"); + throw InvalidActionException( + "H5File::openDataSet", + "Opening a dataset with higher dimensionality than what the library can handle"); } - catch (FileIException& E) // catching higher dimensionality dataset - {} // do nothing, exception expected + catch (FileIException &E) // catching higher dimensionality dataset + { + } // do nothing, exception expected - // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure - // in the p_close see how this will handle it. - BMR + // CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure + // in the p_close see how this will handle it. - BMR PASSED(); - } // end of try block + } // end of try block - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_h5s_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_basic() +} // test_h5s_basic() /*------------------------------------------------------------------------- * @@ -238,7 +242,8 @@ static void test_h5s_basic() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_scalar_write() +static void +test_h5s_scalar_write() { // Output message about test being performed SUBTEST("Scalar Dataspace Writing"); @@ -250,37 +255,36 @@ static void test_h5s_scalar_write() // Create scalar dataspace DataSpace sid1(SPACE3_RANK, NULL); - //n = H5Sget_simple_extent_npoints(sid1); - hssize_t n; // Number of dataspace elements + // n = H5Sget_simple_extent_npoints(sid1); + hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); - int rank; // Logical rank of dataspace + int rank; // Logical rank of dataspace rank = sid1.getSimpleExtentNdims(); verify_val(rank, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); // Retrieves dimension size of dataspace sid1 and verify it - int ndims; // Number of dimensions - hsize_t tdims[4]; // Dimension array to test with - ndims = sid1.getSimpleExtentDims( tdims ); + int ndims; // Number of dimensions + hsize_t tdims[4]; // Dimension array to test with + ndims = sid1.getSimpleExtentDims(tdims); verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Verify extent type - H5S_class_t ext_type; // Extent type + H5S_class_t ext_type; // Extent type ext_type = sid1.getSimpleExtentType(); verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__); // Create and write a dataset - DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); + DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1); dataset.write(&space3_data, PredType::NATIVE_UINT); PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_h5s_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_scalar_write() +} // test_h5s_scalar_write() /*------------------------------------------------------------------------- * @@ -302,9 +306,10 @@ static void test_h5s_scalar_write() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_scalar_read() +static void +test_h5s_scalar_read() { - hsize_t tdims[4]; // Dimension array to test with + hsize_t tdims[4]; // Dimension array to test with // Output message about test being performed SUBTEST("Scalar Dataspace Reading"); @@ -330,19 +335,18 @@ static void test_h5s_scalar_read() verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); // Read data back and verify it - unsigned rdata; // Scalar data read in + unsigned rdata; // Scalar data read in dataset.read(&rdata, PredType::NATIVE_UINT); verify_val(rdata, space3_data, "DataSet::read", __LINE__, __FILE__); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_scalar_read() +} // test_h5s_scalar_read() /*------------------------------------------------------------------------- * @@ -364,7 +368,8 @@ static void test_h5s_scalar_read() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_null() +static void +test_h5s_null() { // Output message about test being performed SUBTEST("Null Dataspace Writing"); @@ -376,12 +381,12 @@ static void test_h5s_null() // Create scalar dataspace DataSpace sid1(H5S_NULL); - hssize_t n; // Number of dataspace elements + hssize_t n; // Number of dataspace elements n = sid1.getSimpleExtentNpoints(); verify_val((long)n, 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Create a dataset - DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT,sid1); + DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1); // Try to write nothing to the dataset dataset.write(&space5_data, PredType::NATIVE_INT); @@ -392,11 +397,10 @@ static void test_h5s_null() PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_h5s_null()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_null() +} // test_h5s_null() /*------------------------------------------------------------------------- * @@ -419,7 +423,8 @@ static void test_h5s_null() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_compound_scalar_write() +static void +test_h5s_compound_scalar_write() { // Output message about test being performed SUBTEST("Compound Dataspace Writing"); @@ -430,18 +435,14 @@ static void test_h5s_compound_scalar_write() // Create the compound datatype. CompType tid1(sizeof(struct space4_struct)); - space4_field1_off=HOFFSET(struct space4_struct, c1); - tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off, - PredType::NATIVE_SCHAR); - space4_field2_off=HOFFSET(struct space4_struct, u); - tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off, - PredType::NATIVE_UINT); - space4_field3_off=HOFFSET(struct space4_struct, f); - tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off, - PredType::NATIVE_FLOAT); - space4_field4_off=HOFFSET(struct space4_struct, c2); - tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off, - PredType::NATIVE_SCHAR); + space4_field1_off = HOFFSET(struct space4_struct, c1); + tid1.insertMember(SPACE4_FIELDNAME1, space4_field1_off, PredType::NATIVE_SCHAR); + space4_field2_off = HOFFSET(struct space4_struct, u); + tid1.insertMember(SPACE4_FIELDNAME2, space4_field2_off, PredType::NATIVE_UINT); + space4_field3_off = HOFFSET(struct space4_struct, f); + tid1.insertMember(SPACE4_FIELDNAME3, space4_field3_off, PredType::NATIVE_FLOAT); + space4_field4_off = HOFFSET(struct space4_struct, c2); + tid1.insertMember(SPACE4_FIELDNAME4, space4_field4_off, PredType::NATIVE_SCHAR); // Create scalar dataspace DataSpace sid1(SPACE3_RANK, NULL); @@ -454,7 +455,7 @@ static void test_h5s_compound_scalar_write() int ndims = sid1.getSimpleExtentNdims(); verify_val(ndims, SPACE3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__); - hsize_t tdims[4]; // Dimension array to test with + hsize_t tdims[4]; // Dimension array to test with ndims = sid1.getSimpleExtentDims(tdims); verify_val(ndims, 0, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__); @@ -463,13 +464,12 @@ static void test_h5s_compound_scalar_write() dataset.write(&space4_data, tid1); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_compound_scalar_write() +} // test_h5s_compound_scalar_write() /*------------------------------------------------------------------------- * @@ -492,9 +492,10 @@ static void test_h5s_compound_scalar_write() * with a special routine. *------------------------------------------------------------------------- */ -static void test_h5s_compound_scalar_read() +static void +test_h5s_compound_scalar_read() { - hsize_t tdims[4]; // Dimension array to test with + hsize_t tdims[4]; // Dimension array to test with // Output message about test being performed SUBTEST("Compound Dataspace Reading"); @@ -521,29 +522,27 @@ static void test_h5s_compound_scalar_read() // Get the datatype of this dataset. CompType type(dataset); - struct space4_struct rdata; // Scalar data read in + struct space4_struct rdata; // Scalar data read in dataset.read(&rdata, type); // Verify read data - if(HDmemcmp(&space4_data,&rdata,sizeof(struct space4_struct))) - { - cerr << "scalar data different: space4_data.c1=" - << space4_data.c1 << ", read_data4.c1=" << rdata.c1 << endl; - cerr << "scalar data different: space4_data.u=" - << space4_data.u << ", read_data4.u=" << rdata.u << endl; - cerr << "scalar data different: space4_data.f=" - << space4_data.f << ", read_data4.f=" << rdata.f << endl; - TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", - space4_data.c1, rdata.c2); + if (HDmemcmp(&space4_data, &rdata, sizeof(struct space4_struct))) { + cerr << "scalar data different: space4_data.c1=" << space4_data.c1 + << ", read_data4.c1=" << rdata.c1 << endl; + cerr << "scalar data different: space4_data.u=" << space4_data.u << ", read_data4.u=" << rdata.u + << endl; + cerr << "scalar data different: space4_data.f=" << space4_data.f << ", read_data4.f=" << rdata.f + << endl; + TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", space4_data.c1, + rdata.c2); } // end if PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_h5s_compound_scalar_read() +} // test_h5s_compound_scalar_read() /*------------------------------------------------------------------------- * @@ -558,21 +557,20 @@ static void test_h5s_compound_scalar_read() * *------------------------------------------------------------------------- */ -extern "C" -void test_h5s() +extern "C" void +test_h5s() { // Output message about test being performed MESSAGE(5, ("Testing Dataspaces\n")); - test_h5s_basic(); // Test basic H5S code - test_h5s_scalar_write(); // Test scalar H5S writing code - test_h5s_scalar_read(); // Test scalar H5S reading code - test_h5s_null(); // Test null H5S code - test_h5s_compound_scalar_write(); // Test compound datatype scalar H5S writing code - test_h5s_compound_scalar_read(); // Test compound datatype scalar H5S reading code -} // test_h5s() + test_h5s_basic(); // Test basic H5S code + test_h5s_scalar_write(); // Test scalar H5S writing code + test_h5s_scalar_read(); // Test scalar H5S reading code + test_h5s_null(); // Test null H5S code + test_h5s_compound_scalar_write(); // Test compound datatype scalar H5S writing code + test_h5s_compound_scalar_read(); // Test compound datatype scalar H5S reading code +} // test_h5s() - /*------------------------------------------------------------------------- * Function: cleanup_h5s * @@ -585,9 +583,8 @@ void test_h5s() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_h5s() +extern "C" void +cleanup_h5s() { HDremove(DATAFILE.c_str()); -} // cleanup_h5s - +} // cleanup_h5s diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index ae0d53a..97f1174 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -5,7 +5,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,10 +26,10 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ test utilility header file +#include "h5cpputil.h" // C++ test utilility header file // A lot of the definition inherited from C test links.c is left here until // the H5L API is implemented and tests are completed - BMR 10/19/2009 @@ -46,7 +46,7 @@ using namespace H5; //#include "H5Lprivate.h" // Links /* File for external link test. Created with gen_udlinks.c */ -#define LINKED_FILE "be_extlink2.h5" +#define LINKED_FILE "be_extlink2.h5" #if 0 const char *FILENAME[] = { @@ -100,31 +100,31 @@ const char *FILENAME[] = { #endif // 0 -#define TMPDIR "tmp" +#define TMPDIR "tmp" -#define FAMILY_SIZE 1024 -#define CORE_INCREMENT 1024 -#define NUM400 400 +#define FAMILY_SIZE 1024 +#define CORE_INCREMENT 1024 +#define NUM400 400 /* do not do check_all_closed() for "ext*" files and "tmp/ext*" */ -#define EXTSTOP 12 +#define EXTSTOP 12 -#define LINK_BUF_SIZE 1024 -#define NAME_BUF_SIZE 1024 -#define MAX_NAME_LEN ((64*1024)+1024) +#define LINK_BUF_SIZE 1024 +#define NAME_BUF_SIZE 1024 +#define MAX_NAME_LEN ((64 * 1024) + 1024) /* Link type IDs */ -#define UD_HARD_TYPE 201 -#define UD_CB_TYPE H5L_TYPE_MAX -#define UD_PLIST_TYPE 128 -#define UD_CBFAIL_TYPE UD_PLIST_TYPE -#define UD_ERROR_TYPE 189 -#define UD_BAD_TYPE1 H5L_TYPE_HARD -#define UD_BAD_TYPE2 (H5L_TYPE_UD_MIN - 5) -#define UD_BAD_VERS (H5L_LINK_CLASS_T_VERS + 1) - -#define DEST_PROP_NAME "destination_group" -#define REREG_TARGET_NAME "rereg_target" +#define UD_HARD_TYPE 201 +#define UD_CB_TYPE H5L_TYPE_MAX +#define UD_PLIST_TYPE 128 +#define UD_CBFAIL_TYPE UD_PLIST_TYPE +#define UD_ERROR_TYPE 189 +#define UD_BAD_TYPE1 H5L_TYPE_HARD +#define UD_BAD_TYPE2 (H5L_TYPE_UD_MIN - 5) +#define UD_BAD_VERS (H5L_LINK_CLASS_T_VERS + 1) + +#define DEST_PROP_NAME "destination_group" +#define REREG_TARGET_NAME "rereg_target" #define UD_CB_LINK_NAME "ud_callback_link" #define NEW_UD_CB_LINK_NAME "ud_callback_link2" @@ -134,31 +134,31 @@ const char *FILENAME[] = { #define LE_FILENAME "le_extlink1.h5" #define BE_FILENAME "be_extlink1.h5" -#define ELINK_CB_FAM_SIZE (hsize_t) 100 +#define ELINK_CB_FAM_SIZE (hsize_t)100 #define H5L_DIM1 100 #define H5L_DIM2 100 /* Creation order macros */ -#define CORDER_GROUP_NAME "corder_group" -#define CORDER_SOFT_GROUP_NAME "corder_soft_group" -#define CORDER_NLINKS 18 -#define CORDER_ITER_STOP 3 -#define CORDER_EST_ENTRY_LEN 9 +#define CORDER_GROUP_NAME "corder_group" +#define CORDER_SOFT_GROUP_NAME "corder_soft_group" +#define CORDER_NLINKS 18 +#define CORDER_ITER_STOP 3 +#define CORDER_EST_ENTRY_LEN 9 /* Timestamp macros */ -#define TIMESTAMP_GROUP_1 "timestamp1" -#define TIMESTAMP_GROUP_2 "timestamp2" +#define TIMESTAMP_GROUP_1 "timestamp1" +#define TIMESTAMP_GROUP_2 "timestamp2" /* Link iteration struct */ typedef struct { - H5_iter_order_t order; /* Direction of iteration */ - unsigned ncalled; /* # of times callback is entered */ - unsigned nskipped; /* # of links skipped */ - int stop; /* # of iterations to stop after */ - int64_t curr; /* Current creation order value */ - size_t max_visit; /* Size of "visited link" flag array */ - hbool_t *visited; /* Pointer to array of "visited link" flags */ + H5_iter_order_t order; /* Direction of iteration */ + unsigned ncalled; /* # of times callback is entered */ + unsigned nskipped; /* # of links skipped */ + int stop; /* # of iterations to stop after */ + int64_t curr; /* Current creation order value */ + size_t max_visit; /* Size of "visited link" flag array */ + hbool_t * visited; /* Pointer to array of "visited link" flags */ } link_iter_info_t; #if 0 @@ -312,14 +312,8 @@ typedef struct { } ovisit_ud_t; #endif -static const char *FILENAME[] = { - "link0", - "link1.h5", - "link2.h5", - NULL -}; +static const char *FILENAME[] = {"link0", "link1.h5", "link2.h5", NULL}; - /*------------------------------------------------------------------------- * Function: test_basic_links * @@ -332,17 +326,17 @@ static const char *FILENAME[] = { * *------------------------------------------------------------------------- */ -static void test_basic_links(hid_t fapl_id, hbool_t new_format) +static void +test_basic_links(hid_t fapl_id, hbool_t new_format) { hsize_t size[1] = {1}; - char filename[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); - try - { - if(new_format) + try { + if (new_format) SUBTEST("Link creation (w/new group format)") else SUBTEST("Link creation") @@ -351,7 +345,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); // Create simple dataspace - DataSpace scalar (1, size, size); + DataSpace scalar(1, size, size); // Create a group then close it by letting the object go out of scope { @@ -367,25 +361,19 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) // Because these are not implemented in the C++ API yet, they are // used so CommonFG::getLinkval can be tested. - if(H5Lcreate_hard( - file_id, "dset1", H5L_SAME_LOC, "grp1/hard1", - H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_hard(file_id, "dset1", H5L_SAME_LOC, "grp1/hard1", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_hard failed"); // Create a symbolic link - if(H5Lcreate_soft( - "/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_soft failed"); // Create a symbolic link to something that doesn't exist - if(H5Lcreate_soft( - "foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_soft failed"); // Create a recursive symbolic link - if(H5Lcreate_soft( - "/grp1/recursive", file_id, "/grp1/recursive", - H5P_DEFAULT, H5P_DEFAULT) < 0) + if (H5Lcreate_soft("/grp1/recursive", file_id, "/grp1/recursive", H5P_DEFAULT, H5P_DEFAULT) < 0) throw Exception("test_basic_links", "H5Lcreate_soft failed"); // Verify link values before closing the file @@ -400,21 +388,19 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } // Open the file and check on the links in it - try - { + try { // Open the file above H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); // Verify link existence - if(file.nameExists("dset1", LinkAccPropList::DEFAULT) != TRUE) + if (file.nameExists("dset1", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::nameExists", "dset1 doesn't exist"); - if(file.nameExists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) + if (file.nameExists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE) throw InvalidActionException("H5File::nameExists", "grp1/soft doesn't exist"); // Verify link values @@ -426,12 +412,11 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_basic_links - + /*------------------------------------------------------------------------- * Function: test_lcpl * @@ -449,16 +434,15 @@ static void test_lcpl(hid_t fapl_id, hbool_t new_format) { H5L_info_t linfo; - char filename[1024]; - hsize_t dims[2]; + char filename[1024]; + hsize_t dims[2]; - if(new_format) + if (new_format) SUBTEST("Link creation property lists (w/new group format)") else SUBTEST("Link creation property lists") - try - { + try { FileAccPropList fapl(fapl_id); // Create a new file. @@ -471,7 +455,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) // Check that its character encoding is the default. linfo = file.getLinkInfo(GROUP1NAME); - if(linfo.cset != H5T_CSET_ASCII) + if (linfo.cset != H5T_CSET_ASCII) throw InvalidActionException("H5Lget_info", "Character encoding is not default"); // Create and commit a datatype with the default LCPL. @@ -486,7 +470,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) // Create a simple dataspace. dims[0] = H5L_DIM1; dims[1] = H5L_DIM2; - DataSpace dspace(2 ,dims); + DataSpace dspace(2, dims); // Create a dataset using the default LCPL. DataSet dset(file.createDataSet("/dataset", PredType::NATIVE_INT, dspace)); @@ -510,12 +494,11 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_lcpl()", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_lcpl() - + /*------------------------------------------------------------------------- * Function: test_move * @@ -529,15 +512,14 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) static void test_move(hid_t fapl_id, hbool_t new_format) { - char filename[1024]; + char filename[1024]; - if(new_format) + if (new_format) SUBTEST("Group::moveLink (w/new group format)") else SUBTEST("Group::moveLink") - try - { + try { FileAccPropList fapl(fapl_id); // Create two new files @@ -560,15 +542,16 @@ test_move(hid_t fapl_id, hbool_t new_format) grp_1.moveLink("group_move", file_b, "group_new_name"); // Should throw an exception but didn't - H5_FAILED(); - cerr << " Group group_move should not be moved across files" << endl; - } catch (Exception& E) { + H5_FAILED(); + cerr << " Group group_move should not be moved across files" << endl; + } + catch (Exception &E) { // expected } // Move a soft link across files, should succeed grp_2.moveLink("soft", file_b, "soft_new_name"); - if(file_b.nameExists("soft_new_name") != TRUE) + if (file_b.nameExists("soft_new_name") != TRUE) throw InvalidActionException("H5File::nameExists", "grp1/soft doesn't exist"); // Move a group across groups in the same file while renaming it @@ -583,9 +566,10 @@ test_move(hid_t fapl_id, hbool_t new_format) moved_grp = grp_1.openGroup("group_move"); // Should throw an exception but didn't - H5_FAILED(); - cerr << " Group group_move should not be in original location" << endl; - } catch (Exception& E) { + H5_FAILED(); + cerr << " Group group_move should not be in original location" << endl; + } + catch (Exception &E) { // expected } @@ -617,46 +601,49 @@ test_move(hid_t fapl_id, hbool_t new_format) moved_grp = grp_1.openGroup("group_newer_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_newer_name should not be in GROUP1NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP1NAME" << endl; + } + catch (Exception &E) { // expected } try { moved_grp = grp_2.openGroup("group_newer_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; + } + catch (Exception &E) { // expected } try { moved_grp = grp_2.openGroup("group_new_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_new_name should not be in GROUP2NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_new_name should not be in GROUP2NAME" << endl; + } + catch (Exception &E) { // expected } try { moved_grp = grp_1.openGroup("group_copy"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_copy should not be in GROUP1NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_copy should not be in GROUP1NAME" << endl; + } + catch (Exception &E) { // expected } PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_move()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_move - + /*------------------------------------------------------------------------- * Function: test_copy * @@ -667,17 +654,17 @@ test_move(hid_t fapl_id, hbool_t new_format) * May 2018 *------------------------------------------------------------------------- */ -static void test_copy(hid_t fapl_id, hbool_t new_format) +static void +test_copy(hid_t fapl_id, hbool_t new_format) { char filename[1024]; - if(new_format) + if (new_format) SUBTEST("Group::copyLink (w/new group format)") else SUBTEST("Group::copyLink") - try - { + try { // Create two new files h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); H5File file_a(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl_id); @@ -696,7 +683,8 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) // Copy a group across files, should fail try { grp_1.copyLink("group_copy", file_b, "group_new_name"); - } catch (Exception& E) { + } + catch (Exception &E) { // expected } @@ -766,9 +754,10 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) moved_grp = grp_2.openGroup("group_newer_name"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_newer_name should not be in GROUP2NAME" << endl; + } + catch (Exception &E) { // expected } @@ -778,20 +767,20 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) moved_grp = grp_1.openGroup("group_copy"); moved_grp.close(); - H5_FAILED(); // Should throw an exception but didn't - cerr << " Group group_copy should not be in GROUP1NAME" << endl; - } catch (Exception& E) { + H5_FAILED(); // Should throw an exception but didn't + cerr << " Group group_copy should not be in GROUP1NAME" << endl; + } + catch (Exception &E) { // expected } PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_copy()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_copy - + /*------------------------------------------------------------------------- * Function: test_num_links * @@ -803,17 +792,17 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) * March, 2017 *------------------------------------------------------------------------- */ -static void test_num_links(hid_t fapl_id, hbool_t new_format) +static void +test_num_links(hid_t fapl_id, hbool_t new_format) { char filename[NAME_BUF_SIZE]; - if(new_format) + if (new_format) SUBTEST("Setting number of links (w/new group format)") else SUBTEST("Setting number of links") - try - { + try { // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); @@ -821,7 +810,7 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format) H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl); LinkAccPropList lapl; - size_t nlinks = 5; + size_t nlinks = 5; lapl.setNumLinks(nlinks); // Read it back and verify @@ -830,12 +819,11 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_num_links()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_num_links - + /*------------------------------------------------------------------------- * Function: test_links * @@ -848,38 +836,36 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format) * *------------------------------------------------------------------------- */ -extern "C" -void test_links() +extern "C" void +test_links() { - hid_t fapl_id, fapl2_id; // File access property lists - hbool_t new_format; // Whether to use the new format or not + hid_t fapl_id, fapl2_id; // File access property lists + hbool_t new_format; // Whether to use the new format or not const char *envval; envval = HDgetenv("HDF5_DRIVER"); - if(envval == NULL) + if (envval == NULL) envval = "nomatch"; fapl_id = h5_fileaccess(); // Output message about test being performed MESSAGE(5, ("Testing Various Links\n")); - try - { + try { /* Copy the file access property list */ - if((fapl2_id = H5Pcopy(fapl_id)) < 0) + if ((fapl2_id = H5Pcopy(fapl_id)) < 0) throw Exception("test_links", "H5Pcopy failed"); /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if(H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - throw Exception("test_links", "H5Pset_libver_bounds failed"); + if (H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + throw Exception("test_links", "H5Pset_libver_bounds failed"); /* Loop over using new group format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) - { + for (new_format = FALSE; new_format <= TRUE; new_format++) { hid_t my_fapl_id; /* Check for FAPL to use */ - if(new_format) + if (new_format) my_fapl_id = fapl2_id; else my_fapl_id = fapl_id; @@ -975,7 +961,7 @@ void test_links() /* Keep this test last, it's testing files that are used above */ /* do not do this for files used by external link tests */ nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0; -#endif // 0 +#endif // 0 } /* end for */ #if 0 @@ -1012,16 +998,14 @@ void test_links() h5_clean_files(FILENAME, fapl_id); /* Test that external links can be used after a library reset. MUST be - * called last so the reset doesn't interfere with the property lists. This - * routine will delete its own file. */ + * called last so the reset doesn't interfere with the property lists. This + * routine will delete its own file. */ /* nerrors += external_reset_register() < 0 ? 1 : 0; - */ + */ } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg()); } - } /*------------------------------------------------------------------------- @@ -1036,9 +1020,8 @@ void test_links() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_links() +extern "C" void +cleanup_links() { HDremove(FILENAME[0]); } - diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index b5e9ff0..094acd6 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,26 +26,27 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file - -const H5std_string FILE_OBJECTS("tobjects.h5"); -const H5std_string FILE_OBJHDR("tobject_header.h5"); -const H5std_string GROUP1("Top Group"); -const H5std_string GROUP1_PATH("/Top Group"); -const H5std_string GROUP1_1("Sub-Group 1.1"); -const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); -const H5std_string GROUP1_2("Sub-Group 1.2"); -const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); -const H5std_string DSET_DEFAULT_NAME("default"); -const H5std_string DSET_IN_FILE("Dataset in File"); -const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); -const H5std_string DSET_IN_GRP1("Dataset in Group 1"); -const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1"); -const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2"); -const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2"); +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file + +const H5std_string FILE_OBJECTS("tobjects.h5"); +const H5std_string FILE_OBJHDR("tobject_header.h5"); +const H5std_string GROUP1("Top Group"); +const H5std_string GROUP1_PATH("/Top Group"); +const H5std_string GROUP1_1("Sub-Group 1.1"); +const H5std_string GROUP1_1_PATH("/Top Group/Sub-Group 1.1"); +const H5std_string GROUP1_2("Sub-Group 1.2"); +const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2"); +const H5std_string DSET_DEFAULT_NAME("default"); +const H5std_string DSET_IN_FILE("Dataset in File"); +const H5std_string DSET_IN_FILE_PATH("/Dataset in File"); +const H5std_string DSET_IN_GRP1("Dataset in Group 1"); +const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1"); +const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2"); +const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2"); /*------------------------------------------------------------------------- * Function: test_get_objname @@ -60,7 +61,8 @@ const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in * *------------------------------------------------------------------------- */ -static void test_get_objname() +static void +test_get_objname() { SUBTEST("H5Object::getObjName on Groups and Datasets"); @@ -69,19 +71,18 @@ static void test_get_objname() H5File file(FILE_OBJECTS, H5F_ACC_TRUNC); // Create a top group and 2 subgroups - Group grp1 = file.createGroup(GROUP1, 0); + Group grp1 = file.createGroup(GROUP1, 0); Group grp1_1 = grp1.createGroup(GROUP1_1, 0); Group grp1_2 = grp1.createGroup(GROUP1_2, 0); // Attempted to create a same group to generate a failure, which should // be caught with sub-class exception clause, if available. try { - Group grp1_2 = grp1.createGroup(GROUP1_2, 0); + grp1_2 = grp1.createGroup(GROUP1_2, 0); } - catch (GroupIException& E) - {} // do nothing, exception expected - catch (Exception& E) - { + catch (GroupIException &E) { + } // do nothing, exception expected + catch (Exception &E) { cerr << "Exception should have been caught by the previous catch" << endl; issue_fail_msg("test_get_objname", __LINE__, __FILE__); } @@ -93,27 +94,24 @@ static void test_get_objname() ssize_t name_len = grp1.getObjName(NULL); // Random length is 4 - if (name_len > 4) - { - char* grp1_name = new char[5]; - name_len = grp1.getObjName(grp1_name, 5); - verify_val((const char*)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__); - delete []grp1_name; + if (name_len > 4) { + char *grp1_name = new char[5]; + name_len = grp1.getObjName(grp1_name, 5); + verify_val((const char *)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__); + delete[] grp1_name; } // Create a data space - hsize_t dims[2]; + hsize_t dims[2]; dims[0] = 2; dims[1] = 5; - DataSpace space (2, dims, NULL); + DataSpace space(2, dims, NULL); // Create a dataset in the file - DataSet dsinfile = file.createDataSet(DSET_IN_FILE, - PredType::NATIVE_DOUBLE, space); + DataSet dsinfile = file.createDataSet(DSET_IN_FILE, PredType::NATIVE_DOUBLE, space); // Create a dataset in the group - DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1, - PredType::NATIVE_INT, space); + DataSet dsingrp = grp1.createDataSet(DSET_IN_GRP1, PredType::NATIVE_INT, space); // Get and verify the name of each dataset, using // H5std_string getObjName() and @@ -140,21 +138,20 @@ static void test_get_objname() // Reopen that same dataset then check the name again with another // overload: ssize_t getObjName(H5std_string& obj_name, size_t len = 0) - dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2); + dsingrp = grp1_2.openDataSet(DSET_IN_GRP1_2); name_len = dsingrp.getObjName(ds_name); verify_val(ds_name, DSET_IN_GRP1_2_PATH, "DataSet::getObjName", __LINE__, __FILE__); // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objname", __LINE__, __FILE__); } -} // test_get_objname +} // test_get_objname /*------------------------------------------------------------------------- * Function: test_get_objname_ontypes @@ -169,7 +166,8 @@ static void test_get_objname() * *------------------------------------------------------------------------- */ -static void test_get_objname_ontypes() +static void +test_get_objname_ontypes() { SUBTEST("H5Object::getObjName on Committed Datatypes"); @@ -178,7 +176,7 @@ static void test_get_objname_ontypes() H5File file(FILE_OBJECTS, H5F_ACC_RDWR); // Create a group - Group grp = file.createGroup ("typetests"); + Group grp = file.createGroup("typetests"); // Create a datatype and save it IntType inttype(PredType::STD_B8LE); @@ -221,7 +219,8 @@ static void test_get_objname_ontypes() // Name this datatype new_int_type.commit(grp, "IntType NATIVE_INT"); ssize_t name_len = new_int_type.getObjName(type_name); // default len - verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", __LINE__, __FILE__); + verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName", + __LINE__, __FILE__); verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__); // Close everything or they can be closed when objects go out of scope @@ -233,11 +232,10 @@ static void test_get_objname_ontypes() PASSED(); } // end top try block - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objname_ontypes", __LINE__, __FILE__); } -} // test_get_objname_ontypes +} // test_get_objname_ontypes /*------------------------------------------------------------------------- * Function: test_get_objtype @@ -252,7 +250,8 @@ static void test_get_objname_ontypes() * *------------------------------------------------------------------------- */ -static void test_get_objtype() +static void +test_get_objtype() { SUBTEST("H5File::childObjType and H5Group::childObjType"); @@ -293,15 +292,14 @@ static void test_get_objtype() // Everything will be closed as they go out of scope PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objtype", __LINE__, __FILE__); } -} // test_get_objtype - +} // test_get_objtype + /*------------------------------------------------------------------------- * Function: test_open_object_header * @@ -322,10 +320,10 @@ const H5std_string DSETNAME("dataset"); #define RANK 2 #define DIM0 5 #define DIM1 10 -static void test_open_object_header() +static void +test_open_object_header() { - hsize_t dims[2]; - H5G_info_t ginfo; /* Group info struct */ + hsize_t dims[2]; // Output message about test being performed SUBTEST("H5Location::openObjId and H5Location::closeObjId"); @@ -337,6 +335,7 @@ static void test_open_object_header() // Create a group in the root group Group grp(file1.createGroup(GROUPNAME)); + grp.close(); // Commit the type inside the file IntType dtype(PredType::NATIVE_INT); @@ -347,7 +346,7 @@ static void test_open_object_header() dims[0] = DIM0; dims[1] = DIM1; DataSpace dspace(RANK, dims); - DataSet dset(file1.createDataSet(DSETNAME, PredType::NATIVE_INT, dspace)); + DataSet dset(file1.createDataSet(DSETNAME, PredType::NATIVE_INT, dspace)); // Create a dataset in the group DataSet dsingrp(grp.createDataSet(DSET_IN_GRP1, PredType::NATIVE_INT, dspace)); @@ -355,12 +354,11 @@ static void test_open_object_header() // Close dataset, dataspace, and group dset.close(); dspace.close(); - grp.close(); // Now make sure that openObjId can open all three types of objects - hid_t obj_grp = file1.openObjId(GROUPNAME); + hid_t obj_grp = file1.openObjId(GROUPNAME); hid_t obj_dtype = file1.openObjId(DTYPENAME); - hid_t obj_dset = file1.openObjId(DSETNAME); + hid_t obj_dset = file1.openObjId(DSETNAME); // Make sure that each is the right kind of ID H5I_type_t id_type = IdComponent::getHDFObjType(obj_grp); @@ -372,7 +370,7 @@ static void test_open_object_header() /* Do something more complex with each of the IDs to make sure */ - Group grp2(obj_grp); + Group grp2(obj_grp); hsize_t num_objs = grp2.getNumObjs(); verify_val(num_objs, 2, "H5Gget_info", __LINE__, __FILE__); @@ -381,8 +379,9 @@ static void test_open_object_header() // Do a few things using the dset object identifier dset.setId(obj_dset); - dspace = dset.getSpace(); + dspace = dset.getSpace(); bool is_simple = dspace.isSimple(); + verify_val(is_simple, true, "isSimple", __LINE__, __FILE__); dspace.close(); // Open datatype object from the group @@ -412,34 +411,30 @@ static void test_open_object_header() try { Group grp3 = dsingrp.openObjId(NOGROUPNAME); } - catch (DataSetIException& E) - {} // do nothing, exception expected and caught correctly - catch (Exception& E) - { + catch (DataSetIException &E) { + } // do nothing, exception expected and caught correctly + catch (Exception &E) { cerr << "Exception should have been caught by the previous catch" << endl; issue_fail_msg("test_get_objname", __LINE__, __FILE__); } PASSED(); - } // end of try block + } // end of try block // catch invalid action exception - catch (InvalidActionException& E) - { + catch (InvalidActionException &E) { cerr << " in InvalidActionException" << endl; cerr << " *FAILED*" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; } // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } } /* test_open_object_header() */ - + /*------------------------------------------------------------------------- * Function: test_is_valid * - * Purpose: Tests validating IDs. * * Return: Success: 0 * Failure: -1 @@ -449,7 +444,8 @@ static void test_open_object_header() * *------------------------------------------------------------------------- */ -static void test_is_valid() +static void +test_is_valid() { SUBTEST("IdComponent::isValid"); @@ -458,8 +454,8 @@ static void test_is_valid() IntType int1(PredType::NATIVE_INT); // Check that the ID is valid - hid_t int1_id = int1.getId(); - bool is_valid = IdComponent::isValid(int1_id); + hid_t int1_id = int1.getId(); + bool is_valid = IdComponent::isValid(int1_id); verify_val(is_valid, true, "IdComponent::isValid", __LINE__, __FILE__); // Create another datatype @@ -479,14 +475,13 @@ static void test_is_valid() verify_val(is_valid, false, "IdComponent::isValid", __LINE__, __FILE__); PASSED(); - } // try block + } // try block // catch all other exceptions - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_get_objtype", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_is_valid +} // test_is_valid /*------------------------------------------------------------------------- * Function: test_objects @@ -501,19 +496,19 @@ static void test_is_valid() * *------------------------------------------------------------------------- */ -extern "C" -void test_object() +extern "C" void +test_object() { // Output message about test being performed MESSAGE(5, ("Testing Object Functions\n")); - test_get_objname(); // Test get object name from groups/datasets + test_get_objname(); // Test get object name from groups/datasets test_get_objname_ontypes(); // Test get object name from types - test_get_objtype(); // Test get object type - test_is_valid(); // Test validating IDs - test_open_object_header(); // Test object header functions (H5O) + test_get_objtype(); // Test get object type + test_is_valid(); // Test validating IDs + test_open_object_header(); // Test object header functions (H5O) -} // test_objects +} // test_objects /*------------------------------------------------------------------------- * Function: cleanup_objects @@ -526,8 +521,8 @@ void test_object() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_object() +extern "C" void +cleanup_object() { HDremove(FILE_OBJECTS.c_str()); } // cleanup_objects diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index 9f43054..5d8a1d5 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -25,25 +25,26 @@ #endif #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file // File names -const H5std_string FILE1("trefer1.h5"); -const H5std_string FILE2("trefer2.h5"); +const H5std_string FILE1("trefer1.h5"); +const H5std_string FILE2("trefer2.h5"); // Dataset and datatype names -const H5std_string DSET1_NAME("Dataset1"); -const H5std_string DSET2_NAME("Dataset2"); -const H5std_string DSET3_NAME("Dataset3"); -const H5std_string DTYPE_NAME("Datatype1"); +const H5std_string DSET1_NAME("Dataset1"); +const H5std_string DSET2_NAME("Dataset2"); +const H5std_string DSET3_NAME("Dataset3"); +const H5std_string DTYPE_NAME("Datatype1"); // Compound type member names -const H5std_string MEMBER1( "a_name" ); -const H5std_string MEMBER2( "b_name" ); -const H5std_string MEMBER3( "c_name" ); +const H5std_string MEMBER1("a_name"); +const H5std_string MEMBER2("b_name"); +const H5std_string MEMBER3("c_name"); // 1-D dataset with fixed dimensions const int SPACE1_RANK = 1; @@ -60,7 +61,7 @@ const int POINT1_NPOINTS = 10; typedef struct s1_t { unsigned int a; unsigned int b; - float c; + float c; } s1_t; /**************************************************************** @@ -77,23 +78,23 @@ test_reference_params(void) // Output message about test being performed SUBTEST("Object Reference Parameters"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + hobj_ref_t *wbuf, // buffer to write to disk + *rbuf, // buffer read from disk + *tbuf; // temp. buffer read from disk // Allocate write & read buffers - int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); - wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t)); + wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a group @@ -105,10 +106,10 @@ test_reference_params(void) // Create a dataset (inside /Group1) DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); - unsigned *tu32; // Temporary pointer to uint32 data - int i; - for (tu32=(unsigned *)wbuf, i=0; i<SPACE1_DIM1; i++) - *tu32++=i*3; // from C test + unsigned *tu32; // Temporary pointer to uint32 data + int i; + for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) + *tu32++ = i * 3; // from C test // Write selection to disk dataset.write(wbuf, PredType::NATIVE_UINT); @@ -143,19 +144,29 @@ test_reference_params(void) /* Test parameters to H5Location::reference */ try { file1->reference(NULL, "/Group1/Dataset1"); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], NULL); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], ""); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_MAXTYPE); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_DATASET_REGION); - } catch (ReferenceException& E) {} // We expect this to fail + } + catch (ReferenceException &E) { + } // We expect this to fail // Close resources dataset.close(); @@ -169,15 +180,13 @@ test_reference_params(void) PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_param()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_param()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} /* test_reference_param() */ +} /* test_reference_param() */ /**************************************************************** ** @@ -185,31 +194,32 @@ test_reference_params(void) ** to various kinds of objects ** ****************************************************************/ -static void test_reference_obj(void) +static void +test_reference_obj(void) { - int i; // counting variables - const H5std_string write_comment="Foo!"; // Comments for group + int i; // counting variables + const H5std_string write_comment = "Foo!"; // Comments for group // Output message about test being performed SUBTEST("Object Reference Functions"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { - hobj_ref_t *wbuf, // buffer to write to disk - *rbuf, // buffer read from disk - *tbuf; // temp. buffer read from disk + hobj_ref_t *wbuf, // buffer to write to disk + *rbuf, // buffer read from disk + *tbuf; // temp. buffer read from disk // Allocate write & read buffers - int temp_size = MAX(sizeof(unsigned),sizeof(hobj_ref_t)); - wbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - rbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); - tbuf=(hobj_ref_t*)HDmalloc(temp_size*SPACE1_DIM1); + int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t)); + wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); + tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1); // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a group @@ -221,9 +231,9 @@ static void test_reference_obj(void) // Create a dataset (inside /Group1) DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1); - unsigned *tu32; // Temporary pointer to uint32 data + unsigned *tu32; // Temporary pointer to uint32 data for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++=i*3; // from C test + *tu32++ = i * 3; // from C test // Write selection to disk dataset.write(wbuf, PredType::NATIVE_UINT); @@ -258,22 +268,22 @@ static void test_reference_obj(void) // Create reference to dataset and test getRefObjType file1->reference(&wbuf[0], "/Group1/Dataset1"); H5O_type_t refobj_type = dataset.getRefObjType(&wbuf[0], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to dataset and test getRefObjType file1->reference(&wbuf[1], "/Group1/Dataset2"); refobj_type = dataset.getRefObjType(&wbuf[1], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to group file1->reference(&wbuf[2], "/Group1"); refobj_type = dataset.getRefObjType(&wbuf[2], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType", __LINE__, __FILE__); // Create reference to named datatype file1->reference(&wbuf[3], "/Group1/Datatype1"); refobj_type = dataset.getRefObjType(&wbuf[3], H5R_OBJECT); - verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType", __LINE__, __FILE__); // Write selection to disk dataset.write(wbuf, PredType::STD_REF_OBJ); @@ -297,15 +307,15 @@ static void test_reference_obj(void) DataSet dset2(dataset, &rbuf[0], H5R_OBJECT); // Check information in the referenced dataset - sid1 = dset2.getSpace(); + sid1 = dset2.getSpace(); hssize_t n_elements = sid1.getSimpleExtentNpoints(); - verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Read from disk dset2.read(tbuf, PredType::NATIVE_UINT); - for(tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - verify_val(*tu32, (uint32_t)(i*3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + for (tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) + verify_val(*tu32, (uint32_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Close dereferenced dataset dset2.close(); @@ -316,18 +326,19 @@ static void test_reference_obj(void) // Get group's comment using // H5std_string getComment(const char* name, <buf_size=0 by default>) H5std_string read_comment1 = group.getComment(".", 10); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__); // Test with the old default value read_comment1 = group.getComment(".", 256); - verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment", __LINE__, __FILE__); // Test that getComment handles failures gracefully, using // H5std_string getComment(const char* name, <buf_size=0 by default>) try { H5std_string read_comment_tmp = group.getComment(NULL); } - catch (Exception& E) {} // We expect this to fail + catch (Exception &E) { + } // We expect this to fail // Close group group.close(); @@ -342,9 +353,9 @@ static void test_reference_obj(void) H5T_class_t tclass; tclass = dtype1.getClass(); - verify_val(tclass, H5T_COMPOUND, "DataType::getClass",__LINE__,__FILE__); + verify_val(tclass, H5T_COMPOUND, "DataType::getClass", __LINE__, __FILE__); int n_members = dtype1.getNmembers(); - verify_val(n_members, 3, "CompType::getNmembers",__LINE__,__FILE__); + verify_val(n_members, 3, "CompType::getNmembers", __LINE__, __FILE__); // Close all objects and file dtype1.close(); @@ -358,16 +369,13 @@ static void test_reference_obj(void) PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_obj()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_obj()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} // test_reference_obj() - +} // test_reference_obj() /**************************************************************** ** @@ -376,25 +384,25 @@ static void test_reference_obj(void) ** dereferenced group ** ****************************************************************/ -#define GROUPNAME "/group" -#define GROUPNAME2 "group2" -#define GROUPNAME3 "group3" -#define DSETNAME "/dset" -#define DSETNAME2 "dset2" -#define ATTRNAME "some attribute" -#define NAME_SIZE 16 +#define GROUPNAME "/group" +#define GROUPNAME2 "group2" +#define GROUPNAME3 "group3" +#define DSETNAME "/dset" +#define DSETNAME2 "dset2" +#define ATTRNAME "some attribute" +#define NAME_SIZE 16 static void test_reference_group(void) { - hobj_ref_t wref; /* Reference to write */ - hobj_ref_t rref; /* Reference to read */ - const H5std_string write_comment="Foo!"; // Comments for group + hobj_ref_t wref; /* Reference to write */ + hobj_ref_t rref; /* Reference to read */ + const H5std_string write_comment = "Foo!"; // Comments for group // Output message about test being performed SUBTEST("Object Reference to Group"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { /* * Create file with a group and a dataset containing an object @@ -402,7 +410,7 @@ test_reference_group(void) */ // Create file FILE1 - file1 = new H5File (FILE1, H5F_ACC_TRUNC); + file1 = new H5File(FILE1, H5F_ACC_TRUNC); // Create scalar dataspace DataSpace sid1; @@ -466,32 +474,32 @@ test_reference_group(void) // Check number of objects in the group dereferenced by constructor hsize_t nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check getting file name given the group dereferenced via constructor H5std_string fname = refgroup.getFileName(); - verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); - + verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__); + // Check number of objects in the group dereferenced by constructor nobjs = attrrefgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check getting file name given the group dereferenced via constructor fname = attrrefgroup.getFileName(); - verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); - + verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__); + // Check number of objects in the group dereferenced by ::reference nobjs = group.getNumObjs(); - verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__); // Check getting file name given the group dereferenced by ::reference fname = group.getFileName(); - verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); + verify_val(fname, FILE1, "H5Group::getFileName", __LINE__, __FILE__); // Unlink one of the objects in the dereferenced group, and re-check refgroup.unlink(GROUPNAME2); nobjs = refgroup.getNumObjs(); - verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs",__LINE__,__FILE__); + verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs", __LINE__, __FILE__); // Close resources group.close(); @@ -503,15 +511,13 @@ test_reference_group(void) PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_group()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_group()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; -} /* test_reference_group() */ +} /* test_reference_group() */ /**************************************************************** ** @@ -522,28 +528,28 @@ test_reference_group(void) static void test_reference_region_1D(void) { - hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ - hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ - hsize_t * coords; /* Coordinate buffer */ - hsize_t low[SPACE3_RANK]; /* Selection bounds */ - hsize_t high[SPACE3_RANK]; /* Selection bounds */ - int i; /* counting variables */ + hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ + hsize_t stride[SPACE3_RANK]; /* Stride of hyperslab */ + hsize_t count[SPACE3_RANK]; /* Element count of hyperslab */ + hsize_t block[SPACE3_RANK]; /* Block size of hyperslab */ + hsize_t coord1[POINT1_NPOINTS][SPACE3_RANK]; /* Coordinates for point selection */ + hsize_t *coords; /* Coordinate buffer */ + hsize_t low[SPACE3_RANK]; /* Selection bounds */ + hsize_t high[SPACE3_RANK]; /* Selection bounds */ + int i; /* counting variables */ // Output message about test being performed SUBTEST("1-D Dataset Region Reference Functions"); try { - hdset_reg_ref_t *wbuf, // buffer to write to disk - *rbuf; // buffer read from disk - uint8_t *dwbuf, // Buffer for writing numeric data to disk - *drbuf; // Buffer for reading numeric data from disk + hdset_reg_ref_t *wbuf, // buffer to write to disk + *rbuf; // buffer read from disk + uint8_t *dwbuf, // Buffer for writing numeric data to disk + *drbuf; // Buffer for reading numeric data from disk // Allocate write & read buffers - wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); + rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1); dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1); drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); @@ -551,13 +557,13 @@ test_reference_region_1D(void) H5File file1(FILE2, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims3[] = {SPACE3_DIM1}; + hsize_t dims3[] = {SPACE3_DIM1}; DataSpace sid3(SPACE3_RANK, dims3); // Create a dataset DataSet dset3 = file1.createDataSet(DSET2_NAME, PredType::STD_U8LE, sid3); - uint8_t *tu8; // Temporary pointer to uint8 data + uint8_t *tu8; // Temporary pointer to uint8 data for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) *tu8++ = i * 3; // from C test @@ -568,7 +574,7 @@ test_reference_region_1D(void) dset3.close(); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a dataset @@ -579,24 +585,24 @@ test_reference_region_1D(void) */ /* Select 15 2x1 hyperslabs for first reference */ - start[0] = 2; + start[0] = 2; stride[0] = 5; - count[0] = 15; - block[0] = 2; + count[0] = 15; + block[0] = 2; // Select a hyperslab region to add to the current selected region sid3.selectHyperslab(H5S_SELECT_SET, count, start, stride, block); // Get and verify the number of elements in a dataspace selection hssize_t nelms = sid3.getSelectNpoints(); - verify_val(nelms, 30, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(nelms, 30, "DataSet::getRefObjType", __LINE__, __FILE__); // Store first dataset region file1.reference(&wbuf[0], "/Dataset2", sid3); // Get and verify object type H5O_type_t obj_type = dset1.getRefObjType(&wbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); /* Select sequence of ten points for second reference */ coord1[0][0] = 16; @@ -615,7 +621,7 @@ test_reference_region_1D(void) // Get and verify the number of elements in a dataspace selection nelms = sid3.getSelectNpoints(); - verify_val(nelms, 10, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(nelms, 10, "DataSet::getRefObjType", __LINE__, __FILE__); // Store first dataset region file1.reference(&wbuf[1], "/Dataset2", sid3); @@ -647,12 +653,12 @@ test_reference_region_1D(void) // Get and verify object type obj_type = dset1.getRefObjType(&rbuf[0], H5R_DATASET_REGION); - verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType",__LINE__,__FILE__); + verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__); // Get dataspace of dset3 the verify number of elements - sid1 = dset3.getSpace(); + sid1 = dset3.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); } // End of test DataSet::dereference { // Test DataSet constructor -by dereference @@ -661,9 +667,9 @@ test_reference_region_1D(void) DataSet newds(dset1, &rbuf[0], H5R_DATASET_REGION); // Get dataspace of newds then verify number of elements - sid1 = newds.getSpace(); + sid1 = newds.getSpace(); nelms = sid1.getSimpleExtentNpoints(); - verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); // Close objects for this mini test newds.close(); @@ -673,8 +679,8 @@ test_reference_region_1D(void) // Read from disk dset3.read(drbuf, PredType::STD_U8LE); - for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) - verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints",__LINE__,__FILE__); + for (tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) + verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__); /* * Test getting the referenced region @@ -685,11 +691,11 @@ test_reference_region_1D(void) // Get and verify number of elements in a dataspace selection nelms = reg_sp.getSelectNpoints(); - verify_val((long)nelms, 30, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 30, "DataSpace::getSelectNpoints", __LINE__, __FILE__); // Get and verify number of hyperslab blocks nelms = reg_sp.getSelectHyperNblocks(); - verify_val((long)nelms, 15, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + verify_val((long)nelms, 15, "DataSpace::getSelectNpoints", __LINE__, __FILE__); /* Allocate space for the hyperslab blocks */ coords = (hsize_t *)HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2); @@ -698,43 +704,43 @@ test_reference_region_1D(void) reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords); // Verify values in the list - verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[4],(hsize_t)12, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[5],(hsize_t)13, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[6],(hsize_t)17, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[7],(hsize_t)18, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[8],(hsize_t)22, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[9],(hsize_t)23, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[10],(hsize_t)27, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[11],(hsize_t)28, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[12],(hsize_t)32, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[13],(hsize_t)33, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[14],(hsize_t)37, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[15],(hsize_t)38, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[16],(hsize_t)42, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[17],(hsize_t)43, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[18],(hsize_t)47, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[19],(hsize_t)48, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[20],(hsize_t)52, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[21],(hsize_t)53, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[22],(hsize_t)57, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[23],(hsize_t)58, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[24],(hsize_t)62, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[25],(hsize_t)63, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[26],(hsize_t)67, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[27],(hsize_t)68, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[28],(hsize_t)72, "Hyperslab Coordinates",__LINE__,__FILE__); - verify_val(coords[29],(hsize_t)73, "Hyperslab Coordinates",__LINE__,__FILE__); + verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[4], (hsize_t)12, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[5], (hsize_t)13, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[6], (hsize_t)17, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[7], (hsize_t)18, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[8], (hsize_t)22, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[9], (hsize_t)23, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[10], (hsize_t)27, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[11], (hsize_t)28, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[12], (hsize_t)32, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[13], (hsize_t)33, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[14], (hsize_t)37, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[15], (hsize_t)38, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[16], (hsize_t)42, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[17], (hsize_t)43, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[18], (hsize_t)47, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[19], (hsize_t)48, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[20], (hsize_t)52, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[21], (hsize_t)53, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[22], (hsize_t)57, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[23], (hsize_t)58, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[24], (hsize_t)62, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[25], (hsize_t)63, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[26], (hsize_t)67, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[27], (hsize_t)68, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[28], (hsize_t)72, "Hyperslab Coordinates", __LINE__, __FILE__); + verify_val(coords[29], (hsize_t)73, "Hyperslab Coordinates", __LINE__, __FILE__); HDfree(coords); // Check boundaries reg_sp.getSelectBounds(low, high); - verify_val(low[0],(hsize_t)2, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)73, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0], (hsize_t)2, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(high[0], (hsize_t)73, "DataSpace::getSelectBounds", __LINE__, __FILE__); /* Close region space */ reg_sp.close(); @@ -748,7 +754,7 @@ test_reference_region_1D(void) // Get and verify number of element points in the current selection hssize_t nelmspts = elm_sp.getSelectElemNpoints(); - verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints",__LINE__,__FILE__); + verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints", __LINE__, __FILE__); /* Allocate space for the hyperslab blocks */ coords = (hsize_t *)HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t)); @@ -757,23 +763,23 @@ test_reference_region_1D(void) elm_sp.getSelectElemPointlist((hsize_t)0, (hsize_t)nelmspts, coords); // Verify points - verify_val(coords[0], coord1[0][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[1], coord1[1][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[2], coord1[2][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[3], coord1[3][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[4], coord1[4][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[5], coord1[5][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[6], coord1[6][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[7], coord1[7][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[8], coord1[8][0], "Element Coordinates",__LINE__,__FILE__); - verify_val(coords[9], coord1[9][0], "Element Coordinates",__LINE__,__FILE__); + verify_val(coords[0], coord1[0][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[1], coord1[1][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[2], coord1[2][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[3], coord1[3][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[4], coord1[4][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[5], coord1[5][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[6], coord1[6][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[7], coord1[7][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[8], coord1[8][0], "Element Coordinates", __LINE__, __FILE__); + verify_val(coords[9], coord1[9][0], "Element Coordinates", __LINE__, __FILE__); HDfree(coords); // Check boundaries elm_sp.getSelectBounds(low, high); - verify_val(low[0],(hsize_t)3, "DataSpace::getSelectBounds",__LINE__,__FILE__); - verify_val(high[0],(hsize_t)97, "DataSpace::getSelectBounds",__LINE__,__FILE__); + verify_val(low[0], (hsize_t)3, "DataSpace::getSelectBounds", __LINE__, __FILE__); + verify_val(high[0], (hsize_t)97, "DataSpace::getSelectBounds", __LINE__, __FILE__); // Close element space elm_sp.close(); @@ -792,13 +798,10 @@ test_reference_region_1D(void) PASSED(); } // end try - catch (Exception& E) - { - issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__, - E.getCFuncName(), E.getCDetailMsg()); + catch (Exception &E) { + issue_fail_msg("test_reference_region_1D()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg()); } -} /* test_reference_region_1D() */ - +} /* test_reference_region_1D() */ /**************************************************************** ** @@ -806,22 +809,22 @@ test_reference_region_1D(void) ** Tests references to various kinds of objects using deprecated API. ** ****************************************************************/ -static void test_reference_compat(void) +static void +test_reference_compat(void) { - // Not yet -} // test_reference_compat() - + // Not yet +} // test_reference_compat() /**************************************************************** ** ** test_reference(): Main reference testing routine. ** ****************************************************************/ -extern "C" -void test_reference(void) +extern "C" void +test_reference(void) { // Output message about test being performed - //MESSAGE("Testing References\n"); + // MESSAGE("Testing References\n"); MESSAGE(5, ("Testing References\n")); test_reference_params(); // Test basic parameters of reference functionality @@ -830,18 +833,16 @@ void test_reference(void) test_reference_region_1D(); // Test 1-D reference functionality test_reference_compat(); // Tests deprecated reference routines (not yet) -} // test_reference() +} // test_reference() - /**************************************************************** ** Function: cleanup_reference ** Purpose: Cleanup temporary test files ** Return: none ****************************************************************/ -extern "C" -void cleanup_reference(void) +extern "C" void +cleanup_reference(void) { HDremove(FILE1.c_str()); HDremove(FILE2.c_str()); } - diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index a706197..c975158 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -26,16 +26,17 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file /* * Offset from alinged memory returned by malloc(). This can be used to test * that type conversions handle non-aligned buffers correctly. */ -#define ALIGNMENT 1 +#define ALIGNMENT 1 /* * Define if you want to test alignment code on a machine that doesn't @@ -50,32 +51,32 @@ using namespace H5; #define H5T_PACKAGE #include "H5Tpkg.h" #endif -#define SET_ALIGNMENT(TYPE,VAL) \ - H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) +#define SET_ALIGNMENT(TYPE, VAL) H5T_NATIVE_##TYPE##_ALIGN_g = MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) #endif -const char *FILENAME[] = { - "dtypes1.h5", - "dtypes2.h5", - "dtypes3.h5", - NULL -}; +const char *FILENAME[] = {"dtypes1.h5", "dtypes2.h5", "dtypes3.h5", NULL}; /* * Count up or down depending on whether the machine is big endian or little * endian. If local variable `endian' is H5T_ORDER_BE then the result will * be I, otherwise the result will be Z-(I+1). */ -#define ENDIAN(Z,I) (H5T_ORDER_BE==endian?(I):(Z)-((I)+1)) +#define ENDIAN(Z, I) (H5T_ORDER_BE == endian ? (I) : (Z) - ((I) + 1)) - -typedef enum flt_t { - FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER -} flt_t; +typedef enum flt_t { FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER } flt_t; typedef enum int_t { - INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, - INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER + INT_CHAR, + INT_UCHAR, + INT_SHORT, + INT_USHORT, + INT_INT, + INT_UINT, + INT_LONG, + INT_ULONG, + INT_LLONG, + INT_ULLONG, + INT_OTHER } int_t; typedef struct { @@ -84,7 +85,7 @@ typedef struct { long c; double d; } src_typ_t; - + /*------------------------------------------------------------------------- * Function: test_classes * @@ -97,7 +98,8 @@ typedef struct { * *------------------------------------------------------------------------- */ -static void test_classes() +static void +test_classes() { SUBTEST("PredType::getClass()"); try { @@ -105,23 +107,23 @@ static void test_classes() // PredType::NATIVE_INT should be in H5T_INTEGER class H5T_class_t tcls = PredType::NATIVE_INT.getClass(); - if (H5T_INTEGER!=tcls) { + if (H5T_INTEGER != tcls) { puts(" Invalid type class for H5T_NATIVE_INT"); } // PredType::NATIVE_DOUBLE should be in H5T_FLOAT class tcls = PredType::NATIVE_DOUBLE.getClass(); - if (H5T_FLOAT!=tcls) { - verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, __FILE__); + if (H5T_FLOAT != tcls) { + verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, + __FILE__); } PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_classes", __LINE__, __FILE__, E.getCDetailMsg()); } } - + /*------------------------------------------------------------------------- * Function: test_copy * @@ -134,7 +136,8 @@ static void test_classes() * *------------------------------------------------------------------------- */ -static void test_copy() +static void +test_copy() { SUBTEST("DataType::copy() and DataType::operator="); try { @@ -144,7 +147,7 @@ static void test_copy() // Test copying a predefined type using DataType::copy DataType copied_type; - copied_type.copy (PredType::STD_B8LE); + copied_type.copy(PredType::STD_B8LE); // Test copying a user-defined type using DataType::operator= DataType assigned_usertype; @@ -155,7 +158,7 @@ static void test_copy() copied_usertype.copy(copied_type); // Test copying a user-defined int type using DataType::operator= - IntType orig_int(PredType::STD_B8LE); + IntType orig_int(PredType::STD_B8LE); DataType generic_type; generic_type = orig_int; @@ -168,13 +171,11 @@ static void test_copy() PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg()); } } - /*------------------------------------------------------------------------- * Function: test_query * @@ -191,14 +192,14 @@ static void test_copy() const H5std_string CompT_NAME("Compound_type"); const H5std_string EnumT_NAME("Enum_type"); -static void test_query() +static void +test_query() { - short enum_val; + short enum_val; // Output message about test being performed SUBTEST("Query functions of compound and enumeration types"); - try - { + try { // Create File H5File file(FILENAME[2], H5F_ACC_TRUNC); @@ -213,11 +214,11 @@ static void test_query() // Create a enumerate datatype EnumType tid2(sizeof(short)); - tid2.insert("RED", (enum_val=0,&enum_val)); - tid2.insert("GREEN", (enum_val=1,&enum_val)); - tid2.insert("BLUE", (enum_val=2,&enum_val)); - tid2.insert("ORANGE", (enum_val=3,&enum_val)); - tid2.insert("YELLOW", (enum_val=4,&enum_val)); + tid2.insert("RED", (enum_val = 0, &enum_val)); + tid2.insert("GREEN", (enum_val = 1, &enum_val)); + tid2.insert("BLUE", (enum_val = 2, &enum_val)); + tid2.insert("ORANGE", (enum_val = 3, &enum_val)); + tid2.insert("YELLOW", (enum_val = 4, &enum_val)); // Query member number and member index by name, for compound type int nmembs = tid1.getNmembers(); @@ -237,10 +238,10 @@ static void test_query() // prop list, then close it tid1.commit(file, CompT_NAME); PropList tcpl = tid1.getCreatePlist(); - if (!IdComponent::isValid(tcpl.getId())) - { + if (!IdComponent::isValid(tcpl.getId())) { // Throw an invalid action exception - throw InvalidActionException("IdComponent::isValid", "Datatype creation property list is not valid"); + throw InvalidActionException("IdComponent::isValid", + "Datatype creation property list is not valid"); } tcpl.close(); tid1.close(); @@ -249,10 +250,10 @@ static void test_query() // prop list, then close it tid2.commit(file, EnumT_NAME); tcpl = tid2.getCreatePlist(); - if (!IdComponent::isValid(tcpl.getId())) - { + if (!IdComponent::isValid(tcpl.getId())) { // Throw an invalid action exception - throw InvalidActionException("IdComponent::isValid", "Datatype creation property list is not valid"); + throw InvalidActionException("IdComponent::isValid", + "Datatype creation property list is not valid"); } tcpl.close(); tid2.close(); @@ -285,14 +286,12 @@ static void test_query() H5File file1(FILENAME[2], H5F_ACC_TRUNC); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_query +} // test_query - /*------------------------------------------------------------------------- * Function: test_transient * @@ -305,16 +304,17 @@ static void test_query() * *------------------------------------------------------------------------- */ -const char* filename1 = "dtypes1.h5"; -static void test_transient () +const char *filename1 = "dtypes1.h5"; +static void +test_transient() { - static hsize_t ds_size[2] = {10, 20}; + static hsize_t ds_size[2] = {10, 20}; SUBTEST("Transient datatypes"); try { // Create the file and the dataspace. - H5File file(filename1, H5F_ACC_TRUNC); + H5File file(filename1, H5F_ACC_TRUNC); DataSpace space(2, ds_size, ds_size); // Copying a predefined type results in a modifiable copy @@ -325,8 +325,11 @@ static void test_transient () try { Attribute attr(type.createAttribute("attr1", PredType::NATIVE_INT, space)); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("H5Object::createAttribute", "Attempted to commit a predefined datatype."); - } catch (AttributeIException& err) {} // do nothing, failure expected + throw InvalidActionException("H5Object::createAttribute", + "Attempted to commit a predefined datatype."); + } + catch (AttributeIException &err) { + } // do nothing, failure expected // Create a dataset from a transient datatype // type.close(); - put trace in H5Tclose to make sure it's closed @@ -339,8 +342,11 @@ static void test_transient () itype.setPrecision(256); // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("PredType::setPrecision", "Dataset datatypes should not be modifiable!"); - } catch (DataTypeIException& err) {} + throw InvalidActionException("PredType::setPrecision", + "Dataset datatypes should not be modifiable!"); + } + catch (DataTypeIException &err) { + } itype.close(); // Get a copy of the dataset's datatype by applying DataType::copy() @@ -360,14 +366,12 @@ static void test_transient () type.close(); space.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_transient", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_transient +} // test_transient - /*------------------------------------------------------------------------- * Function: test_named * @@ -381,12 +385,13 @@ static void test_transient () *------------------------------------------------------------------------- */ const H5std_string filename2("dtypes2.h5"); -static void test_named () +static void +test_named() { - static hsize_t ds_size[2] = {10, 20}; - hsize_t i; - unsigned attr_data[10][20]; - DataType *ds_type = NULL; + static hsize_t ds_size[2] = {10, 20}; + hsize_t i; + unsigned attr_data[10][20]; + DataType * ds_type = NULL; SUBTEST("Named datatypes"); try { @@ -403,15 +408,16 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("PredType::commit", "Attempted to commit a predefined datatype."); - } catch (DataTypeIException& err) {} + } + catch (DataTypeIException &err) { + } // Copy a predefined datatype and commit the copy. IntType itype(PredType::NATIVE_INT); itype.commit(file, "native-int"); // Test commit passing in const H5File& for prototype with const - try - { + try { // Create random char type IntType atype(PredType::NATIVE_UCHAR); @@ -421,9 +427,8 @@ static void test_named () // Commit type passing in const group; compilation would fail if // no matching prototype atype.commit(const_grp, "random uchar"); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group"); } @@ -433,11 +438,14 @@ static void test_named () // We should not be able to modify a type after it has been committed. try { - itype.setPrecision(256); // attempt an invalid action... + itype.setPrecision(256); // attempt an invalid action... // Should FAIL but didn't, so throw an invalid action exception - throw InvalidActionException("IntType::setPrecision", "Attempted to modify a committed datatype."); - } catch (DataTypeIException& err) {} + throw InvalidActionException("IntType::setPrecision", + "Attempted to modify a committed datatype."); + } + catch (DataTypeIException &err) { + } // We should not be able to re-commit a committed type try { @@ -445,12 +453,14 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("IntType::commit", "Attempted to re-commit a committed datatype."); - } catch (DataTypeIException& err) {} // do nothing, failure expected + } + catch (DataTypeIException &err) { + } // do nothing, failure expected // It should be possible to define an attribute for the named type Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space); - for (i=0; i<ds_size[0]*ds_size[1]; i++) - attr_data[0][i] = (int)i;/*tricky*/ + for (i = 0; i < ds_size[0] * ds_size[1]; i++) + attr_data[0][i] = (int)i; /*tricky*/ attr1.write(PredType::NATIVE_UINT, attr_data); attr1.close(); @@ -459,13 +469,15 @@ static void test_named () IntType trans_type; trans_type.copy(itype); bool iscommitted = trans_type.committed(); - verify_val(iscommitted, 0, "DataType::committed() - Copying a named type should result in a transient type!", __LINE__, __FILE__); + verify_val(iscommitted, 0, + "DataType::committed() - Copying a named type should result in a transient type!", + __LINE__, __FILE__); trans_type.setPrecision(256); trans_type.close(); // Close the committed type and reopen it. It should be a named type. itype.close(); - itype = file.openIntType("native-int"); + itype = file.openIntType("native-int"); iscommitted = itype.committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "Opened named types should be named types!"); @@ -473,8 +485,8 @@ static void test_named () // Create a dataset that uses the named type, then get the dataset's // datatype and make sure it's a named type. DataSet dset = file.createDataSet("dset1", itype, space); - ds_type = new DataType(dset.getDataType()); - iscommitted = ds_type->committed(); + ds_type = new DataType(dset.getDataType()); + iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); dset.close(); @@ -483,8 +495,8 @@ static void test_named () // Reopen the dataset and its type, then make sure the type is // a named type. - dset = file.openDataSet("dset1"); - ds_type = new DataType(dset.getDataType()); + dset = file.openDataSet("dset1"); + ds_type = new DataType(dset.getDataType()); iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("IntType::committed()", "Dataset type should be named type!"); @@ -498,8 +510,8 @@ static void test_named () delete ds_type; // Reopen the second dataset and make sure the type is shared - dset = file.openDataSet("dset2"); - ds_type = new DataType(dset.getDataType()); + dset = file.openDataSet("dset2"); + ds_type = new DataType(dset.getDataType()); iscommitted = ds_type->committed(); if (!iscommitted) throw InvalidActionException("DataType::iscommitted()", "Dataset type should be named type!"); @@ -518,17 +530,15 @@ static void test_named () space.close(); file.close(); PASSED(); - } // end of try block - catch (Exception& E) - { + } // end of try block + catch (Exception &E) { issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg()); } - if(ds_type) + if (ds_type) delete ds_type; -} // test_named +} // test_named - /*------------------------------------------------------------------------- * Function: test_encode_decode * @@ -542,11 +552,12 @@ static void test_named () *------------------------------------------------------------------------- */ const H5std_string filename3("encode_decode.h5"); -const int ARRAY1_RANK = 1; -const int ARRAY1_DIM = 10; -static void test_encode_decode() +const int ARRAY1_RANK = 1; +const int ARRAY1_DIM = 10; +static void +test_encode_decode() { - short enum_val; + short enum_val; SUBTEST("DataType::encode() and DataType::decode()"); try { @@ -572,7 +583,7 @@ static void test_encode_decode() verify_val(cmptyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode compound type's buffer to a new CompType - CompType* decoded_cmp_ptr(static_cast<CompType *>(cmptyp.decode())); + CompType *decoded_cmp_ptr(static_cast<CompType *>(cmptyp.decode())); // Verify that the datatype was copied exactly via encoding/decoding verify_val(cmptyp == *decoded_cmp_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -596,11 +607,11 @@ static void test_encode_decode() // Create a enumerate datatype EnumType enumtyp(sizeof(short)); - enumtyp.insert("RED", (enum_val=0,&enum_val)); - enumtyp.insert("GREEN", (enum_val=1,&enum_val)); - enumtyp.insert("BLUE", (enum_val=2,&enum_val)); - enumtyp.insert("ORANGE", (enum_val=3,&enum_val)); - enumtyp.insert("YELLOW", (enum_val=4,&enum_val)); + enumtyp.insert("RED", (enum_val = 0, &enum_val)); + enumtyp.insert("GREEN", (enum_val = 1, &enum_val)); + enumtyp.insert("BLUE", (enum_val = 2, &enum_val)); + enumtyp.insert("ORANGE", (enum_val = 3, &enum_val)); + enumtyp.insert("YELLOW", (enum_val = 4, &enum_val)); // Encode compound type in a buffer enumtyp.encode(); @@ -609,7 +620,7 @@ static void test_encode_decode() verify_val(enumtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode enumeration type's buffer to a new EnumType - EnumType* decoded_enum_ptr(static_cast<EnumType *>(enumtyp.decode())); + EnumType *decoded_enum_ptr(static_cast<EnumType *>(enumtyp.decode())); // Verify that the datatype was copied exactly via encoding/decoding verify_val(enumtyp == *decoded_enum_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -641,7 +652,7 @@ static void test_encode_decode() verify_val(vlsttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode the variable-length type's buffer to a new StrType - StrType* decoded_str_ptr(static_cast<StrType *>(vlsttyp.decode())); + StrType *decoded_str_ptr(static_cast<StrType *>(vlsttyp.decode())); verify_val(vlsttyp == *decoded_str_ptr, true, "DataType::decode", __LINE__, __FILE__); verify_val(decoded_str_ptr->isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); @@ -651,7 +662,7 @@ static void test_encode_decode() // Test decoding the type by way of DataType* // Decode variable-length string type to a new DataType - DataType* decoded_vlstr_ptr(vlsttyp.decode()); + DataType *decoded_vlstr_ptr(vlsttyp.decode()); // Create a StrType instance from the DataType object and verify it StrType decoded_vlsttyp(decoded_vlstr_ptr->getId()); @@ -676,7 +687,7 @@ static void test_encode_decode() verify_val(arrtyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Create an ArrayType instance from the decoded pointer and verify it - ArrayType* decoded_arr_ptr(static_cast<ArrayType *>(arrtyp.decode())); + ArrayType *decoded_arr_ptr(static_cast<ArrayType *>(arrtyp.decode())); verify_val(arrtyp == *decoded_arr_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -708,7 +719,7 @@ static void test_encode_decode() verify_val(inttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Create an IntType instance from the decoded pointer and verify it - IntType* decoded_int_ptr(static_cast<IntType *>(inttyp.decode())); + IntType * decoded_int_ptr(static_cast<IntType *>(inttyp.decode())); H5T_sign_t int_sign = decoded_int_ptr->getSign(); verify_val(int_sign, H5T_SGN_NONE, "DataType::decode", __LINE__, __FILE__); verify_val(inttyp == *decoded_int_ptr, true, "DataType::decode", __LINE__, __FILE__); @@ -729,34 +740,32 @@ static void test_encode_decode() verify_val(flttyp.hasBinaryDesc(), true, "DataType::encode", __LINE__, __FILE__); // Decode the array type's buffer - DataType* decoded_flt_ptr(flttyp.decode()); + DataType *decoded_flt_ptr(flttyp.decode()); // Create a IntType instance from the decoded pointer and verify it FloatType decoded_flttyp(decoded_flt_ptr->getId()); verify_val(flttyp == decoded_flttyp, true, "DataType::decode", __LINE__, __FILE__); - H5std_string norm_string; - H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string); - //verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); + // H5std_string norm_string; + // H5T_norm_t mant_norm = decoded_flttyp.getNorm(norm_string); + // verify_val(decoded_flttyp.isVariableStr(), true, "DataType::decode", __LINE__, __FILE__); delete decoded_flt_ptr; PASSED(); } - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_encode_decode", __LINE__, __FILE__, E.getCDetailMsg()); } } - /**************************************************************** ** ** test_types(): Main datatypes testing routine. ** ****************************************************************/ -extern "C" -void test_types() +extern "C" void +test_types() { // Output message about test being performed MESSAGE(5, ("Testing Generic Data Types\n")); @@ -769,9 +778,8 @@ void test_types() test_named(); test_encode_decode(); -} // test_types() +} // test_types() - /*------------------------------------------------------------------------- * Function: cleanup_types * @@ -784,9 +792,9 @@ void test_types() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_types() +extern "C" void +cleanup_types() { for (int i = 0; i < 3; i++) HDremove(FILENAME[i]); -} // cleanup_types +} // cleanup_types diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index d5f2afe..6154083 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -6,7 +6,7 @@ * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * distribution tree, or in https://www.hdfgroup.org/licenses. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -28,16 +28,17 @@ using std::cerr; using std::endl; #include <string> -#include "H5Cpp.h" // C++ API header file +#include "H5Cpp.h" // C++ API header file using namespace H5; -#include "h5cpputil.h" // C++ utilility header file +#include "h5test.h" +#include "h5cpputil.h" // C++ utilility header file // Data file used in most test functions const H5std_string FILENAME("tvlstr.h5"); // 1-D dataset with fixed dimensions -const int SPACE1_RANK = 1; +const int SPACE1_RANK = 1; const hsize_t SPACE1_DIM1 = 4; /**************************************************************** @@ -125,10 +126,11 @@ static void test_vlstr_free_custom(void *_mem, void *info) const H5std_string DSET1_NAME("String_ds"); const H5std_string DSET1_DATA("String Dataset"); -static void test_vlstring_dataset() +static void +test_vlstring_dataset() { char *dynstring_ds_write = NULL; - char *string_ds_check = NULL; + char *string_ds_check = NULL; // Output message about test being performed SUBTEST("VL String on Datasets"); @@ -144,7 +146,7 @@ static void test_vlstring_dataset() Group root = file1.openGroup("/"); // Create dataspace for the dataset. - DataSpace ds_space (H5S_SCALAR); + DataSpace ds_space(H5S_SCALAR); // Create an dataset in the root group. DataSet dset1 = root.createDataSet(DSET1_NAME, vlst, ds_space); @@ -154,17 +156,19 @@ static void test_vlstring_dataset() // Read and verify the dataset string as a string of chars. dset1.read(&string_ds_check, vlst); - if(HDstrcmp(string_ds_check, DSET1_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n",__LINE__, DSET1_DATA.c_str(), string_ds_check); + if (HDstrcmp(string_ds_check, DSET1_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n", __LINE__, + DSET1_DATA.c_str(), string_ds_check); - HDfree(string_ds_check); // note: no need for std::string test + HDfree(string_ds_check); // note: no need for std::string test string_ds_check = NULL; // Read and verify the dataset string as an std::string. H5std_string read_str; dset1.read(read_str, vlst); if (read_str != DSET1_DATA) - TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n",__LINE__, DSET1_DATA.c_str(), read_str.c_str()); + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n", __LINE__, + DSET1_DATA.c_str(), read_str.c_str()); // Close the dataset. dset1.close(); @@ -172,7 +176,7 @@ static void test_vlstring_dataset() // Test scalar type dataset with 1 value. dset1 = root.createDataSet("test_scalar_small", vlst, ds_space); - dynstring_ds_write = (char*)HDcalloc(1, sizeof(char)); + dynstring_ds_write = (char *)HDcalloc(1, sizeof(char)); HDmemset(dynstring_ds_write, 'A', 1); // Write data to the dataset, then read it back. @@ -180,8 +184,9 @@ static void test_vlstring_dataset() dset1.read(&string_ds_check, vlst); // Verify data read. - if(HDstrcmp(string_ds_check,dynstring_ds_write)!=0) - TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",dynstring_ds_write,string_ds_check); + if (HDstrcmp(string_ds_check, dynstring_ds_write) != 0) + TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n", + dynstring_ds_write, string_ds_check); HDfree(string_ds_check); string_ds_check = NULL; dset1.close(); @@ -197,16 +202,15 @@ static void test_vlstring_dataset() } // end try block // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } - if(dynstring_ds_write) + if (dynstring_ds_write) HDfree(dynstring_ds_write); - if(string_ds_check) + if (string_ds_check) HDfree(string_ds_check); -} // test_vlstring_dataset() +} // test_vlstring_dataset() /*------------------------------------------------------------------------- * Function: test_vlstring_array_dataset @@ -221,22 +225,22 @@ static void test_vlstring_dataset() *------------------------------------------------------------------------- */ const H5std_string DSSTRARR_NAME("StringArray_dset"); -static void test_vlstring_array_dataset() +static void +test_vlstring_array_dataset() { - const char *string_ds_array[SPACE1_DIM1]= { - "Line 1", "Line 2", "Line 3", "Line 4" - }; // Information to write + const char *string_ds_array[SPACE1_DIM1] = {"Line 1", "Line 2", "Line 3", + "Line 4"}; // Information to write // Output message about test being performed SUBTEST("VL String Array on Datasets"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { // Create file. file1 = new H5File(FILENAME, H5F_ACC_RDWR); // Create dataspace for datasets. - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace ds_space(SPACE1_RANK, dims1); // Create a datatype to refer to. @@ -252,10 +256,10 @@ static void test_vlstring_array_dataset() dataset.read(string_ds_check, vlst); hsize_t ii; - for (ii = 0; ii < SPACE1_DIM1; ii++) - { - if(HDstrcmp(string_ds_check[ii], string_ds_array[ii])!=0) - TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, string_ds_array[ii], string_ds_check[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) { + if (HDstrcmp(string_ds_check[ii], string_ds_array[ii]) != 0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n", __LINE__, + string_ds_array[ii], string_ds_check[ii]); HDfree(string_ds_check[ii]); } @@ -273,14 +277,14 @@ static void test_vlstring_array_dataset() // Create and write another dataset. DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space)); - char *wdata2 = (char*)HDcalloc(65534, sizeof(char)); + char * wdata2 = (char *)HDcalloc(65534, sizeof(char)); HDmemset(wdata2, 'A', 65533); dataset2.write(&wdata2, vlst); char *rdata2; dataset2.read(&rdata2, vlst); - if (HDstrcmp(wdata2, rdata2)!=0) - TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, wdata2, rdata2); + if (HDstrcmp(wdata2, rdata2) != 0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n", __LINE__, wdata2, rdata2); // Release resources from second dataset operation. scalar_space.close(); @@ -297,12 +301,11 @@ static void test_vlstring_array_dataset() } // end try // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; } // end test_vlstring_array_dataset() @@ -319,11 +322,12 @@ static void test_vlstring_array_dataset() * *------------------------------------------------------------------------- */ -static void test_vlstrings_special() +static void +test_vlstrings_special() { - const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"}; + const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"}; const char *wdata2[SPACE1_DIM1] = {NULL, NULL, NULL, NULL}; - char *rdata[SPACE1_DIM1]; // Information read in + char * rdata[SPACE1_DIM1]; // Information read in // Output message about test being performed. SUBTEST("Special VL Strings"); @@ -333,7 +337,7 @@ static void test_vlstrings_special() H5File file1(FILENAME, H5F_ACC_TRUNC); // Create dataspace for datasets. - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a datatype to refer to. @@ -347,30 +351,29 @@ static void test_vlstrings_special() // Check data read in. hsize_t ii; // counting variable - for (ii=0; ii<SPACE1_DIM1; ii++) - if(rdata[ii]!=NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) + if (rdata[ii] != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]); // Write dataset to disk, then read it back. dataset.write(wdata, vlst); dataset.read(rdata, vlst); // Compare data read in. - for (ii = 0; ii < SPACE1_DIM1; ii++) - { + for (ii = 0; ii < SPACE1_DIM1; ii++) { size_t wlen = HDstrlen(wdata[ii]); size_t rlen = HDstrlen(rdata[ii]); - if(wlen != rlen) - { - TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", (int)ii, (unsigned)wlen, (int)ii, (unsigned)rlen); + if (wlen != rlen) { + TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", + (int)ii, (unsigned)wlen, (int)ii, (unsigned)rlen); continue; } // end if - if(HDstrcmp(wdata[ii],rdata[ii]) != 0) - { - TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)ii, wdata[ii], (int)ii, rdata[ii]); + if (HDstrcmp(wdata[ii], rdata[ii]) != 0) { + TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)ii, wdata[ii], + (int)ii, rdata[ii]); continue; } // end if - } // end for + } // end for // Reclaim the read VL data. DataSet::vlenReclaim((void *)rdata, vlst, sid1); @@ -385,7 +388,7 @@ static void test_vlstrings_special() // Create the property list and set the fill value for the second // dataset. DSetCreatPropList dcpl; - char *fill = NULL; // Fill value + char * fill = NULL; // Fill value dcpl.setFillValue(vlst, &fill); dataset = file1.createDataSet("Dataset4", vlst, sid1, dcpl); @@ -396,9 +399,9 @@ static void test_vlstrings_special() dataset.read(rdata, vlst); // Check data read in. - for (ii=0; ii<SPACE1_DIM1; ii++) - if(rdata[ii]!=NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) + if (rdata[ii] != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]); // Try to write nil strings to disk. dataset.write(wdata2, vlst); @@ -407,9 +410,9 @@ static void test_vlstrings_special() dataset.read(rdata, vlst); // Check data read in. - for (ii=0; ii<SPACE1_DIM1; ii++) - if(rdata[ii]!=NULL) - TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)ii,rdata[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) + if (rdata[ii] != NULL) + TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]); // Close objects and file. dataset.close(); @@ -421,8 +424,7 @@ static void test_vlstrings_special() } // end try // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstrings_special()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_vlstrings_special @@ -439,13 +441,14 @@ static void test_vlstrings_special() * *------------------------------------------------------------------------- */ -const H5std_string VLSTR_TYPE("vl_string_type"); -static void test_vlstring_type() +const H5std_string VLSTR_TYPE("vl_string_type"); +static void +test_vlstring_type() { // Output message about test being performed. SUBTEST("VL String Type"); - H5File* file1 = NULL; + H5File *file1 = NULL; try { // Open file. file1 = new H5File(FILENAME, H5F_ACC_RDWR); @@ -495,17 +498,17 @@ static void test_vlstring_type() file1 = new H5File(FILENAME, H5F_ACC_RDWR); { // deprecated - // Open the variable-length string datatype just created. - vlst = file1->openStrType(VLSTR_TYPE); + // Open the variable-length string datatype just created. + vlst = file1->openStrType(VLSTR_TYPE); - // Verify character set and padding. - cset = vlst.getCset(); - verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); - pad = vlst.getStrpad(); - verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); + // Verify character set and padding. + cset = vlst.getCset(); + verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); + pad = vlst.getStrpad(); + verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); - // Close type to test new function. - vlst.close(); + // Close type to test new function. + vlst.close(); } // deprecated // Open the variable-length string datatype just created. @@ -525,12 +528,11 @@ static void test_vlstring_type() } // end try block // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_type()", __LINE__, __FILE__, E.getCDetailMsg()); } - if(file1) + if (file1) delete file1; } // end test_vlstring_type() @@ -546,7 +548,8 @@ static void test_vlstring_type() * *------------------------------------------------------------------------- */ -static void test_compact_vlstring() +static void +test_compact_vlstring() { // Output message about test being performed SUBTEST("VL Strings on Compact Dataset"); @@ -556,7 +559,7 @@ static void test_compact_vlstring() H5File file1(FILENAME, H5F_ACC_TRUNC); // Create dataspace for datasets - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace sid1(SPACE1_RANK, dims1); // Create a datatype to refer to @@ -574,21 +577,23 @@ static void test_compact_vlstring() dataset.write(wdata, vlst); // Read dataset from disk - char *rdata[SPACE1_DIM1]; // Information read in + char *rdata[SPACE1_DIM1]; // Information read in dataset.read(rdata, vlst); // Compare data read in hsize_t i; - for (i=0; i<SPACE1_DIM1; i++) { - if (HDstrlen(wdata[i])!=strlen(rdata[i])) { - TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",(int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i])); + for (i = 0; i < SPACE1_DIM1; i++) { + if (HDstrlen(wdata[i]) != strlen(rdata[i])) { + TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n", + (int)i, (int)strlen(wdata[i]), (int)i, (int)strlen(rdata[i])); continue; } // end if - if (HDstrcmp(wdata[i],rdata[i]) != 0) { - TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",(int)i,wdata[i],(int)i,rdata[i]); + if (HDstrcmp(wdata[i], rdata[i]) != 0) { + TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)i, wdata[i], + (int)i, rdata[i]); continue; } // end if - } // end for + } // end for // Reclaim the read VL data DataSet::vlenReclaim((void *)rdata, vlst, sid1); @@ -604,11 +609,10 @@ static void test_compact_vlstring() } // end try // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_compact_vlstrings()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_compact_vlstrings +} // test_compact_vlstrings /*------------------------------------------------------------------------- * Function: test_vlstring_attribute @@ -623,13 +627,14 @@ static void test_compact_vlstring() *------------------------------------------------------------------------- */ // String for writing to attribute -static char *string_att_write=NULL; +static char *string_att_write = NULL; // Info for a string attribute const H5std_string ATTRSTR_NAME("String_attr"); const H5std_string ATTRSTR_DATA("String Attribute"); -static void test_vlstring_attribute() +static void +test_vlstring_attribute() { // Output message about test being performed SUBTEST("VL String on Attributes"); @@ -645,7 +650,7 @@ static void test_vlstring_attribute() Group root = file1.openGroup("/"); // Create dataspace for the attribute. - DataSpace att_space (H5S_SCALAR); + DataSpace att_space(H5S_SCALAR); // Create an attribute for the root group. Attribute gr_attr = root.createAttribute(ATTRSTR_NAME, vlst, att_space); @@ -656,16 +661,18 @@ static void test_vlstring_attribute() // Read and verify the attribute string as a string of chars. char *string_att_check; gr_attr.read(vlst, &string_att_check); - if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check); + if (HDstrcmp(string_att_check, ATTRSTR_DATA.c_str()) != 0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n", + __LINE__, ATTRSTR_DATA.c_str(), string_att_check); - HDfree(string_att_check); // note: no need for std::string test + HDfree(string_att_check); // note: no need for std::string test // Read and verify the attribute string as an std::string. H5std_string read_str; gr_attr.read(vlst, read_str); if (read_str != ATTRSTR_DATA) - TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str()); + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n", __LINE__, + ATTRSTR_DATA.c_str(), read_str.c_str()); // Close group's attribute. gr_attr.close(); @@ -673,7 +680,7 @@ static void test_vlstring_attribute() // Test creating a "large" sized string attribute gr_attr = root.createAttribute("test_scalar_large", vlst, att_space); - string_att_write = (char*)HDcalloc(8192, sizeof(char)); + string_att_write = (char *)HDcalloc(8192, sizeof(char)); HDmemset(string_att_write, 'A', 8191); // Write data to the attribute, then read it back. @@ -681,8 +688,9 @@ static void test_vlstring_attribute() gr_attr.read(vlst, &string_att_check); // Verify data read. - if(HDstrcmp(string_att_check,string_att_write)!=0) - TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); + if (HDstrcmp(string_att_check, string_att_write) != 0) + TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n", + string_att_write, string_att_check); // Release resources. HDfree(string_att_check); @@ -694,11 +702,10 @@ static void test_vlstring_attribute() } // end try block // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_vlstring_attribute() +} // test_vlstring_attribute() #if 0 /*------------------------------------------------------------------------- @@ -777,11 +784,11 @@ static void test_read_vl_string_attribute() */ const H5std_string ATTRSTRARR_NAME("StringArray_attr"); -static void test_vlstring_array_attribute() +static void +test_vlstring_array_attribute() { - const char *string_att_array[SPACE1_DIM1]= { - "Line 1", "Line 2", "Line 3", "Line 4" - }; // Information to write + const char *string_att_array[SPACE1_DIM1] = {"Line 1", "Line 2", "Line 3", + "Line 4"}; // Information to write // Output message about test being performed SUBTEST("VL String Array on Attributes"); @@ -797,7 +804,7 @@ static void test_vlstring_array_attribute() Group root = file1.openGroup("/"); // Create dataspace for datasets. - hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1}; DataSpace att_space(SPACE1_RANK, dims1); // Create an attribute for the root group. @@ -812,12 +819,12 @@ static void test_vlstring_array_attribute() gr_attr.read(vlst, &string_att_check); hsize_t ii; - for (ii = 0; ii < SPACE1_DIM1; ii++) - { - if(HDstrcmp(string_att_check[ii], string_att_array[ii])!=0) - TestErrPrintf("Line %d: Attribute data different: written=%s,read=%s\n",__LINE__, string_att_check[ii], string_att_check[ii]); + for (ii = 0; ii < SPACE1_DIM1; ii++) { + if (HDstrcmp(string_att_check[ii], string_att_array[ii]) != 0) + TestErrPrintf("Line %d: Attribute data different: written=%s,read=%s\n", __LINE__, + string_att_check[ii], string_att_check[ii]); - HDfree(string_att_check[ii]); // note: no need for std::string test + HDfree(string_att_check[ii]); // note: no need for std::string test } // Close group's attribute. @@ -828,15 +835,14 @@ static void test_vlstring_array_attribute() } // end try block // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vlstring_array_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_vlstring_array_attribute() +} // test_vlstring_array_attribute() /* Helper routine for test_vl_rewrite() */ -static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space, - char *name, char *data) +static void +write_scalar_dset(H5File &file, DataType &type, DataSpace &space, char *name, char *data) { DataSet dset; try { @@ -844,34 +850,34 @@ static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space, dset.write(&data, type, space, space); dset.close(); } // end try - catch (FileIException& ferr) { + catch (FileIException &ferr) { throw; } - catch (DataSetIException& derr) { + catch (DataSetIException &derr) { throw; } } /* Helper routine for test_vl_rewrite() */ -static void read_scalar_dset(H5File& file, DataType& type, DataSpace& space, - char *name, char *data) +static void +read_scalar_dset(H5File &file, DataType &type, DataSpace &space, char *name, char *data) { - char *data_read; + char * data_read; DataSet dset; try { dset = file.openDataSet(name); dset.read(&data_read, type, space, space); dset.close(); - if(HDstrcmp(data, data_read)) + if (HDstrcmp(data, data_read)) TestErrPrintf("Expected %s for dataset %s but read %s\n", data, name, data_read); HDfree(data_read); } // end try - catch (FileIException& ferr) { + catch (FileIException &ferr) { throw; } - catch (DataSetIException& derr) { + catch (DataSetIException &derr) { throw; } } @@ -890,8 +896,9 @@ static void read_scalar_dset(H5File& file, DataType& type, DataSpace& space, *------------------------------------------------------------------------- */ const H5std_string FILENAME2("tvlstr2.h5"); -const int REWRITE_NDATASETS = 32; -static void test_vl_rewrite() +const int REWRITE_NDATASETS = 32; +static void +test_vl_rewrite() { // Output message about test being performed SUBTEST("I/O on VL strings with link/unlink"); @@ -905,37 +912,37 @@ static void test_vl_rewrite() StrType type(0, H5T_VARIABLE); // Create dataspace for the attribute. - DataSpace space (H5S_SCALAR); + DataSpace space(H5S_SCALAR); // Create in file 1. - int i; + int i; char name[256]; // Buffer for names & data - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); write_scalar_dset(file1, type, space, name, name); } // Effectively copy data from file 1 to 2. - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); read_scalar_dset(file1, type, space, name, name); write_scalar_dset(file2, type, space, name, name); } // Read back from file 2. - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); read_scalar_dset(file2, type, space, name, name); } // Remove from file 2. - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); file2.unlink(name); } // Effectively copy from file 1 to file 2. - for (i=0; i<REWRITE_NDATASETS; i++) { + for (i = 0; i < REWRITE_NDATASETS; i++) { sprintf(name, "/set_%d", i); read_scalar_dset(file1, type, space, name, name); write_scalar_dset(file2, type, space, name, name); @@ -951,8 +958,7 @@ static void test_vl_rewrite() } // end try // Catch all exceptions. - catch (Exception& E) - { + catch (Exception &E) { issue_fail_msg("test_vl_rewrite()", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_vl_rewrite() @@ -969,8 +975,8 @@ static void test_vl_rewrite() * *------------------------------------------------------------------------- */ -extern "C" -void test_vlstrings() +extern "C" void +test_vlstrings() { // Output message about test being performed MESSAGE(5, ("Testing Variable-Length Strings")); @@ -992,9 +998,8 @@ void test_vlstrings() // Test writing VL datasets in files with lots of unlinking test_vl_rewrite(); -} // test_vlstrings() +} // test_vlstrings() - /*------------------------------------------------------------------------- * Function: cleanup_vlstrings * @@ -1007,10 +1012,9 @@ void test_vlstrings() * *------------------------------------------------------------------------- */ -extern "C" -void cleanup_vlstrings() +extern "C" void +cleanup_vlstrings() { HDremove(FILENAME.c_str()); HDremove(FILENAME2.c_str()); } - |