Skip to content

Commit a03e25a

Browse files
committed
Test Clear
1 parent 7753582 commit a03e25a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

bitmask_test.go

+47
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,50 @@ func TestSet(t *testing.T) {
104104
)
105105
})
106106
}
107+
108+
func TestClear(t *testing.T) {
109+
t.Run("With empty flag", func(t *testing.T) {
110+
assert.Equal(
111+
t,
112+
bitmask.New[Mask](Flag1, Flag2),
113+
bitmask.Clear(
114+
bitmask.New[Mask](Flag1, Flag2),
115+
EmptyFlag,
116+
),
117+
"Clear with empty flag must not modify the mask",
118+
)
119+
})
120+
t.Run("With unset flag", func(t *testing.T) {
121+
assert.Equal(
122+
t,
123+
bitmask.New[Mask](Flag2),
124+
bitmask.Clear(
125+
bitmask.New[Mask](Flag2),
126+
Flag1,
127+
),
128+
"Clear with an unset flag must not modify the mask",
129+
)
130+
})
131+
t.Run("With empty mask", func(t *testing.T) {
132+
assert.Equal(
133+
t,
134+
EmptyMask,
135+
bitmask.Clear(
136+
EmptyMask,
137+
Flag1,
138+
),
139+
"Clear with an empty mask must not modify it",
140+
)
141+
})
142+
t.Run("With real flag", func(t *testing.T) {
143+
assert.Equal(
144+
t,
145+
EmptyMask,
146+
bitmask.Clear(
147+
bitmask.New[Mask](Flag1),
148+
Flag1,
149+
),
150+
"Clear with a flag on a mask with that flag must clear the flag",
151+
)
152+
})
153+
}

0 commit comments

Comments
 (0)