mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-09 15:52:54 +01:00
Add test for excluded characters in config
A new unit test has been added to verify GetCharRangeFromConfig() function. The test ensures that the function properly excludes configured characters from the generated range.
This commit is contained in:
parent
ddae28d1a9
commit
9bb78748be
1 changed files with 17 additions and 0 deletions
|
@ -220,6 +220,23 @@ func TestGetCharRangeFromConfig(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGetCharRangeFromConfig_ExcludeChar(t *testing.T) {
|
||||
defaultConf := NewConfig()
|
||||
defaultGen := New(defaultConf)
|
||||
defaultRange := defaultGen.GetCharRangeFromConfig()
|
||||
defaultRange = strings.ReplaceAll(defaultRange, "a", "")
|
||||
defaultRange = strings.ReplaceAll(defaultRange, "b", "")
|
||||
|
||||
config := NewConfig(WithExcludeChars("ab"))
|
||||
generator := New(config)
|
||||
excludeRange := generator.GetCharRangeFromConfig()
|
||||
|
||||
if excludeRange != defaultRange {
|
||||
t.Errorf("GetCharRangeFromConfig(WithExcludeChars()) failed. Expected"+
|
||||
"char range: %s, got: %s", defaultRange, excludeRange)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPasswordLength(t *testing.T) {
|
||||
config := NewConfig()
|
||||
generator := New(config)
|
||||
|
|
Loading…
Reference in a new issue