1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/common/bitmask/byte_test.go

28 lines
410 B
Go
Raw Normal View History

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
}