diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2015-01-23 17:04:14 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2015-01-23 17:23:35 +0100 |
commit | 3248801a925449644071671dcd85e370303071b4 (patch) | |
tree | daf4bd900de49effe12e035f924e517d9716cd96 /api_test/main.c | |
parent | 96a4e04522584aab4ea1fe444f971bec935abc8a (diff) |
Improve version information
Add version number and string as macros and symbols. Version numbers can
be easily compared, for example in the C preprocessor:
#include <cmark.h>
#if CMARK_VERSION < 0x020200
#error Requires libcmark 2.2.0 or higher
#endif
Storing the version in a global variable allows to check the library
version at runtime. For example:
if (CMARK_VERSION != cmark_version) {
warn("Compiled against libcmark %s, but using %s",
CMARK_VERSION_STRING, cmark_version_string);
}
The version should be updated whenever the public API is changed.
Diffstat (limited to 'api_test/main.c')
-rw-r--r-- | api_test/main.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/api_test/main.c b/api_test/main.c index af40a9f..d341246 100644 --- a/api_test/main.c +++ b/api_test/main.c @@ -53,6 +53,14 @@ static void test_continuation_byte(test_batch_runner *runner, const char *utf8); static void +version(test_batch_runner *runner) +{ + INT_EQ(runner, cmark_version, CMARK_VERSION, "cmark_version"); + STR_EQ(runner, cmark_version_string, CMARK_VERSION_STRING, + "cmark_version_string"); +} + +static void constructor(test_batch_runner *runner) { for (int i = 0; i < num_node_types; ++i) { @@ -666,6 +674,7 @@ int main() { int retval; test_batch_runner *runner = test_batch_runner_new(); + version(runner); constructor(runner); accessors(runner); node_check(runner); |