mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-12 17:02:56 +01:00
Winni Neessen
b31219046a
The naming and handling of mode bitmasks have been refactored for improved code readability and maintainability. The term "Mode" was replaced with "ModeMask" for clarity and all associated functions were renamed accordingly (e.g., "SetMode" to "MaskSetMode"). These changes provide better insight into the function of the code and increase understandability for future development efforts. The command-line utility now also supports specifying modes via the "-M" flag.
40 lines
942 B
Go
40 lines
942 B
Go
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) {
|
|
var m ModeMask
|
|
m = MaskSetMode(m, tc.mode)
|
|
if !MaskHasMode(m, tc.mode) {
|
|
t.Errorf("MaskSetMode() failed, mode not found in bitmask")
|
|
}
|
|
m = MaskToggleMode(m, tc.mode)
|
|
if MaskHasMode(m, tc.mode) {
|
|
t.Errorf("MaskToggleMode() failed, mode found in bitmask")
|
|
}
|
|
m = MaskToggleMode(m, tc.mode)
|
|
if !MaskHasMode(m, tc.mode) {
|
|
t.Errorf("MaskToggleMode() failed, mode not found in bitmask")
|
|
}
|
|
m = MaskClearMode(m, tc.mode)
|
|
if MaskHasMode(m, tc.mode) {
|
|
t.Errorf("MaskClearMode() failed, mode found in bitmask")
|
|
}
|
|
})
|
|
}
|
|
}
|