Add flags byte array check
This commit is contained in:
parent
a6b57c92a9
commit
3e5a7cf322
@ -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.
|
||||
//
|
||||
|
@ -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])
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user