whyrusleeping / cbor-gen

Codegen for cbor codecs on your types
MIT License
35 stars 25 forks source link

TestDeferredContainer is break on master branch #54

Open NexZhu opened 3 years ago

NexZhu commented 3 years ago

The following test outputs errors on master branch

func TestDeferredContainer(t *testing.T) {
    zero := &DeferredContainer{}
    recepticle := &DeferredContainer{}
    testValueRoundtrip(t, zero, recepticle)
}

Output:

=== RUN   TestDeferredContainer
    roundtrip_test.go:62: &testing.DeferredContainer{Stuff:(*testing.SimpleTypeOne)(nil), Deferred:(*typegen.Deferred)(nil), Value:0x0} != &testing.DeferredContainer{Stuff:(*testing.SimpleTypeOne)(nil), Deferred:(*typegen.Deferred)(0xc000004780), Value:0x0}
    roundtrip_test.go:63: not equal after round trip!
--- PASS: TestDeferredContainer (0.00s)
PASS
Stebalien commented 3 years ago

Looks like this was broken in https://github.com/whyrusleeping/cbor-gen/pull/16. cc @whyrusleeping?

whyrusleeping commented 3 years ago

Ah, looks like its always allocating a deferred object now. Doesnt seem like wrong behaviour, maybe we should adjust the test?

Stebalien commented 3 years ago

Well, it's not behaving like any of the other "null" cases. But I agree that the current code is probably safer (and doesn't affect the final encoding).