2023-08-04 16:02:58 +02:00
|
|
|
package apg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSetClearHasToggleMode(t *testing.T) {
|
|
|
|
tt := []struct {
|
|
|
|
name string
|
|
|
|
mode Mode
|
|
|
|
}{
|
|
|
|
{"ModeNumber", ModeNumber},
|
|
|
|
{"ModeLowerCase", ModeLowerCase},
|
|
|
|
{"ModeUpperCase", ModeUpperCase},
|
|
|
|
{"ModeSpecial", ModeSpecial},
|
|
|
|
{"ModeHumanReadable", ModeHumanReadable},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range tt {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
2023-08-04 17:14:24 +02:00
|
|
|
var m ModeMask
|
|
|
|
m = MaskSetMode(m, tc.mode)
|
|
|
|
if !MaskHasMode(m, tc.mode) {
|
|
|
|
t.Errorf("MaskSetMode() failed, mode not found in bitmask")
|
2023-08-04 16:02:58 +02:00
|
|
|
}
|
2023-08-04 17:14:24 +02:00
|
|
|
m = MaskToggleMode(m, tc.mode)
|
|
|
|
if MaskHasMode(m, tc.mode) {
|
|
|
|
t.Errorf("MaskToggleMode() failed, mode found in bitmask")
|
2023-08-04 16:02:58 +02:00
|
|
|
}
|
2023-08-04 17:14:24 +02:00
|
|
|
m = MaskToggleMode(m, tc.mode)
|
|
|
|
if !MaskHasMode(m, tc.mode) {
|
|
|
|
t.Errorf("MaskToggleMode() failed, mode not found in bitmask")
|
2023-08-04 16:02:58 +02:00
|
|
|
}
|
2023-08-04 17:14:24 +02:00
|
|
|
m = MaskClearMode(m, tc.mode)
|
|
|
|
if MaskHasMode(m, tc.mode) {
|
|
|
|
t.Errorf("MaskClearMode() failed, mode found in bitmask")
|
2023-08-04 16:02:58 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|