Skip to content

Commit

Permalink
処理の効率化
Browse files Browse the repository at this point in the history
  • Loading branch information
Hueter57 committed Jul 5, 2024
1 parent 81b2729 commit c6e53f8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions testutil/random/ramdom.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,23 @@ const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
// この関数はmath/randが生成する擬似乱数を使用します
func AlphaNumeric(t *testing.T, n int) string {
t.Helper()
b := make([]byte, n)

var result string
for i := 0; i < n; i++ {
result += string(letters[rand.IntN(len(letters))])
for i := range n {
b[i] = letters[rand.IntN(len(letters))]
}

return result
return string(b)
}

func Numeric(t *testing.T, max int) int {
t.Helper()
n := rand.IntN(max)
return n
return rand.IntN(max)
}

func Numeric64(t *testing.T, max int64) int64 {
t.Helper()
n := rand.Int64N(max)
return n
return rand.Int64N(max)

Check warning on line 30 in testutil/random/ramdom.go

View check run for this annotation

Codecov / codecov/patch

testutil/random/ramdom.go#L30

Added line #L30 was not covered by tests
}

func AlphaNumericSlice(t *testing.T, length int, max int64) []string {
Expand Down

0 comments on commit c6e53f8

Please sign in to comment.