MCPcopy
hub / github.com/uber-go/zap / roundTripsCorrectly

Function roundTripsCorrectly

zapcore/json_encoder_impl_test.go:611–622  ·  view source on GitHub ↗
(encode func(string) []byte, original string)

Source from the content-addressed store, hash-verified

609}
610
611func roundTripsCorrectly(encode func(string) []byte, original string) bool {
612 // Encode using our encoder, decode using the standard library, and assert
613 // that we haven't lost any information.
614 encoded := encode(original)
615
616 var decoded string
617 err := json.Unmarshal(encoded, &decoded)
618 if err != nil {
619 return false
620 }
621 return original == decoded
622}
623
624func roundTripsCorrectlyString(original string) bool {
625 return roundTripsCorrectly(zapEncode((*jsonEncoder).safeAddString), original)

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected