go-vise

Constrained Size Output Virtual Machine
Info | Log | Files | Refs | README | LICENSE

commit 3e5a7cf322892e59786a71a1395fe34bd89730fe
parent a6b57c92a9af102c5e630935b7fb5923296970be
Author: lash <dev@holbrook.no>
Date:   Fri, 31 Mar 2023 23:25:05 +0100

Add flags byte array check

Diffstat:
Mgo/state/state.go | 2+-
Mgo/state/state_test.go | 12++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/go/state/state.go b/go/state/state.go @@ -52,7 +52,7 @@ func NewState(bitSize uint32) State { return st } -// SetFlag sets the flag at the given bit field index. +// SetFlag sets the flag at the given bit field index // // Returns true if bit state was changed. // diff --git a/go/state/state_test.go b/go/state/state_test.go @@ -1,6 +1,7 @@ package state import ( + "bytes" "testing" ) @@ -85,6 +86,17 @@ func TestStateFlags(t *testing.T) { if v { t.Errorf("Expected change not to be set for bit 10") } + v, err = st.SetFlag(2) + if err != nil { + t.Error(err) + } + v, err = st.SetFlag(19) + if err != nil { + t.Error(err) + } + if !bytes.Equal(st.Flags[:3], []byte{0x04, 0x04, 0x08}) { + t.Errorf("Expected 0x020203, got %v", st.Flags[:3]) + } } //