un-inception/test/qr.cpp
russell@unturf.com d7388d43ba feat: add QR code functional tests across 41 languages
Native QR generation for each language's ecosystem:
- 27 languages use package manager QR libraries (qrcode, rqrcode, ZXing, etc.)
- 10 languages use C FFI to libqrencode (dlopen, ISO_C_BINDING, @cImport, critcl)
- 2 shell languages use qrencode CLI (native shell paradigm)
- 1 language (Prolog) uses C FFI with CLI fallback

Section 9 added to test-sdk.sh with get_qr_file() mapping and
QR:unsandbox-qr-ok:ROWS pattern validation across the hydra matrix.
2026-01-27 18:24:54 -05:00

24 lines
740 B
C++

#include <iostream>
#include <dlfcn.h>
extern "C" {
typedef struct { int version; int width; unsigned char *data; } QRcode;
}
int main() {
void *lib = dlopen("libqrencode.so", RTLD_LAZY);
if (!lib) { std::cerr << "dlopen: " << dlerror() << std::endl; return 1; }
auto encode = reinterpret_cast<QRcode*(*)(const char*, int, int, int, int)>(
dlsym(lib, "QRcode_encodeString"));
auto qfree = reinterpret_cast<void(*)(QRcode*)>(
dlsym(lib, "QRcode_free"));
QRcode *qr = encode("unsandbox-qr-ok", 0, 1, 2, 1);
if (!qr) { std::cerr << "encode failed" << std::endl; return 1; }
std::cout << "QR:unsandbox-qr-ok:ROWS:" << qr->width << std::endl;
qfree(qr);
dlclose(lib);
return 0;
}