mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-09 15:52:54 +01:00
Reorder modes and add new test for modes
The ordering of modes in the existing test was changed to logically group them together. In addition, a new test was added, `TestModesFromFlags`, to cover multiple different conditions including complex modes and cases where certain mode elements are excluded. This expansion in testing enhances our coverage of varied mode settings.
This commit is contained in:
parent
704269d0b8
commit
f3a4b516d1
1 changed files with 42 additions and 4 deletions
46
mode_test.go
46
mode_test.go
|
@ -9,11 +9,11 @@ func TestSetClearHasToggleMode(t *testing.T) {
|
|||
name string
|
||||
mode Mode
|
||||
}{
|
||||
{"ModeNumber", ModeNumber},
|
||||
{"ModeLowerCase", ModeLowerCase},
|
||||
{"ModeUpperCase", ModeUpperCase},
|
||||
{"ModeSpecial", ModeSpecial},
|
||||
{"ModeHumanReadable", ModeHumanReadable},
|
||||
{"ModeLowerCase", ModeLowerCase},
|
||||
{"ModeNumber", ModeNumber},
|
||||
{"ModeSpecial", ModeSpecial},
|
||||
{"ModeUpperCase", ModeUpperCase},
|
||||
}
|
||||
|
||||
for _, tc := range tt {
|
||||
|
@ -38,3 +38,41 @@ func TestSetClearHasToggleMode(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestModesFromFlags(t *testing.T) {
|
||||
tt := []struct {
|
||||
name string
|
||||
ms string
|
||||
mode []Mode
|
||||
}{
|
||||
{"ModeComplex", "C", []Mode{ModeLowerCase, ModeNumber, ModeSpecial,
|
||||
ModeUpperCase}},
|
||||
{"ModeHumanReadable", "H", []Mode{ModeHumanReadable}},
|
||||
{"ModeLowerCase", "L", []Mode{ModeLowerCase}},
|
||||
{"ModeNumber", "N", []Mode{ModeNumber}},
|
||||
{"ModeUpperCase", "U", []Mode{ModeUpperCase}},
|
||||
{"ModeSpecial", "S", []Mode{ModeSpecial}},
|
||||
{"ModeLowerSpecialUpper", "LSU", []Mode{ModeLowerCase, ModeSpecial,
|
||||
ModeUpperCase}},
|
||||
{"ModeComplexNoLower", "Cl", []Mode{ModeNumber, ModeSpecial,
|
||||
ModeUpperCase}},
|
||||
{"ModeComplexNoNumber", "Cn", []Mode{ModeLowerCase, ModeSpecial,
|
||||
ModeUpperCase}},
|
||||
{"ModeComplexNoSpecial", "Cs", []Mode{ModeLowerCase, ModeNumber,
|
||||
ModeUpperCase}},
|
||||
{"ModeComplexNoUpper", "Cu", []Mode{ModeLowerCase, ModeNumber,
|
||||
ModeSpecial}},
|
||||
}
|
||||
for _, tc := range tt {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var mm ModeMask
|
||||
mm = ModesFromFlags(tc.ms)
|
||||
for _, tm := range tc.mode {
|
||||
if !MaskHasMode(mm, tm) {
|
||||
t.Errorf("ModesFromFlags() failed, expected mode %q not found",
|
||||
tm)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue