MCPcopy
hub / github.com/bitfield/script / TestEncodeBase64_FollowedByDecodeRecoversOriginal

Function TestEncodeBase64_FollowedByDecodeRecoversOriginal

script_test.go:2015–2035  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2013}
2014
2015func TestEncodeBase64_FollowedByDecodeRecoversOriginal(t *testing.T) {
2016 t.Parallel()
2017 for _, tc := range base64Cases {
2018 t.Run(tc.name, func(t *testing.T) {
2019 decoded, err := script.Echo(tc.decoded).EncodeBase64().DecodeBase64().String()
2020 if err != nil {
2021 t.Fatal(err)
2022 }
2023 if decoded != tc.decoded {
2024 t.Error("encode-decode round trip failed:", cmp.Diff(tc.decoded, decoded))
2025 }
2026 encoded, err := script.Echo(tc.encoded).DecodeBase64().EncodeBase64().String()
2027 if err != nil {
2028 t.Fatal(err)
2029 }
2030 if encoded != tc.encoded {
2031 t.Error("decode-encode round trip failed:", cmp.Diff(tc.encoded, encoded))
2032 }
2033 })
2034 }
2035}
2036
2037func TestDecodeBase64_CorrectlyDecodesInputToBytes(t *testing.T) {
2038 t.Parallel()

Callers

nothing calls this directly

Calls 5

EchoFunction · 0.92
StringMethod · 0.80
DecodeBase64Method · 0.80
EncodeBase64Method · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…