2017-10-21 19:04:24 +00:00
|
|
|
package bitmask_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
. "v2ray.com/core/common/bitmask"
|
2017-10-24 14:15:35 +00:00
|
|
|
. "v2ray.com/ext/assert"
|
2017-10-21 19:04:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestBitmaskByte(t *testing.T) {
|
2017-10-24 14:15:35 +00:00
|
|
|
assert := With(t)
|
2017-10-21 19:04:24 +00:00
|
|
|
|
|
|
|
b := Byte(0)
|
|
|
|
b.Set(Byte(1))
|
2017-10-24 14:15:35 +00:00
|
|
|
assert(b.Has(1), IsTrue)
|
2017-10-21 19:04:24 +00:00
|
|
|
|
|
|
|
b.Set(Byte(2))
|
2017-10-24 14:15:35 +00:00
|
|
|
assert(b.Has(2), IsTrue)
|
|
|
|
assert(b.Has(1), IsTrue)
|
2017-10-21 19:04:24 +00:00
|
|
|
|
|
|
|
b.Clear(Byte(1))
|
2017-10-24 14:15:35 +00:00
|
|
|
assert(b.Has(2), IsTrue)
|
|
|
|
assert(b.Has(1), IsFalse)
|
2017-10-21 19:04:24 +00:00
|
|
|
|
|
|
|
b.Toggle(Byte(2))
|
2017-10-24 14:15:35 +00:00
|
|
|
assert(b.Has(2), IsFalse)
|
2017-10-21 19:04:24 +00:00
|
|
|
}
|