summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 */