mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-22 13:50:49 +01:00
#53 Add ModeHumanReadable and refactor mode tests
Updated mode tests to include a new Mode, ModeHumanReadable, and created an additional test case, ModeComplexNoHumanReadable. This was done because a more human readable mode was required for some use cases. Also added a test function TestMode_String to ensure the .String() method of each mode works as intended.
This commit is contained in:
parent
f3a4b516d1
commit
3cccc65498
1 changed files with 27 additions and 2 deletions
29
mode_test.go
29
mode_test.go
|
@ -52,8 +52,10 @@ func TestModesFromFlags(t *testing.T) {
|
||||||
{"ModeNumber", "N", []Mode{ModeNumber}},
|
{"ModeNumber", "N", []Mode{ModeNumber}},
|
||||||
{"ModeUpperCase", "U", []Mode{ModeUpperCase}},
|
{"ModeUpperCase", "U", []Mode{ModeUpperCase}},
|
||||||
{"ModeSpecial", "S", []Mode{ModeSpecial}},
|
{"ModeSpecial", "S", []Mode{ModeSpecial}},
|
||||||
{"ModeLowerSpecialUpper", "LSU", []Mode{ModeLowerCase, ModeSpecial,
|
{"ModeLowerSpecialUpper", "LSUH", []Mode{ModeHumanReadable,
|
||||||
ModeUpperCase}},
|
ModeLowerCase, ModeSpecial, ModeUpperCase}},
|
||||||
|
{"ModeComplexNoHumanReadable", "Ch", []Mode{ModeLowerCase,
|
||||||
|
ModeNumber, ModeSpecial, ModeUpperCase}},
|
||||||
{"ModeComplexNoLower", "Cl", []Mode{ModeNumber, ModeSpecial,
|
{"ModeComplexNoLower", "Cl", []Mode{ModeNumber, ModeSpecial,
|
||||||
ModeUpperCase}},
|
ModeUpperCase}},
|
||||||
{"ModeComplexNoNumber", "Cn", []Mode{ModeLowerCase, ModeSpecial,
|
{"ModeComplexNoNumber", "Cn", []Mode{ModeLowerCase, ModeSpecial,
|
||||||
|
@ -76,3 +78,26 @@ func TestModesFromFlags(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMode_String(t *testing.T) {
|
||||||
|
tt := []struct {
|
||||||
|
name string
|
||||||
|
m Mode
|
||||||
|
e string
|
||||||
|
}{
|
||||||
|
{"ModeHumanReadable", ModeHumanReadable, "Human-readable"},
|
||||||
|
{"ModeLowerCase", ModeLowerCase, "Lower-case"},
|
||||||
|
{"ModeNumber", ModeNumber, "Number"},
|
||||||
|
{"ModeSpecial", ModeSpecial, "Special"},
|
||||||
|
{"ModeUpperCase", ModeUpperCase, "Upper-case"},
|
||||||
|
{"ModeUnknown", 255, "Unknown"},
|
||||||
|
}
|
||||||
|
for _, tc := range tt {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
if tc.m.String() != tc.e {
|
||||||
|
t.Errorf("Mode.String() failed, expected: %s, got: %s", tc.e,
|
||||||
|
tc.m.String())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue