hn-readcard-go/gui_test.go

22 lines
573 B
Go
Raw Normal View History

2026-08-12 13:40:06 +08:00
//go:build windows
package main
import "testing"
func TestBuildQRContent(t *testing.T) {
got := buildQRContent(guiCardData{Name: "张 三", IDNum: "3301", CardNum: "C-1", CardIDCode: "ID"})
want := "%E5%BC%A0%20%E4%B8%89|3301|C-1|ID"
if got != want {
t.Fatalf("buildQRContent() = %q, want %q", got, want)
}
}
func TestEncodeURIComponentCompatibleCharacters(t *testing.T) {
const input = "AZaz09-_.!~*'() /"
const want = "AZaz09-_.!~*'()%20%2F"
if got := encodeURIComponent(input); got != want {
t.Fatalf("encodeURIComponent() = %q, want %q", got, want)
}
}