Files
logos-protocol/tests/protocol/test_protocol_version.cpp
Dario Lipicar 29afbac532 Extract the Logos protocol layer from logos-cpp-sdk (lp_* C ABI + protocol semver) (#2)
* Extract the Logos protocol layer from logos-cpp-sdk

Transports (plain TCP/TLS, qt_local, qt_remote/QRO, mock), token manager,
consumer core (LogosAPIClient/LogosAPIConsumer incl. the capability
auto-requestModule flow), ModuleProxy, the abstract LogosProviderObject
interface, and the canonical QVariant<->JSON conversion — now behind the
language-neutral lp_* C ABI (logos_protocol.h) carrying the protocol
semver (LOGOS_PROTOCOL_VERSION_*, lp_protocol_version()).

Bytes crossing the ABI use the lossless {"_bytes": base64url} tagging
(NUL-safe), matching the plain wire encoding.

Provider lp_* surface is compiled groundwork; serving lands with module
authoring.

* consumer: typed requestModule for the capability flow

Port of logos-cpp-sdk master f5a127dd ('use updated capability module',
cpp-sdk#85, Iuri Matias) — the touched files (logos_api_client.cpp,
logos_api_consumer.{h,cpp}) moved into this repo in the P1 extraction.
The capability auto-requestModule path now calls a typed std::string
helper on the consumer (which acquires the capability object directly)
instead of a stringly invokeRemoteMethod round-trip. 111/111 tests.
2026-06-12 18:59:01 -03:00

41 lines
1.2 KiB
C++

#include <gtest/gtest.h>
#include "logos_protocol.h"
#include <cstring>
// The protocol version is the single number governing Logos load/call
// compatibility (same MAJOR ⇔ compatible). These tests pin the C ABI
// getters to the header macros so SDKs that forward the linked version
// (instead of minting their own) always agree with logos_protocol.h.
TEST(ProtocolVersion, VersionStringMatchesMacros)
{
const char* v = lp_protocol_version();
ASSERT_NE(v, nullptr);
EXPECT_STREQ(v, LOGOS_PROTOCOL_VERSION_STRING);
char composed[32];
std::snprintf(composed, sizeof(composed), "%d.%d.%d",
LOGOS_PROTOCOL_VERSION_MAJOR,
LOGOS_PROTOCOL_VERSION_MINOR,
LOGOS_PROTOCOL_VERSION_PATCH);
EXPECT_STREQ(v, composed);
}
TEST(ProtocolVersion, AbiMajorMatchesMacro)
{
EXPECT_EQ(lp_protocol_abi_major(), LOGOS_PROTOCOL_VERSION_MAJOR);
}
TEST(ProtocolVersion, VersionStringIsStatic)
{
// Documented as a static string: two calls return the same pointer and
// callers must NOT free it.
EXPECT_EQ(lp_protocol_version(), lp_protocol_version());
}
TEST(ProtocolVersion, StringFreeAcceptsNull)
{
lp_string_free(nullptr); // must be a no-op, not a crash
}