Add flags byte array check

This commit is contained in:
lash 2023-03-31 23:25:05 +01:00
parent a6b57c92a9
commit 3e5a7cf322
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 13 additions and 1 deletions

View File

@ -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.
//

View File

@ -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])
}
}
//