LCOV - code coverage report
Current view: top level - pebble/internal/testutils - rng.go (source / functions) Hit Total Coverage
Test: 2024-12-10 08:17Z 0f9bf63d - tests only.lcov Lines: 10 12 83.3 %
Date: 2024-12-10 08:17:35 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2024 The LevelDB-Go and Pebble Authors. All rights reserved. Use
       2             : // of this source code is governed by a BSD-style license that can be found in
       3             : // the LICENSE file.
       4             : 
       5             : package testutils
       6             : 
       7             : import "math/rand/v2"
       8             : 
       9             : // RandIntInRange returns a value in [min, max)
      10           1 : func RandIntInRange(r *rand.Rand, min, max int) int {
      11           1 :         return min + r.IntN(max-min)
      12           1 : }
      13             : 
      14             : var randLetters = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
      15             : 
      16             : // RandBytes returns a byte slice of the given length with random
      17             : // data.
      18           1 : func RandBytes(r *rand.Rand, size int) []byte {
      19           1 :         if size <= 0 {
      20           0 :                 return nil
      21           0 :         }
      22             : 
      23           1 :         arr := make([]byte, size)
      24           1 :         for i := 0; i < len(arr); i++ {
      25           1 :                 arr[i] = randLetters[r.IntN(len(randLetters))]
      26           1 :         }
      27           1 :         return arr
      28             : }

Generated by: LCOV version 1.14