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

Function TestNullUUIDMarshalText

null_test.go:72–102  ·  null_test.go::TestNullUUIDMarshalText
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestNullUUIDMarshalText(t *testing.T) {
73 tests := []struct {
74 nullUUID NullUUID
75 }{
76 {
77 nullUUID: NullUUID{},
78 },
79 {
80 nullUUID: NullUUID{
81 UUID: MustParse("12345678-abcd-1234-abcd-0123456789ab"),
82 Valid: true,
83 },
84 },
85 }
86 for _, test := range tests {
87 var uText []byte
88 var uErr error
89 nuText, nuErr := test.nullUUID.MarshalText()
90 if test.nullUUID.Valid {
91 uText, uErr = test.nullUUID.UUID.MarshalText()
92 } else {
93 uText = []byte("null")
94 }
95 if nuErr != uErr {
96 t.Errorf("expected error %e, got %e", nuErr, uErr)
97 }
98 if !bytes.Equal(nuText, uText) {
99 t.Errorf("expected text data %s, got %s", string(nuText), string(uText))
100 }
101 }
102}
103
104func TestNullUUIDUnmarshalText(t *testing.T) {
105 tests := []struct {

Callers

nothing calls this directly

Calls 2

MustParseFunction · 0.85
MarshalTextMethod · 0.45

Tested by

no test coverage detected