MCPcopy
hub / github.com/google/uuid / TestNullUUIDUnmarshalText

Function TestNullUUIDUnmarshalText

null_test.go:104–134  ·  null_test.go::TestNullUUIDUnmarshalText
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestNullUUIDUnmarshalText(t *testing.T) {
105 tests := []struct {
106 nullUUID NullUUID
107 }{
108 {
109 nullUUID: NullUUID{},
110 },
111 {
112 nullUUID: NullUUID{
113 UUID: MustParse("12345678-abcd-1234-abcd-0123456789ab"),
114 Valid: true,
115 },
116 },
117 }
118 for _, test := range tests {
119 var uText []byte
120 var uErr error
121 nuText, nuErr := test.nullUUID.MarshalText()
122 if test.nullUUID.Valid {
123 uText, uErr = test.nullUUID.UUID.MarshalText()
124 } else {
125 uText = []byte("null")
126 }
127 if nuErr != uErr {
128 t.Errorf("expected error %e, got %e", nuErr, uErr)
129 }
130 if !bytes.Equal(nuText, uText) {
131 t.Errorf("expected text data %s, got %s", string(nuText), string(uText))
132 }
133 }
134}
135
136func TestNullUUIDMarshalBinary(t *testing.T) {
137 tests := []struct {

Callers

nothing calls this directly

Calls 2

MustParseFunction · 0.85
MarshalTextMethod · 0.45

Tested by

no test coverage detected