2019-03-09 01:57:59 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Sean Bright <sean.bright@gmail.com>
|
|
|
|
*
|
|
|
|
* Jansson is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the MIT license. See LICENSE for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "util.h"
|
2019-10-17 14:08:51 +08:00
|
|
|
#include <jansson.h>
|
|
|
|
#include <string.h>
|
2019-03-09 01:57:59 +08:00
|
|
|
|
2019-10-17 14:08:51 +08:00
|
|
|
static void test_version_str(void) {
|
2019-03-09 01:57:59 +08:00
|
|
|
if (strcmp(jansson_version_str(), JANSSON_VERSION)) {
|
|
|
|
fail("jansson_version_str returned invalid version string");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-17 14:08:51 +08:00
|
|
|
static void test_version_cmp() {
|
|
|
|
if (jansson_version_cmp(JANSSON_MAJOR_VERSION, JANSSON_MINOR_VERSION,
|
|
|
|
JANSSON_MICRO_VERSION)) {
|
2019-03-09 01:57:59 +08:00
|
|
|
fail("jansson_version_cmp equality check failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jansson_version_cmp(JANSSON_MAJOR_VERSION - 1, 0, 0) <= 0) {
|
|
|
|
fail("jansson_version_cmp less than check failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (JANSSON_MINOR_VERSION) {
|
2019-10-20 01:35:28 +08:00
|
|
|
if (jansson_version_cmp(JANSSON_MAJOR_VERSION, JANSSON_MINOR_VERSION - 1,
|
2019-10-17 14:08:51 +08:00
|
|
|
JANSSON_MICRO_VERSION) <= 0) {
|
2019-03-09 01:57:59 +08:00
|
|
|
fail("jansson_version_cmp less than check failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (JANSSON_MICRO_VERSION) {
|
2019-10-17 14:08:51 +08:00
|
|
|
if (jansson_version_cmp(JANSSON_MAJOR_VERSION, JANSSON_MINOR_VERSION,
|
|
|
|
JANSSON_MICRO_VERSION - 1) <= 0) {
|
2019-03-09 01:57:59 +08:00
|
|
|
fail("jansson_version_cmp less than check failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-17 14:08:51 +08:00
|
|
|
if (jansson_version_cmp(JANSSON_MAJOR_VERSION + 1, JANSSON_MINOR_VERSION,
|
|
|
|
JANSSON_MICRO_VERSION) >= 0) {
|
2019-03-09 01:57:59 +08:00
|
|
|
fail("jansson_version_cmp greater than check failed");
|
|
|
|
}
|
|
|
|
|
2019-10-17 14:08:51 +08:00
|
|
|
if (jansson_version_cmp(JANSSON_MAJOR_VERSION, JANSSON_MINOR_VERSION + 1,
|
|
|
|
JANSSON_MICRO_VERSION) >= 0) {
|
2019-03-09 01:57:59 +08:00
|
|
|
fail("jansson_version_cmp greater than check failed");
|
|
|
|
}
|
|
|
|
|
2019-10-17 14:08:51 +08:00
|
|
|
if (jansson_version_cmp(JANSSON_MAJOR_VERSION, JANSSON_MINOR_VERSION,
|
|
|
|
JANSSON_MICRO_VERSION + 1) >= 0) {
|
2019-03-09 01:57:59 +08:00
|
|
|
fail("jansson_version_cmp greater than check failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-17 14:08:51 +08:00
|
|
|
static void run_tests() {
|
2019-03-09 01:57:59 +08:00
|
|
|
test_version_str();
|
|
|
|
test_version_cmp();
|
|
|
|
}
|