tomato/auto_tests/version_test.c
Green Sky a3126d581b Squashed 'external/toxcore/c-toxcore/' changes from 67badf694..82460b212
82460b212 feat: add ngc events
24b54722a fix: Ensure we have allocators available for the error paths.
48dbcfebc cleanup: Remove redundant `-DSODIUM_EXPORT` from definitions.
0cef46ee9 cleanup: Fix a few more clang-tidy warnings.
0c5b918e9 cleanup: Fix a few more clang-tidy warnings.
4d3c97f49 cleanup: Enforce stricter identifier naming using clang-tidy.
a549807df refactor: Add `mem` module to allow tests to override allocators.
6133fb153 chore: Add devcontainer setup for codespaces.
620e07ecd chore: Set a timeout for tests started using Conan
c0ec33b16 chore: Migrate Windows CI from Appveyor to Azure DevOps
8ed47f3ef fix incorrect documentation
a1e245841 docs: Fix doxygen config and remove some redundant comments.
b0f633185 chore: Fix the Android CI job
7469a529b fix: Add missing `#include <array>`.
2b1a6b0d2 add missing ngc constants getter declarations and definitions
2e02d5637 chore: Add missing module dependencies.
REVERT: 67badf694 feat: add ngc events

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: 82460b2124216af1ac9d63060de310a682a2fd15
2023-10-10 19:37:39 +02:00

97 lines
2.8 KiB
C

#include "../toxcore/tox.h"
#include "check_compat.h"
#define CHECK(major, minor, patch, expected) \
do_check(TOX_VERSION_MAJOR, TOX_VERSION_MINOR, TOX_VERSION_PATCH, \
major, minor, patch, \
TOX_VERSION_IS_API_COMPATIBLE(major, minor, patch), expected)
static void do_check(int lib_major, int lib_minor, int lib_patch,
int cli_major, int cli_minor, int cli_patch,
bool actual, bool expected)
{
ck_assert_msg(actual == expected,
"Client version %d.%d.%d is%s compatible with library version %d.%d.%d, but it should%s be\n",
cli_major, cli_minor, cli_patch, actual ? "" : " not",
lib_major, lib_minor, lib_patch, expected ? "" : " not");
}
#undef TOX_VERSION_MAJOR
#undef TOX_VERSION_MINOR
#undef TOX_VERSION_PATCH
int main(void)
{
#define TOX_VERSION_MAJOR 0
#define TOX_VERSION_MINOR 0
#define TOX_VERSION_PATCH 4
// Tox versions from 0.0.* are only compatible with themselves.
CHECK(0, 0, 0, false);
CHECK(0, 0, 3, false);
CHECK(0, 0, 4, true);
CHECK(0, 0, 5, false);
CHECK(1, 0, 4, false);
#undef TOX_VERSION_MAJOR
#undef TOX_VERSION_MINOR
#undef TOX_VERSION_PATCH
#define TOX_VERSION_MAJOR 0
#define TOX_VERSION_MINOR 1
#define TOX_VERSION_PATCH 4
// Tox versions from 0.1.* are only compatible with themselves or 0.1.<*
CHECK(0, 0, 0, false);
CHECK(0, 0, 4, false);
CHECK(0, 0, 5, false);
CHECK(0, 1, 0, true);
CHECK(0, 1, 4, true);
CHECK(0, 1, 5, false);
CHECK(0, 2, 0, false);
CHECK(0, 2, 4, false);
CHECK(0, 2, 5, false);
CHECK(1, 0, 0, false);
CHECK(1, 0, 4, false);
CHECK(1, 0, 5, false);
CHECK(1, 1, 4, false);
#undef TOX_VERSION_MAJOR
#undef TOX_VERSION_MINOR
#undef TOX_VERSION_PATCH
#define TOX_VERSION_MAJOR 1
#define TOX_VERSION_MINOR 0
#define TOX_VERSION_PATCH 4
// Beyond 0.*.* Tox is comfortable with any lower version within their major
CHECK(0, 0, 4, false);
CHECK(1, 0, 0, true);
CHECK(1, 0, 1, true);
CHECK(1, 0, 4, true);
CHECK(1, 0, 5, false);
CHECK(1, 1, 0, false);
CHECK(2, 0, 0, false);
CHECK(2, 0, 4, false);
#undef TOX_VERSION_MAJOR
#undef TOX_VERSION_MINOR
#undef TOX_VERSION_PATCH
#define TOX_VERSION_MAJOR 1
#define TOX_VERSION_MINOR 1
#define TOX_VERSION_PATCH 4
CHECK(0, 0, 4, false);
CHECK(1, 0, 0, true);
CHECK(1, 0, 4, true);
CHECK(1, 0, 5, true);
CHECK(1, 1, 0, true);
CHECK(1, 1, 1, true);
CHECK(1, 1, 4, true);
CHECK(1, 1, 5, false);
CHECK(1, 2, 0, false);
CHECK(1, 2, 4, false);
CHECK(1, 2, 5, false);
CHECK(2, 0, 0, false);
CHECK(2, 1, 4, false);
#undef TOX_VERSION_MAJOR
#undef TOX_VERSION_MINOR
#undef TOX_VERSION_PATCH
return 0;
}