summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2011-03-02 20:44:44 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2011-03-02 20:44:44 (GMT)
commita0f4d6d40c2679879291a44de62a7117e3d03a81 (patch)
tree50ad2a220432bbe7de8dd04f241be5c9448414cf
parentf62a87c45b1e01a424a37e0f1d8f8f1907c92aa1 (diff)
downloadhdf5-a0f4d6d40c2679879291a44de62a7117e3d03a81.zip
hdf5-a0f4d6d40c2679879291a44de62a7117e3d03a81.tar.gz
hdf5-a0f4d6d40c2679879291a44de62a7117e3d03a81.tar.bz2
[svn-r20180] I added 2 public macros to the H5public.h - H5_VERSION_GE and H5_VERSION_LE - and put some test cases in tfile.c.
Tested on jam, heiwa, and amani.
-rw-r--r--src/H5public.h11
-rw-r--r--test/tfile.c49
2 files changed, 60 insertions, 0 deletions
diff --git a/src/H5public.h b/src/H5public.h
index 1f835f7..0a3b072 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -83,6 +83,17 @@ extern "C" {
#define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \
H5_VERS_RELEASE)
+/* macros for comparing the version */
+#define H5_VERSION_GE(Maj,Min,Rel) \
+ (((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR==Min) && (H5_VERS_RELEASE>=Rel)) || \
+ ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR>Min)) || \
+ (H5_VERS_MAJOR>Maj))
+
+#define H5_VERSION_LE(Maj,Min,Rel) \
+ (((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR==Min) && (H5_VERS_RELEASE<=Rel)) || \
+ ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR<Min)) || \
+ (H5_VERS_MAJOR<Maj))
+
/*
* Status return values. Failed integer functions in HDF5 result almost
* always in a negative value (unsigned failing functions sometimes return
diff --git a/test/tfile.c b/test/tfile.c
index 7939491..89cc2bd 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -3114,6 +3114,54 @@ test_libver_bounds(void)
/****************************************************************
**
+** test_libver_macros():
+** Verify that H5_VERSION_GE and H5_VERSION_LE work correactly.
+**
+****************************************************************/
+static void
+test_libver_macros(void)
+{
+ unsigned major = H5_VERS_MAJOR;
+ unsigned minor = H5_VERS_MINOR;
+ unsigned release = H5_VERS_RELEASE;
+ herr_t ret; /* Return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing macros for library version comparison\n"));
+
+ VERIFY(H5_VERSION_GE(major,minor,release), TRUE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major-1,minor,release), TRUE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major-1,minor+1,release), TRUE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major-1,minor,release+1), TRUE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major,minor-1,release), TRUE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major,minor-1,release+1), TRUE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major,minor,release-1), TRUE, "H5_VERSION_GE");
+
+ VERIFY(H5_VERSION_GE(major+1,minor,release), FALSE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major+1,minor-1,release), FALSE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major+1,minor-1,release-1), FALSE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major,minor+1,release), FALSE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major,minor+1,release-1), FALSE, "H5_VERSION_GE");
+ VERIFY(H5_VERSION_GE(major,minor,release+1), FALSE, "H5_VERSION_GE");
+
+ VERIFY(H5_VERSION_LE(major,minor,release), TRUE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major+1,minor,release), TRUE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major+1,minor-1,release), TRUE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major+1,minor-1,release-1), TRUE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major,minor+1,release), TRUE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major,minor+1,release-1), TRUE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major,minor,release+1), TRUE, "H5_VERSION_LE");
+
+ VERIFY(H5_VERSION_LE(major-1,minor,release), FALSE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major-1,minor+1,release), FALSE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major-1,minor+1,release+1), FALSE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major,minor-1,release), FALSE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major,minor-1,release+1), FALSE, "H5_VERSION_LE");
+ VERIFY(H5_VERSION_LE(major,minor,release-1), FALSE, "H5_VERSION_LE");
+} /* test_libver_macros() */
+
+/****************************************************************
+**
** test_deprec():
** Test deprecated functionality.
**
@@ -3292,6 +3340,7 @@ test_file(void)
test_filespace_info(); /* Test file creation public routines:H5Pget/set_file_space */
test_filespace_compatible();/* Test compatibility for file space management */
test_libver_bounds(); /* Test compatibility for file space management */
+ test_libver_macros(); /* Test the macros for library version comparison */
#ifndef H5_NO_DEPRECATED_SYMBOLS
test_deprec(); /* Test deprecated routines */
#endif /* H5_NO_DEPRECATED_SYMBOLS */