apg-go/algo_test.go
Winni Neessen 69bb1e4cb7
#53 Add tests and refactor Algorithm constants
Test suite `TestIntToAlgo` was added to `algo_test.go` to validate `IntToAlgo` function. Additionally, Algorithm constants in `algo.go` have been prefixed with "Algo". These changes were made in order to make the code clearer and ensure the function returns the expected values for the given inputs.
2023-08-04 20:35:31 +02:00

23 lines
441 B
Go

package apg
import "testing"
func TestIntToAlgo(t *testing.T) {
tt := []struct {
name string
a int
e Algorithm
}{
{"AlgoPronouncable", 0, AlgoPronouncable},
{"AlgoRandom", 1, AlgoRandom},
{"AlgoUnsupported", 2, 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)
}
})
}
}