apg-go/algo_test.go
Winni Neessen acadccc84a
Add binary mode for secret generation
This commit updates the password generator to now include a binary mode. This mode produces a 256 bits long fully binary secret which can be used for AES-256 encryption. New flags `-bh` (print hex representation) and `-bn` (new line after secret) have been added for this mode. The version has also been updated to 1.0.1 recognizing this new addition.
2024-03-17 18:09:27 +01:00

31 lines
622 B
Go

// SPDX-FileCopyrightText: 2021-2024 Winni Neessen <wn@neessen.dev>
//
// SPDX-License-Identifier: MIT
package apg
import (
"testing"
)
func TestIntToAlgo(t *testing.T) {
tt := []struct {
name string
a int
e Algorithm
}{
{"AlgoPronounceable", 0, AlgoPronounceable},
{"AlgoRandom", 1, AlgoRandom},
{"AlgoCoinflip", 2, AlgoCoinFlip},
{"AlgoBinary", 3, AlgoBinary},
{"AlgoUnsupported", 4, AlgoUnsupported},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
a := IntToAlgo(tc.a)
if a != tc.e {
t.Errorf("IntToAlgo() failed, expected: %d, got: %d", tc.e, a)
}
})
}
}