From 32744cae8a9131f7ea7d6b967160c0607edb7f00 Mon Sep 17 00:00:00 2001 From: wellwei <96378453+wellwei@users.noreply.github.com> Date: Sun, 23 Aug 2026 02:45:24 +0800 Subject: [PATCH] feat(pkg): compat.boost-{config,assert,throw-exception,type-traits,uuid} 1.92.0 + compat.jwt-cpp 0.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit modular-boost 拆包路线(vcpkg 同构):每个 boostorg/ 从自己的 boost-1.92.0 tag 打独立小包,不引单体 tarball。头文件包含闭包经逐文件 grep 核实:uuid 仅依 赖 config/assert/throw_exception/type_traits 四个头库,五包交付集两两不相交, 升级时整列车一起动版本。 - 传统 #include 消费(Shape B 头文件+锚点),不做模块包装;language=c++20 - jwt-cpp(Thalhammer/jwt-cpp,v0.7.2)无条件依赖 compat.openssl 3.5.1, 链接标志由 openssl 包自带并传递;JSON 后端用捆绑 picojson 默认 - 六个消费者测试成员(mcpp.toml 注册),真断言:版本列车/BOOST_VERIFY 语义/ 异常传播/trait 答案/UUID RFC4122 形状与 SHA1 名字生成器/JWT HS256 实签实验签 - 本地 macOS 冷缓存全绿:lint 五连 + pinned mcpp 2026.8.10.3 xpkg parse + 六成员 mcpp test;linux gcc 腿的 -latomic 预案已记录在 uuid 描述符注释 - CN 镜像暂缺,纯上游 URL(boost-ext.ut 先例) --- mcpp.toml | 6 ++ pkgs/c/compat.boost-assert.lua | 56 +++++++++++++ pkgs/c/compat.boost-config.lua | 78 +++++++++++++++++++ pkgs/c/compat.boost-throw-exception.lua | 58 ++++++++++++++ pkgs/c/compat.boost-type-traits.lua | 57 ++++++++++++++ pkgs/c/compat.boost-uuid.lua | 73 +++++++++++++++++ pkgs/c/compat.jwt-cpp.lua | 76 ++++++++++++++++++ tests/examples/boost-assert/mcpp.toml | 8 ++ tests/examples/boost-assert/tests/assert.cpp | 21 +++++ tests/examples/boost-config/mcpp.toml | 10 +++ tests/examples/boost-config/tests/config.cpp | 26 +++++++ .../examples/boost-throw-exception/mcpp.toml | 8 ++ .../tests/throw_exception.cpp | 15 ++++ tests/examples/boost-type-traits/mcpp.toml | 8 ++ .../boost-type-traits/tests/type_traits.cpp | 18 +++++ tests/examples/boost-uuid/mcpp.toml | 9 +++ tests/examples/boost-uuid/tests/uuid.cpp | 48 ++++++++++++ tests/examples/jwt-cpp/mcpp.toml | 9 +++ tests/examples/jwt-cpp/tests/jwt.cpp | 49 ++++++++++++ 19 files changed, 633 insertions(+) create mode 100644 pkgs/c/compat.boost-assert.lua create mode 100644 pkgs/c/compat.boost-config.lua create mode 100644 pkgs/c/compat.boost-throw-exception.lua create mode 100644 pkgs/c/compat.boost-type-traits.lua create mode 100644 pkgs/c/compat.boost-uuid.lua create mode 100644 pkgs/c/compat.jwt-cpp.lua create mode 100644 tests/examples/boost-assert/mcpp.toml create mode 100644 tests/examples/boost-assert/tests/assert.cpp create mode 100644 tests/examples/boost-config/mcpp.toml create mode 100644 tests/examples/boost-config/tests/config.cpp create mode 100644 tests/examples/boost-throw-exception/mcpp.toml create mode 100644 tests/examples/boost-throw-exception/tests/throw_exception.cpp create mode 100644 tests/examples/boost-type-traits/mcpp.toml create mode 100644 tests/examples/boost-type-traits/tests/type_traits.cpp create mode 100644 tests/examples/boost-uuid/mcpp.toml create mode 100644 tests/examples/boost-uuid/tests/uuid.cpp create mode 100644 tests/examples/jwt-cpp/mcpp.toml create mode 100644 tests/examples/jwt-cpp/tests/jwt.cpp diff --git a/mcpp.toml b/mcpp.toml index 5ca32be..09746e1 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -11,7 +11,12 @@ members = [ "tests/examples/archive", "tests/examples/asio-module", "tests/examples/asio-ssl", + "tests/examples/boost-assert", + "tests/examples/boost-config", "tests/examples/boost-ext.ut", + "tests/examples/boost-throw-exception", + "tests/examples/boost-type-traits", + "tests/examples/boost-uuid", "tests/examples/build-mcpp", "tests/examples/c-ares", "tests/examples/catch2", @@ -46,6 +51,7 @@ members = [ "tests/examples/imgui", "tests/examples/imgui-module", "tests/examples/imgui-window", + "tests/examples/jwt-cpp", "tests/examples/marzer.tomlplusplus", "tests/examples/libmysqlclient", "tests/examples/mysql-connector-cpp", diff --git a/pkgs/c/compat.boost-assert.lua b/pkgs/c/compat.boost-assert.lua new file mode 100644 index 0000000..405b244 --- /dev/null +++ b/pkgs/c/compat.boost-assert.lua @@ -0,0 +1,56 @@ +-- Form B inline descriptor for Boost.Assert 1.92.0 — BOOST_ASSERT / +-- BOOST_VERIFY / BOOST_CURRENT_LOCATION / boost::source_location. +-- Part of the modular-boost header family; see compat.boost-config for the +-- family wiring and version-train policy (all five packages move together). +-- +-- Header references: assert's own tree includes boost/config.hpp and +-- boost/cstdint.hpp, both shipped by compat.boost-config — hence the single +-- dep. Nothing else crosses the family boundary (verified by grep, matching +-- upstream CMakeLists' INTERFACE line: Boost::config only). +-- +-- Header-only, traditional `#include` consumption; no CN mirror yet (plain +-- upstream URL, like boost-ext.ut); BSL-1.0. +package = { + spec = "1", + namespace = "compat", + name = "boost-assert", + description = "Boost.Assert 1.92.0 — configurable assert macros with source-location support", + licenses = {"BSL-1.0"}, + repo = "https://github.com/boostorg/assert", + type = "package", + + xpm = { + linux = { + ["1.92.0"] = { + url = "https://github.com/boostorg/assert/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "8d49fc69df12e8fbc0e7fe3c4ede45044747199ccdeaf66c2aebb146becc54aa", + }, + }, + macosx = { + ["1.92.0"] = { + url = "https://github.com/boostorg/assert/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "8d49fc69df12e8fbc0e7fe3c4ede45044747199ccdeaf66c2aebb146becc54aa", + }, + }, + windows = { + ["1.92.0"] = { + url = "https://github.com/boostorg/assert/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "8d49fc69df12e8fbc0e7fe3c4ede45044747199ccdeaf66c2aebb146becc54aa", + }, + }, + }, + + mcpp = { + language = "c++20", + import_std = false, + include_dirs = { "*/include" }, -- exposes boost/assert.hpp + friends + generated_files = { + ["mcpp_generated/boost_assert_anchor.cpp"] = [==[ +int mcpp_compat_boost_assert_anchor(void) { return 0; } +]==], + }, + sources = { "mcpp_generated/boost_assert_anchor.cpp" }, + targets = { ["boost_assert"] = { kind = "lib" } }, + deps = { ["compat.boost-config"] = "1.92.0" }, + }, +} diff --git a/pkgs/c/compat.boost-config.lua b/pkgs/c/compat.boost-config.lua new file mode 100644 index 0000000..70dd66e --- /dev/null +++ b/pkgs/c/compat.boost-config.lua @@ -0,0 +1,78 @@ +-- Form B inline descriptor for Boost.Config 1.92.0 — the root of this index's +-- modular-boost header family. Each boostorg/ repository is packaged from +-- its OWN release-train tag (`boost-1.92.0`) instead of the ~224 MiB monolith, +-- mirroring how vcpkg splits Boost into per-library ports: consumers download +-- exactly the closure they use (Config alone is ~300 KiB of archives). +-- +-- Family wiring (verified by grepping every `` include across each +-- package's include tree AND cross-checked against each repo's CMakeLists +-- INTERFACE link line): +-- config -> (nothing) +-- assert -> config +-- type-traits -> config +-- throw-exception -> assert, config +-- uuid -> all four above +-- The five shipped header sets are pairwise disjoint, so five `*/include` +-- include roots union into one coherent `boost/` tree with no collisions. +-- Upgrades move the WHOLE train together (every boostorg repo tags the same +-- release); partial trains are untested territory. +-- +-- Header-only, traditional `#include` consumption only — no module unit here. +-- Upstream ships none for Config, and this family deliberately stays on the +-- textual path (see compat.jwt-cpp / tests/examples/boost-*). +-- +-- No CN mirror yet: plain-string upstream URL, like boost-ext.ut. Consumers in +-- CN fall back to the GLOBAL source until a maintainer backfills gitcode. +-- +-- License: Boost Software License 1.0 (BSL-1.0), file LICENSE_1_0.txt. +package = { + spec = "1", + namespace = "compat", + name = "boost-config", + description = "Boost.Config 1.92.0 — platform/compiler/stdlib detection macros; root of the modular-boost header family", + licenses = {"BSL-1.0"}, + repo = "https://github.com/boostorg/config", + type = "package", + + xpm = { + linux = { + ["1.92.0"] = { + url = "https://github.com/boostorg/config/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "b4171037f13373203ba79cbc141d612982052283e696a315185ab5bea46102a0", + }, + }, + macosx = { + ["1.92.0"] = { + url = "https://github.com/boostorg/config/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "b4171037f13373203ba79cbc141d612982052283e696a315185ab5bea46102a0", + }, + }, + windows = { + ["1.92.0"] = { + url = "https://github.com/boostorg/config/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "b4171037f13373203ba79cbc141d612982052283e696a315185ab5bea46102a0", + }, + }, + }, + + mcpp = { + language = "c++20", + import_std = false, + -- Exposes `boost/` (config.hpp, version.hpp, detail/, no_tr1/, ...) so + -- consumers write `#include `. This package also owns + -- the family's shared oddments that live outside boost/config/: the + -- historical boost/cstdint.hpp, boost/limits.hpp, boost/static_assert.hpp, + -- boost/detail/workaround.hpp — and boost/version.hpp, which downstream + -- members assert against. + include_dirs = { "*/include" }, + -- Header-only: a trivial anchor TU gives mcpp a buildable lib target. + generated_files = { + ["mcpp_generated/boost_config_anchor.cpp"] = [==[ +int mcpp_compat_boost_config_anchor(void) { return 0; } +]==], + }, + sources = { "mcpp_generated/boost_config_anchor.cpp" }, + targets = { ["boost_config"] = { kind = "lib" } }, + deps = { }, + }, +} diff --git a/pkgs/c/compat.boost-throw-exception.lua b/pkgs/c/compat.boost-throw-exception.lua new file mode 100644 index 0000000..ca038c3 --- /dev/null +++ b/pkgs/c/compat.boost-throw-exception.lua @@ -0,0 +1,58 @@ +-- Form B inline descriptor for Boost.ThrowException 1.92.0 — +-- BOOST_THROW_EXCEPTION and boost::throw_exception, the family's uniform +-- "raise a std::exception-derived error" path. +-- Part of the modular-boost header family; see compat.boost-config for the +-- family wiring and version-train policy. +-- +-- Header references: throw_exception includes boost/assert/ (compat.boost-assert) +-- and boost/config/ (compat.boost-config); boost/exception/exception.hpp is its +-- own. Matches upstream CMakeLists' INTERFACE line: Boost::assert + Boost::config. +-- +-- Header-only, traditional `#include` consumption; no CN mirror yet; BSL-1.0. +package = { + spec = "1", + namespace = "compat", + name = "boost-throw-exception", + description = "Boost.ThrowException 1.92.0 — common exception-raising infrastructure for Boost libraries", + licenses = {"BSL-1.0"}, + repo = "https://github.com/boostorg/throw_exception", + type = "package", + + xpm = { + linux = { + ["1.92.0"] = { + url = "https://github.com/boostorg/throw_exception/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "1ddbb967a43504e28bbe2a35a010df9f7ff5d1a49d3678c9fdfc035fd32ce005", + }, + }, + macosx = { + ["1.92.0"] = { + url = "https://github.com/boostorg/throw_exception/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "1ddbb967a43504e28bbe2a35a010df9f7ff5d1a49d3678c9fdfc035fd32ce005", + }, + }, + windows = { + ["1.92.0"] = { + url = "https://github.com/boostorg/throw_exception/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "1ddbb967a43504e28bbe2a35a010df9f7ff5d1a49d3678c9fdfc035fd32ce005", + }, + }, + }, + + mcpp = { + language = "c++20", + import_std = false, + include_dirs = { "*/include" }, -- exposes boost/throw_exception.hpp + generated_files = { + ["mcpp_generated/boost_throw_exception_anchor.cpp"] = [==[ +int mcpp_compat_boost_throw_exception_anchor(void) { return 0; } +]==], + }, + sources = { "mcpp_generated/boost_throw_exception_anchor.cpp" }, + targets = { ["boost_throw_exception"] = { kind = "lib" } }, + deps = { + ["compat.boost-assert"] = "1.92.0", + ["compat.boost-config"] = "1.92.0", + }, + }, +} diff --git a/pkgs/c/compat.boost-type-traits.lua b/pkgs/c/compat.boost-type-traits.lua new file mode 100644 index 0000000..ed6aca6 --- /dev/null +++ b/pkgs/c/compat.boost-type-traits.lua @@ -0,0 +1,57 @@ +-- Form B inline descriptor for Boost.TypeTraits 1.92.0 — the is_same / +-- add_pointer / remove_cv / integral_constant family (the C++03-era trait +-- toolkit; modern code usually reaches for std:: traits, but Boost headers +-- still lean on these). +-- Part of the modular-boost header family; see compat.boost-config for the +-- family wiring and version-train policy. +-- +-- Header references: type_traits includes boost/config/, boost/detail/ +-- workarounds, boost/static_assert.hpp and boost/version.hpp — all shipped by +-- compat.boost-config. Matches upstream CMakeLists' INTERFACE line: +-- Boost::config + Boost::type_traits's own tree. +-- +-- Header-only, traditional `#include` consumption; no CN mirror yet; BSL-1.0. +package = { + spec = "1", + namespace = "compat", + name = "boost-type-traits", + description = "Boost.TypeTraits 1.92.0 — compile-time type introspection traits", + licenses = {"BSL-1.0"}, + repo = "https://github.com/boostorg/type_traits", + type = "package", + + xpm = { + linux = { + ["1.92.0"] = { + url = "https://github.com/boostorg/type_traits/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "ee6c4d3d993f9138d9a77c57c3d91111aafed79add4f09f4e0a7effcfcdc0cae", + }, + }, + macosx = { + ["1.92.0"] = { + url = "https://github.com/boostorg/type_traits/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "ee6c4d3d993f9138d9a77c57c3d91111aafed79add4f09f4e0a7effcfcdc0cae", + }, + }, + windows = { + ["1.92.0"] = { + url = "https://github.com/boostorg/type_traits/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "ee6c4d3d993f9138d9a77c57c3d91111aafed79add4f09f4e0a7effcfcdc0cae", + }, + }, + }, + + mcpp = { + language = "c++20", + import_std = false, + include_dirs = { "*/include" }, -- exposes boost/type_traits/* + generated_files = { + ["mcpp_generated/boost_type_traits_anchor.cpp"] = [==[ +int mcpp_compat_boost_type_traits_anchor(void) { return 0; } +]==], + }, + sources = { "mcpp_generated/boost_type_traits_anchor.cpp" }, + targets = { ["boost_type_traits"] = { kind = "lib" } }, + deps = { ["compat.boost-config"] = "1.92.0" }, + }, +} diff --git a/pkgs/c/compat.boost-uuid.lua b/pkgs/c/compat.boost-uuid.lua new file mode 100644 index 0000000..c7550d0 --- /dev/null +++ b/pkgs/c/compat.boost-uuid.lua @@ -0,0 +1,73 @@ +-- Form B inline descriptor for Boost.UUID 1.92.0 — RFC 4122/9562 UUIDs: +-- random (v4), name (SHA1/MD5 v5), time (v1/v6/v7) generators, string +-- round-trip, std::hash. Header-only since forever — the historical +-- src/sha1.cpp is long gone; sha1/md5/chacha20 live inline under detail/. +-- Part of the modular-boost header family; see compat.boost-config for the +-- family wiring and version-train policy. +-- +-- Header references (verified by grep across the include tree, matching +-- upstream CMakeLists' INTERFACE line): boost/assert, boost/config, +-- boost/throw_exception, boost/type_traits — all packaged in this index as +-- compat.boost-{assert,config,throw-exception,type-traits}; everything else +-- stays inside boost/uuid/. The closure is exactly these four deps. +-- +-- One upstream CMake wrinkle deliberately NOT carried over: +-- BOOST_UUID_LINK_LIBATOMIC adds -latomic as an INTERFACE link requirement on +-- GCC / non-Windows non-Apple Clang for the uint128 paths. Our consumer test +-- exercises the standard v4/name/string surface without it; add a linux +-- ldflags entry here only if a future member actually links 128-bit paths. +-- +-- SIMD dispatch (SSE2..AVX10 via uuid_x86/generic .ipp) is auto-detected from +-- compiler/arch macros — no flags needed; BOOST_UUID_NO_SIMD is the escape +-- hatch if a toolchain ever misreports. +-- +-- Header-only, traditional `#include` consumption; no CN mirror yet; BSL-1.0. +package = { + spec = "1", + namespace = "compat", + name = "boost-uuid", + description = "Boost.UUID 1.92.0 — RFC 4122/9562 UUID generation and parsing", + licenses = {"BSL-1.0"}, + repo = "https://github.com/boostorg/uuid", + type = "package", + + xpm = { + linux = { + ["1.92.0"] = { + url = "https://github.com/boostorg/uuid/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "a5fca6d0499b7e47e7bbdf59afb1aaf6876d7788b27c3c6b2bbacfc795234e35", + }, + }, + macosx = { + ["1.92.0"] = { + url = "https://github.com/boostorg/uuid/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "a5fca6d0499b7e47e7bbdf59afb1aaf6876d7788b27c3c6b2bbacfc795234e35", + }, + }, + windows = { + ["1.92.0"] = { + url = "https://github.com/boostorg/uuid/archive/refs/tags/boost-1.92.0.tar.gz", + sha256 = "a5fca6d0499b7e47e7bbdf59afb1aaf6876d7788b27c3c6b2bbacfc795234e35", + }, + }, + }, + + mcpp = { + language = "c++20", + import_std = false, + include_dirs = { "*/include" }, -- exposes boost/uuid/* (+ boost/uuid.hpp shim) + generated_files = { + ["mcpp_generated/boost_uuid_anchor.cpp"] = [==[ +int mcpp_compat_boost_uuid_anchor(void) { return 0; } +]==], + }, + sources = { "mcpp_generated/boost_uuid_anchor.cpp" }, + targets = { ["boost_uuid"] = { kind = "lib" } }, + deps = { + ["compat.boost-assert"] = "1.92.0", + ["compat.boost-config"] = "1.92.0", + ["compat.boost-throw-exception"] = "1.92.0", + ["compat.boost-type-traits"] = "1.92.0", + }, + }, +} diff --git a/pkgs/c/compat.jwt-cpp.lua b/pkgs/c/compat.jwt-cpp.lua new file mode 100644 index 0000000..dbe2c4a --- /dev/null +++ b/pkgs/c/compat.jwt-cpp.lua @@ -0,0 +1,76 @@ +-- Form B inline descriptor for jwt-cpp 0.7.2 (Thalhammer/jwt-cpp) — header-only +-- JSON Web Token creation/verification. Traditional `#include ` +-- consumption; upstream ships no module unit (its modules work is an open, +-- unmerged PR), and this package deliberately stays on the textual path. +-- +-- Identity: the canonical repo is Thalhammer/jwt-cpp — NOT "jwt-cpp/jwt-cpp" +-- (no such org exists) and NOT prince-chrismc/jwt-cpp (a fork). Version 0.7.2 +-- is the latest stable release (2026-02-09); the archive is the codeload +-- auto-tarball, whose top dir `jwt-cpp-0.7.2/` the `*` glob absorbs. +-- +-- OpenSSL is an UNCONDITIONAL compile-time dependency: jwt.h includes +-- outside any feature guard (including ssl.h, even though only +-- libcrypto APIs are called — upstream's CMake target links OpenSSL::SSL + +-- OpenSSL::Crypto both). compat.openssl 3.5.1 provides headers AND carries the +-- per-platform link flags itself; they propagate to consumers, so this +-- descriptor adds no ldflags of its own. Windows support in compat.openssl is +-- evidenced by merged #211 + the asio-ssl member's real-TLS test. +-- +-- JSON backend: the bundled picojson snapshot under include/picojson/ is used +-- (upstream default; jwt.h force-defines PICOJSON_USE_INT64 before including +-- it). The official nlohmann traits path (`JWT_DISABLE_PICOJSON` + +-- traits/nlohmann-json/defaults.h) can become a feature later if a consumer +-- needs it — deliberately not wired now to keep the dep closure single-namespace. +-- +-- Known upstream quirk: on Windows, including before numeric_limits +-- uses trips MIN/MAX macros (upstream FAQ) — consumers define NOMINMAX as +-- usual; nothing package-side needed for code that doesn't mix the two. +-- +-- No CN mirror yet: plain-string upstream URL, like boost-ext.ut. +-- License: MIT (Copyright (c) 2018 Dominik Thalhammer). +package = { + spec = "1", + namespace = "compat", + name = "jwt-cpp", + description = "jwt-cpp 0.7.2 — header-only JSON Web Token (JWT) library for C++, backed by OpenSSL", + licenses = {"MIT"}, + repo = "https://github.com/Thalhammer/jwt-cpp", + type = "package", + + xpm = { + linux = { + ["0.7.2"] = { + url = "https://github.com/Thalhammer/jwt-cpp/archive/refs/tags/v0.7.2.tar.gz", + sha256 = "6e815d86c168eb521a27937d603747dec0ca3c39ffc12d6fa72e2cf78a5b02d2", + }, + }, + macosx = { + ["0.7.2"] = { + url = "https://github.com/Thalhammer/jwt-cpp/archive/refs/tags/v0.7.2.tar.gz", + sha256 = "6e815d86c168eb521a27937d603747dec0ca3c39ffc12d6fa72e2cf78a5b02d2", + }, + }, + windows = { + ["0.7.2"] = { + url = "https://github.com/Thalhammer/jwt-cpp/archive/refs/tags/v0.7.2.tar.gz", + sha256 = "6e815d86c168eb521a27937d603747dec0ca3c39ffc12d6fa72e2cf78a5b02d2", + }, + }, + }, + + mcpp = { + language = "c++20", + import_std = false, + -- Exposes BOTH `jwt-cpp/` and the bundled `picojson/` (jwt.h includes + -- it via its own quoted path, but keep the -I surface complete). + include_dirs = { "*/include" }, + generated_files = { + ["mcpp_generated/jwt_cpp_anchor.cpp"] = [==[ +int mcpp_compat_jwt_cpp_anchor(void) { return 0; } +]==], + }, + sources = { "mcpp_generated/jwt_cpp_anchor.cpp" }, + targets = { ["jwt_cpp"] = { kind = "lib" } }, + deps = { ["compat.openssl"] = "3.5.1" }, + }, +} diff --git a/tests/examples/boost-assert/mcpp.toml b/tests/examples/boost-assert/mcpp.toml new file mode 100644 index 0000000..ce0c83d --- /dev/null +++ b/tests/examples/boost-assert/mcpp.toml @@ -0,0 +1,8 @@ +# compat.boost-assert test project: asserts the assert/current_function/ +# source_location surface compiles and behaves at runtime. +[package] +name = "boost-assert-tests" +version = "0.1.0" + +[dependencies.compat] +boost-assert = "1.92.0" diff --git a/tests/examples/boost-assert/tests/assert.cpp b/tests/examples/boost-assert/tests/assert.cpp new file mode 100644 index 0000000..d0a819f --- /dev/null +++ b/tests/examples/boost-assert/tests/assert.cpp @@ -0,0 +1,21 @@ +// Behavioral test: BOOST_VERIFY's expression is evaluated in ALL build modes +// (unlike BOOST_ASSERT, which compiles away under NDEBUG), and the +// source_location / current_function utilities return live data. +#include +#include +#include + +static int answer() { return 42; } + +int main() { + bool ran = false; + BOOST_VERIFY(answer() == 42 && (ran = true)); // must run even under NDEBUG + + const char* fn = BOOST_CURRENT_FUNCTION; + bool fn_ok = fn != nullptr && *fn != '\0'; + + constexpr boost::source_location loc = BOOST_CURRENT_LOCATION; + bool loc_ok = loc.file_name() != nullptr && loc.line() > 0; + + return (ran && fn_ok && loc_ok) ? 0 : 1; +} diff --git a/tests/examples/boost-config/mcpp.toml b/tests/examples/boost-config/mcpp.toml new file mode 100644 index 0000000..b4ee293 --- /dev/null +++ b/tests/examples/boost-config/mcpp.toml @@ -0,0 +1,10 @@ +# compat.boost-config test project: the root of the modular-boost header +# family this index carries. Asserts the pinned 1.92.0 train and positive +# platform detection under `mcpp test`. Resolves via the inherited +# workspace-root `[indices]` compat redirect. +[package] +name = "boost-config-tests" +version = "0.1.0" + +[dependencies.compat] +boost-config = "1.92.0" diff --git a/tests/examples/boost-config/tests/config.cpp b/tests/examples/boost-config/tests/config.cpp new file mode 100644 index 0000000..60f927c --- /dev/null +++ b/tests/examples/boost-config/tests/config.cpp @@ -0,0 +1,26 @@ +// Behavioral test: the compat.boost-config headers are present and identify +// themselves as exactly the pinned 1.92.0 train. If the descriptor ever +// drifts to another release without this member following, this fails loudly. +#include +#include +#include + +int main() { + // BOOST_VERSION encodes major*100000 + minor*100 + patch -> 1.92.0. + bool ok = BOOST_VERSION == 109200; + ok = ok && std::string_view(BOOST_LIB_VERSION) == "1_92"; + + // Platform detection must have positively selected THIS platform's header: + // each platform/*.hpp stamps BOOST_PLATFORM with its own string. A config + // that silently defaulted everywhere would fail on every branch. +#if defined(_WIN32) + ok = ok && std::string_view(BOOST_PLATFORM) == "Win32"; +#elif defined(__APPLE__) && defined(__MACH__) + ok = ok && std::string_view(BOOST_PLATFORM) == "Mac OS"; +#elif defined(__linux__) + ok = ok && std::string_view(BOOST_PLATFORM) == "linux"; +#else + ok = false; // not a platform this index claims +#endif + return ok ? 0 : 1; +} diff --git a/tests/examples/boost-throw-exception/mcpp.toml b/tests/examples/boost-throw-exception/mcpp.toml new file mode 100644 index 0000000..4bc5c3a --- /dev/null +++ b/tests/examples/boost-throw-exception/mcpp.toml @@ -0,0 +1,8 @@ +# compat.boost-throw-exception test project: BOOST_THROW_EXCEPTION raises a +# std::exception-derived error carrying the original message. +[package] +name = "boost-throw-exception-tests" +version = "0.1.0" + +[dependencies.compat] +boost-throw-exception = "1.92.0" diff --git a/tests/examples/boost-throw-exception/tests/throw_exception.cpp b/tests/examples/boost-throw-exception/tests/throw_exception.cpp new file mode 100644 index 0000000..2d5b74f --- /dev/null +++ b/tests/examples/boost-throw-exception/tests/throw_exception.cpp @@ -0,0 +1,15 @@ +// Behavioral test: BOOST_THROW_EXCEPTION raises an exception catchable as its +// own std::exception base, carrying the original message through what(). +#include +#include +#include + +int main() { + bool caught = false; + try { + BOOST_THROW_EXCEPTION(std::runtime_error("compat probe")); + } catch (const std::exception& e) { + caught = std::strstr(e.what(), "compat probe") != nullptr; + } + return caught ? 0 : 1; +} diff --git a/tests/examples/boost-type-traits/mcpp.toml b/tests/examples/boost-type-traits/mcpp.toml new file mode 100644 index 0000000..dd810c2 --- /dev/null +++ b/tests/examples/boost-type-traits/mcpp.toml @@ -0,0 +1,8 @@ +# compat.boost-type-traits test project: the trait answers are asserted both +# statically (compile fails on wrong answers) and through a runtime value. +[package] +name = "boost-type-traits-tests" +version = "0.1.0" + +[dependencies.compat] +boost-type-traits = "1.92.0" diff --git a/tests/examples/boost-type-traits/tests/type_traits.cpp b/tests/examples/boost-type-traits/tests/type_traits.cpp new file mode 100644 index 0000000..927aa93 --- /dev/null +++ b/tests/examples/boost-type-traits/tests/type_traits.cpp @@ -0,0 +1,18 @@ +// Behavioral test: core traits give the right answers, cross-checked against +// the standard library where an equivalent exists. +#include +#include +#include +#include + +int main() { + static_assert(boost::is_same::value, "same type must match"); + static_assert(!boost::is_same::value, "distinct types must differ"); + static_assert(std::is_same::type, int*>::value, + "add_pointer must yield int*"); + static_assert(std::is_same::type, int>::value, + "remove_cv must strip const/volatile"); + + bool ok = boost::is_same::value; // runtime-visible path + return ok ? 0 : 1; +} diff --git a/tests/examples/boost-uuid/mcpp.toml b/tests/examples/boost-uuid/mcpp.toml new file mode 100644 index 0000000..5101207 --- /dev/null +++ b/tests/examples/boost-uuid/mcpp.toml @@ -0,0 +1,9 @@ +# compat.boost-uuid test project: RFC 4122 shape, string round-trip, +# deterministic name generation and std::hash. Pulls the whole modular-boost +# header family transitively through the descriptor's own deps. +[package] +name = "boost-uuid-tests" +version = "0.1.0" + +[dependencies.compat] +boost-uuid = "1.92.0" diff --git a/tests/examples/boost-uuid/tests/uuid.cpp b/tests/examples/boost-uuid/tests/uuid.cpp new file mode 100644 index 0000000..77bbcec --- /dev/null +++ b/tests/examples/boost-uuid/tests/uuid.cpp @@ -0,0 +1,48 @@ +// Behavioral test: RFC 4122 shape of generated UUIDs, string round-trip, +// deterministic name generation, and the std::hash specialization. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() { + namespace uuids = boost::uuids; + bool ok = true; + + // Nil UUID round-trips through the canonical textual form. + std::ostringstream nil_out; + nil_out << uuids::nil_uuid(); + ok = ok && nil_out.str() == "00000000-0000-0000-0000-000000000000"; + + // Parse -> print reproduces the canonical spelling byte for byte. + uuids::string_generator parse; + const uuids::uuid fixed = + parse("f81d4fae-7dec-11d0-a765-00a0c91e6bf6"); + std::ostringstream fixed_out; + fixed_out << fixed; + ok = ok && fixed_out.str() == "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"; + + // Random generator emits RFC 4122 version 4 / variant 1 shapes, and two + // draws differ (collision odds are negligible by construction). + uuids::random_generator rand; + const uuids::uuid a = rand(); + const uuids::uuid b = rand(); + ok = ok && ((a.data[6] >> 4) == 4) && ((a.data[8] >> 6) == 0b10); + ok = ok && a != b; + + // Name generator is deterministic per input and sensitive across inputs. + uuids::name_generator_sha1 namegen(uuids::ns::dns()); + ok = ok && namegen("example.com") == namegen("example.com"); + ok = ok && namegen("example.com") != namegen("other.example.com"); + + // The std::hash specialization agrees on equal values. + ok = ok && std::hash{}(fixed) == std::hash{}(fixed); + + return ok ? 0 : 1; +} diff --git a/tests/examples/jwt-cpp/mcpp.toml b/tests/examples/jwt-cpp/mcpp.toml new file mode 100644 index 0000000..3a31d90 --- /dev/null +++ b/tests/examples/jwt-cpp/mcpp.toml @@ -0,0 +1,9 @@ +# compat.jwt-cpp test project: real HMAC signing + verification through the +# package's compat.openssl dependency — the positive path must verify, and a +# wrong key must be rejected. +[package] +name = "jwt-cpp-tests" +version = "0.1.0" + +[dependencies.compat] +jwt-cpp = "0.7.2" diff --git a/tests/examples/jwt-cpp/tests/jwt.cpp b/tests/examples/jwt-cpp/tests/jwt.cpp new file mode 100644 index 0000000..c8c636a --- /dev/null +++ b/tests/examples/jwt-cpp/tests/jwt.cpp @@ -0,0 +1,49 @@ +// Behavioral test: HS256 sign -> decode -> verify through compat.openssl. +// The correct key and claim must pass; a wrong key must be rejected. This is +// the end-to-end assertion that the package's OpenSSL wiring actually links +// and computes, not just that headers exist. +#include +#include +#include + +int main() { + bool ok = true; + + const auto token = jwt::create() + .set_payload_claim("sub", jwt::claim(std::string("alice"))) + // Boolean claims need the JSON value spelled out: a + // bare `jwt::claim(true)` would need TWO user-defined + // conversions (bool -> picojson::value -> claim). + .set_payload_claim( + "admin", + jwt::claim(jwt::traits::kazuho_picojson::value_type(true))) + .set_expires_at(std::chrono::system_clock::now() + + std::chrono::seconds{3600}) + .sign(jwt::algorithm::hs256{"secret-key"}); + + const auto decoded = jwt::decode(token); + ok = ok && decoded.get_payload_claim("sub").as_string() == "alice"; + ok = ok && decoded.get_payload_claim("admin").as_boolean(); + ok = ok && decoded.get_header_claim("alg").as_string() == "HS256"; + + try { + jwt::verify() + .allow_algorithm(jwt::algorithm::hs256{"secret-key"}) + .with_claim("sub", jwt::claim(std::string("alice"))) + .verify(decoded); + } catch (...) { + ok = false; // correct key + claim: verification must succeed + } + + bool wrong_key_rejected = false; + try { + jwt::verify() + .allow_algorithm(jwt::algorithm::hs256{"wrong-key"}) + .with_claim("sub", jwt::claim(std::string("alice"))) + .verify(decoded); + } catch (...) { + wrong_key_rejected = true; // wrong signature must throw + } + + return (ok && wrong_key_rejected) ? 0 : 1; +}