MCPcopy
hub / github.com/connectrpc/connect-go / assertCodeRoundTrips

Function assertCodeRoundTrips

code_test.go:44–56  ·  view source on GitHub ↗
(tb testing.TB, code Code)

Source from the content-addressed store, hash-verified

42}
43
44func assertCodeRoundTrips(tb testing.TB, code Code) {
45 tb.Helper()
46 encoded, err := code.MarshalText()
47 assert.Nil(tb, err)
48 var decoded Code
49 assert.Nil(tb, decoded.UnmarshalText(encoded))
50 assert.Equal(tb, decoded, code)
51 if code >= minCode && code <= maxCode {
52 var invalid Code
53 // For the known codes, we only accept the canonical string representation: "canceled", not "code_1".
54 assert.NotNil(tb, invalid.UnmarshalText([]byte("code_"+strconv.Itoa(int(code)))))
55 }
56}

Callers 1

TestCodeFunction · 0.85

Calls 5

UnmarshalTextMethod · 0.95
NilFunction · 0.92
EqualFunction · 0.92
NotNilFunction · 0.92
MarshalTextMethod · 0.80

Tested by

no test coverage detected