From 57ebf3b3238a165c1973ecdf96ba79f95d650fc9 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Thu, 15 Oct 2026 12:29:25 +0300 Subject: Add soversion, version macros, and reserved term_options words The shared library now carries its major version in the SONAME (libterm.so.0), so an ABI break gets a new file name. The header gains TERM_VERSION, TERM_VERSION_MAJOR/MINOR/PATCH and TERM_VERSION_CODE, and term_version() returns the code the library was built with. A test checks the macros against meson.build's project version and against the runtime value. term_options ends with uint32_t reserved[8]. term_new() returns NULL if a word is nonzero, so later versions can give those words a meaning without misreading a caller's leftover data. All-zero options stay valid. Co-Authored-By: Claude Haiku 5.5 --- tests/version_test.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/version_test.c (limited to 'tests/version_test.c') diff --git a/tests/version_test.c b/tests/version_test.c new file mode 100644 index 0000000..0eb889e --- /dev/null +++ b/tests/version_test.c @@ -0,0 +1,27 @@ +#include "term/term.h" + +#include +#include +#include + +/* The project version from meson.build. The build defines it. */ +#ifndef TERM_TEST_PROJECT_VERSION +#error "define TERM_TEST_PROJECT_VERSION as the project version, such as \"0.1.0\"" +#endif + +int main(void) +{ + char text[32]; + snprintf(text, sizeof(text), "%d.%d.%d", + TERM_VERSION_MAJOR, TERM_VERSION_MINOR, TERM_VERSION_PATCH); + assert(!strcmp(text, TERM_TEST_PROJECT_VERSION)); + + int major, minor, patch; + assert(sscanf(TERM_TEST_PROJECT_VERSION, "%d.%d.%d", &major, &minor, &patch) == 3); + assert(TERM_VERSION_CODE == TERM_VERSION(major, minor, patch)); + assert(term_version() == TERM_VERSION_CODE); + + assert(TERM_VERSION(0, 2, 0) > TERM_VERSION(0, 1, 255)); + assert(TERM_VERSION(1, 0, 0) > TERM_VERSION(0, 255, 255)); + return 0; +} -- cgit v1.2.3