fckeuspy-go/qr_manual_test.go

32 lines
581 B
Go

package main
import (
"image/png"
"os"
"testing"
)
// go test -run TestDecodeQR -v
func TestDecodeQR(t *testing.T) {
path := os.Getenv("QR_TEST_FILE")
if path == "" {
t.Skip("set QR_TEST_FILE to a PNG path to run")
return
}
f, err := os.Open(path)
if err != nil {
t.Fatal(err)
}
defer f.Close()
img, err := png.Decode(f)
if err != nil {
t.Fatal(err)
}
txt, err := DecodeQR(img)
if err != nil {
t.Fatalf("decode error: %v", err)
}
t.Logf("decoded: %d bytes", len(txt))
}