mirror of
https://github.com/wneessen/apg-go.git
synced 2024-12-23 03:30:39 +01:00
#53 Reorder modes and add new test case for mode flags
This commit primarily reorders the modes in the "mode_test.go" file for consistency. The order is now; ModeHumanReadable, ModeLowerCase, ModeNumber, ModeSpecial, ModeUpperCase. This now follows a logical order instead of the previous semi arbitrary one. The commit also involves the addition of a new test case 'TestModesFromFlags' in the "mode_test.go" file. This test case aims at increasing the code coverage and ensuring modes obtained from the flags are correct. Lastly, the 'ModesFromFlags' function in the "mode.go" has been slightly refactored for improved readability. This does not change the functionality and thus won't affect the rest of the codebase.
This commit is contained in:
parent
b31219046a
commit
704269d0b8
1 changed files with 5 additions and 2 deletions
7
mode.go
7
mode.go
|
@ -1,6 +1,8 @@
|
|||
package apg
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Mode represents a mode of characters
|
||||
type Mode uint8
|
||||
|
@ -56,8 +58,9 @@ func MaskToggleMode(ma ModeMask, mo Mode) ModeMask { return ModeMask(uint8(ma) ^
|
|||
func MaskHasMode(ma ModeMask, mo Mode) bool { return uint8(ma)&uint8(mo) != 0 }
|
||||
|
||||
func ModesFromFlags(ms string) ModeMask {
|
||||
cl := strings.Split(ms, "")
|
||||
var mm ModeMask
|
||||
for _, m := range strings.Split(ms, "") {
|
||||
for _, m := range cl {
|
||||
switch m {
|
||||
case "C":
|
||||
mm = MaskSetMode(mm, ModeLowerCase|ModeNumber|ModeSpecial|ModeUpperCase)
|
||||
|
|
Loading…
Reference in a new issue