mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-22 13:50:49 +01:00
Compare commits
No commits in common. "cff8d507b338a16c7eacaa5c4886931fb69984da" and "d302625908d8f0d295118a97058562ab0f41d15a" have entirely different histories.
cff8d507b3
...
d302625908
2 changed files with 31 additions and 53 deletions
2
.github/workflows/codecov.yml
vendored
2
.github/workflows/codecov.yml
vendored
|
@ -40,6 +40,6 @@ jobs:
|
|||
go test -v -race --coverprofile=coverage.coverprofile --covermode=atomic ./...
|
||||
- name: Upload coverage to Codecov
|
||||
if: success() && matrix.go == '1.22' && matrix.os == 'ubuntu-latest'
|
||||
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4.1.1
|
||||
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
|
||||
|
|
|
@ -523,13 +523,36 @@ func TestGenerate(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGenerator_RandomStringFromCharRange_fail(t *testing.T) {
|
||||
config := NewConfig()
|
||||
gen := New(config)
|
||||
_, err := gen.RandomStringFromCharRange(0, gen.GetCharRangeFromConfig())
|
||||
if err == nil {
|
||||
t.Errorf("RandomStringFromCharRange() with zero length is supposed" +
|
||||
"to fail, but didn't")
|
||||
func BenchmarkGenerator_CoinFlip(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
g := New(NewConfig())
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = g.CoinFlip()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGenerator_RandomBytes(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
g := New(NewConfig())
|
||||
var l int64 = 1024
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := g.RandomBytes(l)
|
||||
if err != nil {
|
||||
b.Errorf("failed to generate random bytes: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGenerator_RandomString(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
g := New(NewConfig())
|
||||
cr := CharRangeAlphaUpper + CharRangeAlphaLower + CharRangeNumeric + CharRangeSpecial
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := g.RandomStringFromCharRange(32, cr)
|
||||
if err != nil {
|
||||
b.Errorf("RandomStringFromCharRange() failed: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -567,48 +590,3 @@ func TestGenerator_generateBinary(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerator_checkMinimumRequirements_human(t *testing.T) {
|
||||
config := NewConfig(WithModeMask(ModeLowerCase|ModeUpperCase|ModeNumeric|
|
||||
ModeSpecial|ModeHumanReadable), WithMinLowercase(1), WithMinUppercase(1),
|
||||
WithMinNumeric(1), WithMinSpecial(1))
|
||||
gen := New(config)
|
||||
pw, err := gen.Generate()
|
||||
if err != nil {
|
||||
t.Errorf("Generate() failed: %s", err)
|
||||
}
|
||||
_ = gen.checkMinimumRequirements(pw)
|
||||
}
|
||||
|
||||
func BenchmarkGenerator_CoinFlip(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
g := New(NewConfig())
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = g.CoinFlip()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGenerator_RandomBytes(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
g := New(NewConfig())
|
||||
var l int64 = 1024
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := g.RandomBytes(l)
|
||||
if err != nil {
|
||||
b.Errorf("failed to generate random bytes: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkGenerator_RandomString(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
g := New(NewConfig())
|
||||
cr := CharRangeAlphaUpper + CharRangeAlphaLower + CharRangeNumeric + CharRangeSpecial
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := g.RandomStringFromCharRange(32, cr)
|
||||
if err != nil {
|
||||
b.Errorf("RandomStringFromCharRange() failed: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue