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