apg-go/mode_test.go
Winni Neessen ac97b94ec9
Refactor generator and add config options
Refactored the generator to include a new config option, changed function signatures to follow the new structure, and renamed the function 'RandomString' to 'RandomStringFromCharRange' for clarity. Also, added a new mode and algorithm feature to enhance password generation. Furthermore, added several tests for new features and configurations. Adapted the CLI to use the new configuration approach. This refactoring was necessary to improve the customizability and clarity of the password generation process. Fixed minor issues and added '.gitignore' for clean commits in the future.
2023-08-04 16:02:58 +02:00

40 lines
890 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 Mode
m = SetMode(m, tc.mode)
if !HasMode(m, tc.mode) {
t.Errorf("SetMode() failed, mode not found in bitmask")
}
m = ToggleMode(m, tc.mode)
if HasMode(m, tc.mode) {
t.Errorf("ToggleMode() failed, mode found in bitmask")
}
m = ToggleMode(m, tc.mode)
if !HasMode(m, tc.mode) {
t.Errorf("ToggleMode() failed, mode not found in bitmask")
}
m = ClearMode(m, tc.mode)
if HasMode(m, tc.mode) {
t.Errorf("ClearMode() failed, mode found in bitmask")
}
})
}
}