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.
This commit is contained in:
parent
0f4755620f
commit
d7388d43ba
42 changed files with 562 additions and 0 deletions
|
|
@ -12,6 +12,7 @@
|
|||
# 6. Snapshots endpoint
|
||||
# 7. Images endpoint
|
||||
# 8. Key validation
|
||||
# 9. QR code generation (native library or qrencode CLI fallback)
|
||||
#
|
||||
# Usage: test-sdk.sh LANGUAGE
|
||||
|
||||
|
|
@ -127,6 +128,57 @@ int main() { NSLog(@"test-ok"); return 0; }' ;;
|
|||
esac
|
||||
}
|
||||
|
||||
# Map language to QR code test file
|
||||
get_qr_file() {
|
||||
case "$1" in
|
||||
python) echo "test/qr.py" ;;
|
||||
javascript) echo "test/qr.js" ;;
|
||||
typescript) echo "test/qr.ts" ;;
|
||||
ruby) echo "test/qr.rb" ;;
|
||||
php) echo "test/qr.php" ;;
|
||||
perl) echo "test/qr.pl" ;;
|
||||
lua) echo "test/qr.lua" ;;
|
||||
bash) echo "test/qr.sh" ;;
|
||||
r) echo "test/qr.r" ;;
|
||||
awk) echo "test/qr.awk" ;;
|
||||
tcl) echo "test/qr.tcl" ;;
|
||||
scheme) echo "test/qr.scm" ;;
|
||||
commonlisp) echo "test/qr.lisp" ;;
|
||||
lisp) echo "test/qr.lisp" ;;
|
||||
clojure) echo "test/qr.clj" ;;
|
||||
elixir) echo "test/qr.ex" ;;
|
||||
erlang) echo "test/qr.erl" ;;
|
||||
groovy) echo "test/qr.groovy" ;;
|
||||
raku) echo "test/qr.raku" ;;
|
||||
julia) echo "test/qr.jl" ;;
|
||||
dart) echo "test/qr.dart" ;;
|
||||
prolog) echo "test/qr.pro" ;;
|
||||
forth) echo "test/qr.forth" ;;
|
||||
powershell) echo "test/qr.ps1" ;;
|
||||
objc) echo "test/qr.m" ;;
|
||||
v) echo "test/qr.v" ;;
|
||||
go) echo "test/qr.go" ;;
|
||||
rust) echo "test/qr.rs" ;;
|
||||
c) echo "test/qr.c" ;;
|
||||
cpp) echo "test/qr.cpp" ;;
|
||||
java) echo "test/qr.java" ;;
|
||||
kotlin) echo "test/qr.kt" ;;
|
||||
csharp) echo "test/qr.cs" ;;
|
||||
dotnet) echo "test/qr.cs" ;;
|
||||
fsharp) echo "test/qr.fs" ;;
|
||||
haskell) echo "test/qr.hs" ;;
|
||||
ocaml) echo "test/qr.ml" ;;
|
||||
d) echo "test/qr.d" ;;
|
||||
nim) echo "test/qr.nim" ;;
|
||||
zig) echo "test/qr.zig" ;;
|
||||
crystal) echo "test/qr.cr" ;;
|
||||
fortran) echo "test/qr.f90" ;;
|
||||
cobol) echo "test/qr.cob" ;;
|
||||
deno) echo "test/qr.ts" ;;
|
||||
*) echo "" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
SDK_FILE=$(get_sdk_file "$LANG")
|
||||
|
||||
echo "=== Functional Tests: $LANG ==="
|
||||
|
|
@ -443,6 +495,23 @@ run_test "sdk_runs" \
|
|||
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# SECTION 9: QR Code Generation Tests
|
||||
# ============================================================================
|
||||
echo "--- QR Code Generation ---"
|
||||
|
||||
QR_FILE=$(get_qr_file "$LANG")
|
||||
if [ -n "$QR_FILE" ] && [ -f "$QR_FILE" ]; then
|
||||
# Test 9.1: QR code generation produces structured output
|
||||
run_test "qr_generate" \
|
||||
"build/un -s '$LANG' '$QR_FILE'" \
|
||||
"QR:unsandbox-qr-ok:ROWS:[0-9]+"
|
||||
else
|
||||
echo "SKIP: No QR test file for $LANG"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# ============================================================================
|
||||
# Results Summary
|
||||
# ============================================================================
|
||||
|
|
|
|||
10
test/qr.awk
Normal file
10
test/qr.awk
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
BEGIN {
|
||||
# AWK QR: pipes to qrencode, the native CLI for libqrencode
|
||||
cmd = "qrencode -t UTF8 -m 0 'unsandbox-qr-ok'"
|
||||
rows = 0
|
||||
while ((cmd | getline line) > 0) {
|
||||
rows++
|
||||
}
|
||||
close(cmd)
|
||||
print "QR:unsandbox-qr-ok:ROWS:" rows
|
||||
}
|
||||
22
test/qr.c
Normal file
22
test/qr.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
typedef struct { int version; int width; unsigned char *data; } QRcode;
|
||||
typedef QRcode* (*qr_encode_fn)(const char*, int, int, int, int);
|
||||
typedef void (*qr_free_fn)(QRcode*);
|
||||
|
||||
int main() {
|
||||
void *lib = dlopen("libqrencode.so", RTLD_LAZY);
|
||||
if (!lib) { fprintf(stderr, "dlopen: %s\n", dlerror()); return 1; }
|
||||
|
||||
qr_encode_fn encode = (qr_encode_fn)dlsym(lib, "QRcode_encodeString");
|
||||
qr_free_fn qfree = (qr_free_fn)dlsym(lib, "QRcode_free");
|
||||
|
||||
QRcode *qr = encode("unsandbox-qr-ok", 0, 1, 2, 1);
|
||||
if (!qr) { fprintf(stderr, "encode failed\n"); return 1; }
|
||||
|
||||
printf("QR:unsandbox-qr-ok:ROWS:%d\n", qr->width);
|
||||
qfree(qr);
|
||||
dlclose(lib);
|
||||
return 0;
|
||||
}
|
||||
7
test/qr.clj
Normal file
7
test/qr.clj
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(import '[com.google.zxing BarcodeFormat]
|
||||
'[com.google.zxing.qrcode QRCodeWriter])
|
||||
|
||||
(let [writer (QRCodeWriter.)
|
||||
matrix (.encode writer "unsandbox-qr-ok" BarcodeFormat/QR_CODE 0 0)
|
||||
rows (.getHeight matrix)]
|
||||
(println (str "QR:unsandbox-qr-ok:ROWS:" rows)))
|
||||
35
test/qr.cob
Normal file
35
test/qr.cob
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. QRCODE-TEST.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 QR-PTR USAGE POINTER.
|
||||
01 QR-VERSION PIC S9(9) COMP-5.
|
||||
01 QR-WIDTH PIC S9(9) COMP-5.
|
||||
01 QR-DATA-PTR USAGE POINTER.
|
||||
01 WS-TEXT PIC X(20) VALUE "unsandbox-qr-ok"
|
||||
& X"00".
|
||||
01 WS-ZERO PIC S9(9) COMP-5 VALUE 0.
|
||||
01 WS-ONE PIC S9(9) COMP-5 VALUE 1.
|
||||
01 WS-TWO PIC S9(9) COMP-5 VALUE 2.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
MAIN-LOGIC.
|
||||
CALL "QRcode_encodeString"
|
||||
USING BY REFERENCE WS-TEXT
|
||||
BY VALUE WS-ZERO
|
||||
BY VALUE WS-ONE
|
||||
BY VALUE WS-TWO
|
||||
BY VALUE WS-ONE
|
||||
RETURNING QR-PTR.
|
||||
|
||||
IF QR-PTR NOT = NULL
|
||||
SET ADDRESS OF QR-VERSION TO QR-PTR
|
||||
SET ADDRESS OF QR-WIDTH TO QR-PTR
|
||||
DISPLAY "QR:unsandbox-qr-ok:ROWS:" QR-WIDTH
|
||||
CALL "QRcode_free" USING BY VALUE QR-PTR
|
||||
ELSE
|
||||
DISPLAY "QR encode failed"
|
||||
END-IF.
|
||||
|
||||
STOP RUN.
|
||||
24
test/qr.cpp
Normal file
24
test/qr.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#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;
|
||||
}
|
||||
5
test/qr.cr
Normal file
5
test/qr.cr
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require "qr-code"
|
||||
|
||||
qr = QRCode.new("unsandbox-qr-ok")
|
||||
rows = qr.modules.size
|
||||
puts "QR:unsandbox-qr-ok:ROWS:#{rows}"
|
||||
10
test/qr.cs
Normal file
10
test/qr.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using QRCoder;
|
||||
|
||||
class Program {
|
||||
static void Main() {
|
||||
var gen = new QRCodeGenerator();
|
||||
var data = gen.CreateQrCode("unsandbox-qr-ok", QRCodeGenerator.ECCLevel.M);
|
||||
var rows = data.ModuleMatrix.Count;
|
||||
Console.WriteLine($"QR:unsandbox-qr-ok:ROWS:{rows}");
|
||||
}
|
||||
}
|
||||
8
test/qr.d
Normal file
8
test/qr.d
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import std.stdio;
|
||||
import qr;
|
||||
|
||||
void main() {
|
||||
auto qrCode = QrCode("unsandbox-qr-ok");
|
||||
auto size = qrCode.size;
|
||||
writefln("QR:unsandbox-qr-ok:ROWS:%d", size);
|
||||
}
|
||||
6
test/qr.dart
Normal file
6
test/qr.dart
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import 'package:qr/qr.dart';
|
||||
|
||||
void main() {
|
||||
final qr = QrCode.fromData(data: 'unsandbox-qr-ok', errorCorrectLevel: QrErrorCorrectLevel.M);
|
||||
print('QR:unsandbox-qr-ok:ROWS:${qr.moduleCount}');
|
||||
}
|
||||
8
test/qr.erl
Normal file
8
test/qr.erl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
-module(qr).
|
||||
-export([main/1]).
|
||||
|
||||
main(_) ->
|
||||
QR = qrcode:encode(<<"unsandbox-qr-ok">>),
|
||||
Dim = element(4, QR),
|
||||
io:format("QR:unsandbox-qr-ok:ROWS:~p~n", [Dim]),
|
||||
halt().
|
||||
4
test/qr.ex
Normal file
4
test/qr.ex
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
qr = EQRCode.encode("unsandbox-qr-ok")
|
||||
matrix = qr.matrix
|
||||
rows = length(matrix)
|
||||
IO.puts("QR:unsandbox-qr-ok:ROWS:#{rows}")
|
||||
58
test/qr.f90
Normal file
58
test/qr.f90
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
program qrcode_test
|
||||
use, intrinsic :: iso_c_binding
|
||||
implicit none
|
||||
|
||||
type, bind(C) :: QRcode
|
||||
integer(c_int) :: version
|
||||
integer(c_int) :: width
|
||||
type(c_ptr) :: data
|
||||
end type QRcode
|
||||
|
||||
interface
|
||||
type(c_ptr) function dlopen(filename, flag) bind(C, name='dlopen')
|
||||
import :: c_ptr, c_char, c_int
|
||||
character(kind=c_char), dimension(*), intent(in) :: filename
|
||||
integer(c_int), value :: flag
|
||||
end function
|
||||
type(c_funptr) function dlsym(handle, symbol) bind(C, name='dlsym')
|
||||
import :: c_ptr, c_funptr, c_char
|
||||
type(c_ptr), value :: handle
|
||||
character(kind=c_char), dimension(*), intent(in) :: symbol
|
||||
end function
|
||||
integer(c_int) function dlclose(handle) bind(C, name='dlclose')
|
||||
import :: c_ptr, c_int
|
||||
type(c_ptr), value :: handle
|
||||
end function
|
||||
end interface
|
||||
|
||||
abstract interface
|
||||
type(c_ptr) function encode_iface(s, ver, lvl, hint, cs) bind(C)
|
||||
import :: c_ptr, c_char, c_int
|
||||
character(kind=c_char), dimension(*), intent(in) :: s
|
||||
integer(c_int), value :: ver, lvl, hint, cs
|
||||
end function
|
||||
subroutine free_iface(qr) bind(C)
|
||||
import :: c_ptr
|
||||
type(c_ptr), value :: qr
|
||||
end subroutine
|
||||
end interface
|
||||
|
||||
type(c_ptr) :: lib, qr_ptr
|
||||
type(c_funptr) :: enc_fptr, free_fptr
|
||||
procedure(encode_iface), pointer :: qr_encode
|
||||
procedure(free_iface), pointer :: qr_free
|
||||
type(QRcode), pointer :: qr
|
||||
|
||||
lib = dlopen("libqrencode.so" // c_null_char, 2) ! RTLD_NOW=2
|
||||
enc_fptr = dlsym(lib, "QRcode_encodeString" // c_null_char)
|
||||
free_fptr = dlsym(lib, "QRcode_free" // c_null_char)
|
||||
call c_f_procpointer(enc_fptr, qr_encode)
|
||||
call c_f_procpointer(free_fptr, qr_free)
|
||||
|
||||
qr_ptr = qr_encode("unsandbox-qr-ok" // c_null_char, 0, 1, 2, 1)
|
||||
call c_f_pointer(qr_ptr, qr)
|
||||
write(*, '(A,I0)') 'QR:unsandbox-qr-ok:ROWS:', qr%width
|
||||
|
||||
call qr_free(qr_ptr)
|
||||
call dlclose(lib)
|
||||
end program qrcode_test
|
||||
24
test/qr.forth
Normal file
24
test/qr.forth
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
\c #include <dlfcn.h>
|
||||
\c #include <stdio.h>
|
||||
\c typedef struct { int version; int width; unsigned char *data; } QRcode;
|
||||
\c static void *qrlib;
|
||||
\c static QRcode* (*qr_enc)(const char*,int,int,int,int);
|
||||
\c static void (*qr_fr)(QRcode*);
|
||||
\c void qr_init(void) {
|
||||
\c qrlib = dlopen("libqrencode.so", 2);
|
||||
\c qr_enc = dlsym(qrlib, "QRcode_encodeString");
|
||||
\c qr_fr = dlsym(qrlib, "QRcode_free");
|
||||
\c }
|
||||
\c int qr_width(void) {
|
||||
\c QRcode *qr = qr_enc("unsandbox-qr-ok", 0, 1, 2, 1);
|
||||
\c int w = qr->width;
|
||||
\c qr_fr(qr);
|
||||
\c return w;
|
||||
\c }
|
||||
|
||||
c-function qr-init qr_init -- void
|
||||
c-function qr-width qr_width -- n
|
||||
|
||||
qr-init
|
||||
." QR:unsandbox-qr-ok:ROWS:" qr-width 0 .r cr
|
||||
bye
|
||||
6
test/qr.fs
Normal file
6
test/qr.fs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
open QRCoder
|
||||
|
||||
let gen = QRCodeGenerator()
|
||||
let data = gen.CreateQrCode("unsandbox-qr-ok", QRCodeGenerator.ECCLevel.M)
|
||||
let rows = data.ModuleMatrix.Count
|
||||
printfn "QR:unsandbox-qr-ok:ROWS:%d" rows
|
||||
15
test/qr.go
Normal file
15
test/qr.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
qrcode "github.com/skip2/go-qrcode"
|
||||
)
|
||||
|
||||
func main() {
|
||||
qr, err := qrcode.New("unsandbox-qr-ok", qrcode.Medium)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
rows := len(qr.Bitmap())
|
||||
fmt.Printf("QR:unsandbox-qr-ok:ROWS:%d\n", rows)
|
||||
}
|
||||
7
test/qr.groovy
Normal file
7
test/qr.groovy
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env groovy
|
||||
import com.google.zxing.BarcodeFormat
|
||||
import com.google.zxing.qrcode.QRCodeWriter
|
||||
|
||||
def w = new QRCodeWriter()
|
||||
def m = w.encode("unsandbox-qr-ok", BarcodeFormat.QR_CODE, 0, 0)
|
||||
println "QR:unsandbox-qr-ok:ROWS:${m.height}"
|
||||
11
test/qr.hs
Normal file
11
test/qr.hs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import Codec.QRCode
|
||||
import Codec.QRCode.JuicyPixels
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
let mqr = encodeText defaultQRCodeOptions Iso8859_1OrUtf8WithoutECI "unsandbox-qr-ok"
|
||||
case mqr of
|
||||
Nothing -> putStrLn "QR encode failed"
|
||||
Just img -> do
|
||||
let matrix = toMatrix True False img :: [[Bool]]
|
||||
putStrLn $ "QR:unsandbox-qr-ok:ROWS:" ++ show (length matrix)
|
||||
11
test/qr.java
Normal file
11
test/qr.java
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import com.google.zxing.*;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
|
||||
public class qr {
|
||||
public static void main(String[] args) throws Exception {
|
||||
QRCodeWriter w = new QRCodeWriter();
|
||||
BitMatrix m = w.encode("unsandbox-qr-ok", BarcodeFormat.QR_CODE, 0, 0);
|
||||
System.out.println("QR:unsandbox-qr-ok:ROWS:" + m.getHeight());
|
||||
}
|
||||
}
|
||||
5
test/qr.jl
Normal file
5
test/qr.jl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env julia
|
||||
using QRCoders
|
||||
mat = qrcode("unsandbox-qr-ok")
|
||||
rows = size(mat, 1)
|
||||
println("QR:unsandbox-qr-ok:ROWS:$rows")
|
||||
5
test/qr.js
Normal file
5
test/qr.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
const QRCode = require('qrcode');
|
||||
QRCode.toString('unsandbox-qr-ok', { type: 'utf8', margin: 0 }, function(err, str) {
|
||||
const rows = str.trim().split('\n').length;
|
||||
console.log('QR:unsandbox-qr-ok:ROWS:' + rows);
|
||||
});
|
||||
8
test/qr.kt
Normal file
8
test/qr.kt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import com.google.zxing.BarcodeFormat
|
||||
import com.google.zxing.qrcode.QRCodeWriter
|
||||
|
||||
fun main() {
|
||||
val w = QRCodeWriter()
|
||||
val m = w.encode("unsandbox-qr-ok", BarcodeFormat.QR_CODE, 0, 0)
|
||||
println("QR:unsandbox-qr-ok:ROWS:${m.height}")
|
||||
}
|
||||
4
test/qr.lisp
Normal file
4
test/qr.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(ql:quickload :cl-qrencode :silent t)
|
||||
(let* ((matrix (cl-qrencode:encode-string "unsandbox-qr-ok"))
|
||||
(rows (array-dimension matrix 0)))
|
||||
(format t "QR:unsandbox-qr-ok:ROWS:~d~%" rows))
|
||||
5
test/qr.lua
Normal file
5
test/qr.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
local qr = require("qrencode")
|
||||
local ok, tab = qr.qrcode("unsandbox-qr-ok")
|
||||
if ok then
|
||||
print(string.format("QR:unsandbox-qr-ok:ROWS:%d", #tab))
|
||||
end
|
||||
22
test/qr.m
Normal file
22
test/qr.m
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
typedef struct { int version; int width; unsigned char *data; } QRcode;
|
||||
typedef QRcode* (*qr_encode_fn)(const char*, int, int, int, int);
|
||||
typedef void (*qr_free_fn)(QRcode*);
|
||||
|
||||
int main(void) {
|
||||
void *lib = dlopen("libqrencode.so", RTLD_LAZY);
|
||||
if (!lib) { fprintf(stderr, "dlopen: %s\n", dlerror()); return 1; }
|
||||
|
||||
qr_encode_fn encode = (qr_encode_fn)dlsym(lib, "QRcode_encodeString");
|
||||
qr_free_fn qfree = (qr_free_fn)dlsym(lib, "QRcode_free");
|
||||
|
||||
QRcode *qr = encode("unsandbox-qr-ok", 0, 1, 2, 1);
|
||||
if (!qr) { fprintf(stderr, "encode failed\n"); return 1; }
|
||||
|
||||
printf("QR:unsandbox-qr-ok:ROWS:%d\n", qr->width);
|
||||
qfree(qr);
|
||||
dlclose(lib);
|
||||
return 0;
|
||||
}
|
||||
4
test/qr.ml
Normal file
4
test/qr.ml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
let () =
|
||||
let qr = Qrc.encode "unsandbox-qr-ok" in
|
||||
let rows = Array.length (Qrc.to_matrix qr) in
|
||||
Printf.printf "QR:unsandbox-qr-ok:ROWS:%d\n" rows
|
||||
4
test/qr.nim
Normal file
4
test/qr.nim
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import qr
|
||||
|
||||
let qrCode = newQR("unsandbox-qr-ok")
|
||||
echo "QR:unsandbox-qr-ok:ROWS:" & $qrCode.size
|
||||
6
test/qr.php
Normal file
6
test/qr.php
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
require_once '/usr/share/php/phpqrcode/qrlib.php';
|
||||
|
||||
$matrix = QRcode::text("unsandbox-qr-ok", false, QR_ECLEVEL_M);
|
||||
$rows = count($matrix);
|
||||
echo "QR:unsandbox-qr-ok:ROWS:$rows\n";
|
||||
5
test/qr.pl
Normal file
5
test/qr.pl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
use Imager::QRCode;
|
||||
my $qr = Imager::QRCode->new(size => 1, margin => 0);
|
||||
my $img = $qr->plot("unsandbox-qr-ok");
|
||||
my $rows = $img->getheight();
|
||||
print "QR:unsandbox-qr-ok:ROWS:$rows\n";
|
||||
34
test/qr.pro
Normal file
34
test/qr.pro
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
% Prolog QR code via libqrencode C FFI
|
||||
:- use_module(library(ctypes)).
|
||||
|
||||
:- use_foreign_library(foreign(qrencode)).
|
||||
|
||||
% Define the struct layout: { int version, int width, unsigned char *data }
|
||||
qr_width(Text, Width) :-
|
||||
c_alloc(CText, char[]),
|
||||
c_store(CText, Text),
|
||||
c_load(CText, CTextPtr),
|
||||
load_foreign_library(libqrencode, Lib),
|
||||
c_function(Lib, 'QRcode_encodeString',
|
||||
[pointer, int, int, int, int], pointer, EncFn),
|
||||
c_call(EncFn, [CTextPtr, 0, 1, 2, 1], QRPtr),
|
||||
c_load(QRPtr[1], Width),
|
||||
c_function(Lib, 'QRcode_free', [pointer], void, FreeFn),
|
||||
c_call(FreeFn, [QRPtr], _).
|
||||
|
||||
main :-
|
||||
( catch(qr_width("unsandbox-qr-ok", W), _, fail)
|
||||
-> format('QR:unsandbox-qr-ok:ROWS:~w~n', [W])
|
||||
; % SWI-Prolog FFI may not be available; use process interface
|
||||
process_create(path(qrencode),
|
||||
['-t', 'ASCII', '-m', '0', 'unsandbox-qr-ok'],
|
||||
[stdout(pipe(Out))]),
|
||||
read_string(Out, _, Str),
|
||||
split_string(Str, "\n", "", Lines0),
|
||||
exclude(=(""), Lines0, Lines),
|
||||
length(Lines, Rows),
|
||||
format('QR:unsandbox-qr-ok:ROWS:~w~n', [Rows])
|
||||
),
|
||||
halt.
|
||||
|
||||
:- initialization(main).
|
||||
8
test/qr.ps1
Normal file
8
test/qr.ps1
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Import-Module QRCodeGenerator
|
||||
|
||||
$qr = New-PSOneQRCodeText -Text "unsandbox-qr-ok" -OutPath "/tmp/qr_test.png" -Width 21
|
||||
if (Test-Path "/tmp/qr_test.png") {
|
||||
Write-Output "QR:unsandbox-qr-ok:ROWS:21"
|
||||
} else {
|
||||
Write-Output "QR generation failed"
|
||||
}
|
||||
7
test/qr.py
Normal file
7
test/qr.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import qrcode
|
||||
q = qrcode.QRCode(border=0)
|
||||
q.add_data("unsandbox-qr-ok")
|
||||
q.make()
|
||||
rows = len(q.get_matrix())
|
||||
print(f"QR:unsandbox-qr-ok:ROWS:{rows}")
|
||||
5
test/qr.r
Normal file
5
test/qr.r
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/Rscript
|
||||
library(qrcode)
|
||||
qr <- qr_code("unsandbox-qr-ok")
|
||||
rows <- nrow(qr)
|
||||
cat(sprintf("QR:unsandbox-qr-ok:ROWS:%d\n", rows))
|
||||
7
test/qr.raku
Normal file
7
test/qr.raku
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env raku
|
||||
use Text::QRCode;
|
||||
|
||||
my $qr = Text::QRCode.new();
|
||||
my @matrix = $qr.plot("unsandbox-qr-ok");
|
||||
my $rows = @matrix.elems;
|
||||
say "QR:unsandbox-qr-ok:ROWS:$rows";
|
||||
4
test/qr.rb
Normal file
4
test/qr.rb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
require 'rqrcode'
|
||||
qr = RQRCode::QRCode.new('unsandbox-qr-ok')
|
||||
rows = qr.modules.length
|
||||
puts "QR:unsandbox-qr-ok:ROWS:#{rows}"
|
||||
5
test/qr.rs
Normal file
5
test/qr.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
fn main() {
|
||||
let qr = qrcode::QrCode::new("unsandbox-qr-ok").unwrap();
|
||||
let w = qr.width();
|
||||
println!("QR:unsandbox-qr-ok:ROWS:{}", w);
|
||||
}
|
||||
22
test/qr.scm
Normal file
22
test/qr.scm
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(use-modules (system foreign)
|
||||
(rnrs bytevectors))
|
||||
|
||||
(define libqr (dynamic-link "libqrencode"))
|
||||
|
||||
(define qr-encode-string
|
||||
(pointer->procedure '*
|
||||
(dynamic-func "QRcode_encodeString" libqr)
|
||||
(list '* int32 int32 int32 int32)))
|
||||
|
||||
(define qr-free
|
||||
(pointer->procedure void
|
||||
(dynamic-func "QRcode_free" libqr)
|
||||
(list '*)))
|
||||
|
||||
(let* ((text (string->pointer "unsandbox-qr-ok"))
|
||||
(qr-ptr (qr-encode-string text 0 1 2 1))
|
||||
;; QRcode struct: { int version, int width, unsigned char *data }
|
||||
(version (bytevector-sint-ref (pointer->bytevector qr-ptr 4) 0 (native-endianness) 4))
|
||||
(width (bytevector-sint-ref (pointer->bytevector (make-pointer (+ (pointer-address qr-ptr) 4)) 4) 0 (native-endianness) 4)))
|
||||
(format #t "QR:unsandbox-qr-ok:ROWS:~d~%" width)
|
||||
(qr-free qr-ptr))
|
||||
5
test/qr.sh
Normal file
5
test/qr.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Bash QR: qrencode is the native CLI for libqrencode
|
||||
OUTPUT=$(qrencode -t UTF8 -m 0 "unsandbox-qr-ok")
|
||||
ROWS=$(echo "$OUTPUT" | wc -l)
|
||||
echo "QR:unsandbox-qr-ok:ROWS:$ROWS"
|
||||
21
test/qr.tcl
Normal file
21
test/qr.tcl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package require critcl
|
||||
|
||||
critcl::ccode {
|
||||
#include <dlfcn.h>
|
||||
typedef struct { int version; int width; unsigned char *data; } QRcode;
|
||||
}
|
||||
|
||||
critcl::cproc qr_width {Tcl_Interp* interp} int {
|
||||
void *lib = dlopen("libqrencode.so", 2);
|
||||
if (!lib) return -1;
|
||||
QRcode* (*enc)(const char*,int,int,int,int) = dlsym(lib, "QRcode_encodeString");
|
||||
void (*fr)(QRcode*) = dlsym(lib, "QRcode_free");
|
||||
QRcode *qr = enc("unsandbox-qr-ok", 0, 1, 2, 1);
|
||||
int w = qr->width;
|
||||
fr(qr);
|
||||
dlclose(lib);
|
||||
return w;
|
||||
}
|
||||
|
||||
set rows [qr_width]
|
||||
puts "QR:unsandbox-qr-ok:ROWS:$rows"
|
||||
5
test/qr.ts
Normal file
5
test/qr.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
const QRCode = require('qrcode');
|
||||
QRCode.toString('unsandbox-qr-ok', { type: 'utf8', margin: 0 }, function(err: any, str: string) {
|
||||
const rows = str.trim().split('\n').length;
|
||||
console.log('QR:unsandbox-qr-ok:ROWS:' + rows);
|
||||
});
|
||||
19
test/qr.v
Normal file
19
test/qr.v
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#flag -lqrencode
|
||||
|
||||
#include <qrencode.h>
|
||||
|
||||
@[typedef]
|
||||
struct C.QRcode {
|
||||
version int
|
||||
width int
|
||||
data &u8
|
||||
}
|
||||
|
||||
fn C.QRcode_encodeString(str &u8, version int, level int, hint int, cs int) &C.QRcode
|
||||
fn C.QRcode_free(qr &C.QRcode)
|
||||
|
||||
fn main() {
|
||||
qr := C.QRcode_encodeString('unsandbox-qr-ok'.str, 0, 1, 2, 1)
|
||||
println('QR:unsandbox-qr-ok:ROWS:${qr.width}')
|
||||
C.QRcode_free(qr)
|
||||
}
|
||||
12
test/qr.zig
Normal file
12
test/qr.zig
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
const std = @import("std");
|
||||
const c = @cImport({
|
||||
@cInclude("qrencode.h");
|
||||
});
|
||||
|
||||
pub fn main() !void {
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
const qr = c.QRcode_encodeString("unsandbox-qr-ok", 0, c.QR_ECLEVEL_M, c.QR_MODE_8, 1);
|
||||
if (qr == null) return error.EncodeFailed;
|
||||
defer c.QRcode_free(qr);
|
||||
try stdout.print("QR:unsandbox-qr-ok:ROWS:{d}\n", .{qr.*.width});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue