A cross-platform C++23 library with a platform-neutral public API and runtime-selected backends: - Input: Wayland virtual pointer/keyboard (Hyprland, wlroots), libei via the RemoteDesktop portal (GNOME, KDE), uinput, and Win32 SendInput - Capture: ScreenCast portal + PipeWire, and Win32 GDI - Windows: Hyprland IPC and Win32 enumeration - Monitors via wl_output/xdg-output and EnumDisplayMonitors - Optional OpenCV template matching (alvin::vision) Also adds the `alvin` CLI, Catch2 unit tests, install rules with find_package(Alvin) support, API docs (docs/API.md and the Obsidian vault), and README instructions for both ways of consuming the library. Windows backends are written but not yet compiled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#include <catch2/catch_test_macros.hpp>
|
|
|
|
#include "common/json.hpp"
|
|
|
|
using namespace alvin;
|
|
|
|
TEST_CASE("json parses a Hyprland client entry") {
|
|
auto v = json::parse(R"([{
|
|
"address": "0x55a4165aec60",
|
|
"at": [2903, 58], "size": [2834, 1539],
|
|
"workspace": {"id": 8, "name": "8"},
|
|
"hidden": false, "title": "Café \"quoted\"", "pid": 3163
|
|
}])");
|
|
REQUIRE(v);
|
|
const auto& c = (*v)[0];
|
|
CHECK(c["address"].string() == "0x55a4165aec60");
|
|
CHECK(c["at"][0].number() == 2903);
|
|
CHECK(c["size"][1].number() == 1539);
|
|
CHECK(c["workspace"]["name"].string() == "8");
|
|
CHECK(c["hidden"].boolean(true) == false);
|
|
CHECK(c["title"].string() == "Caf\xc3\xa9 \"quoted\"");
|
|
CHECK(c["missing"].isNull());
|
|
CHECK(c["missing"]["deeper"].isNull());
|
|
}
|
|
|
|
TEST_CASE("json rejects malformed input") {
|
|
CHECK_FALSE(json::parse("{"));
|
|
CHECK_FALSE(json::parse("[1,]"));
|
|
CHECK_FALSE(json::parse("{\"a\" 1}"));
|
|
CHECK_FALSE(json::parse("[1] trailing"));
|
|
CHECK(json::parse(" {} "));
|
|
CHECK(json::parse("\"\\ud83d\\ude00\"")->string() == "\xf0\x9f\x98\x80");
|
|
}
|