Open joonas-fi opened 3 years ago
This test passes, i.e. it correctly unpacks both fields:
type Foo struct { HasOptional uint8 Optional uint8 `struct:"if=HasOptional == 1"` } func TestFoobar(t *testing.T) { item := &Foo{} restruct.Unpack([]byte{1, 2}, binary.LittleEndian, item) assert.EqualString(t, fmt.Sprintf("%v", item), "&{1 2}") }
But this does not:
type HasOptionalFlag uint8 type Foo struct { HasOptional HasOptionalFlag Optional uint8 `struct:"if=HasOptional == 1"` }
I get exp=&{1 2}; got=&{1 0}
exp=&{1 2}; got=&{1 0}
The if= seems to evaluate to false. Might be related to #43
if=
This test passes, i.e. it correctly unpacks both fields:
But this does not:
I get
exp=&{1 2}; got=&{1 0}
The
if=
seems to evaluate to false. Might be related to #43