package tools import "testing" func TestDecodeBase64AcceptsWhitespaceAndMultipleVariants(t *testing.T) { tests := []struct { name string input string want string }{ {name: "standard with whitespace", input: "aG V s\nbG8=", want: "hello"}, {name: "raw standard", input: "aGVsbG8", want: "hello"}, {name: "standard url-safe payload", input: "--8=", want: string([]byte{0xfb, 0xef})}, {name: "raw url-safe payload", input: "--8", want: string([]byte{0xfb, 0xef})}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { got, err := decodeBase64(tc.input) if err != nil { t.Fatalf("decodeBase64(%q) error = %v", tc.input, err) } if string(got) != tc.want { t.Fatalf("decodeBase64(%q) = %q, want %q", tc.input, string(got), tc.want) } }) } }