Files
WebOne-go/internal/textenc/textenc_test.go
T
Claude 81bb843396 Port WebOne 0.19.0 to Go
A Go translation of WebOne (github.com/atauenis/webone, commit e940b43),
the HTTP 1.x proxy that lets old browsers use today's web: config loader
with sets of edits and .NET regular expressions, the HTTP/1.0-1.1 server
with keep-alive, HTTPS fetching and patching, code pages, the CONNECT
proxy (MITM, pass-through, non-HTTP tunnels), the CA and site certificates
(MD5/SHA-1 signing included), internal and error pages, Web Archive
fallback, converters, web FTP client and online video.

WebOne's licence, configuration files and html pages are kept. Go-only
options: SslCaDirectory signs with the D-Modem BBS's proxy sub-CA (or its
root), SslTrustOwnCA, and DnsServer. README lists the differences: no SSL
2.0/3.0 in Go's TLS, and the upstream bugs fixed on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRH4kntyPfrY1bFWC3
2026-11-11 12:34:29 +00:00

37 lines
764 B
Go

package textenc
import (
"bytes"
"testing"
)
func TestRoundTrip(t *testing.T) {
all := make([]byte, 256)
for i := range all {
all[i] = byte(i)
}
for _, cp := range []int{1252, 1251, 866, 437, 28591} {
e := ByCodePage(cp)
if e == nil {
t.Errorf("no code page %d", cp)
continue
}
if got := e.Encode(e.Decode(all)); !bytes.Equal(got, all) {
t.Errorf("%s: bytes change on decode and encode", e.Name)
}
}
}
func TestEncodeUnknown(t *testing.T) {
e := Lookup("windows-1251")
if e == nil {
t.Fatal("no windows-1251")
}
if got := string(e.Encode("Ж€你")); got != "\xc6\x88?" {
t.Errorf("got %q", got)
}
if Lookup("utf-8") != UTF8 || Lookup("koi8-r") == nil || Lookup("x-mac-cyrillic") == nil {
t.Error("lookup by name")
}
}