MCPcopy Index your code
hub / github.com/coder/coder / TestInt63n

Function TestInt63n

cryptorand/numbers_test.go:22–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20}
21
22func TestInt63n(t *testing.T) {
23 t.Parallel()
24
25 for i := 0; i < 20; i++ {
26 v, err := cryptorand.Int63n(100)
27 require.NoError(t, err, "unexpected error from Int63n")
28 t.Logf("value: %v <- random?", v)
29 require.GreaterOrEqual(t, v, int64(0), "values must be positive")
30 require.Less(t, v, int64(100), "values must be less than 100")
31 }
32
33 // Ensure Int63n works for int larger than 32 bits
34 _, err := cryptorand.Int63n(1 << 35)
35 require.NoError(t, err, "expected Int63n to work for 64-bit int")
36
37 // Expect a panic if max is negative
38 require.PanicsWithValue(t, "invalid argument to Int63n", func() {
39 cryptorand.Int63n(0)
40 })
41}
42
43func TestIntn(t *testing.T) {
44 t.Parallel()

Callers

nothing calls this directly

Calls 3

Int63nFunction · 0.92
LessMethod · 0.80
LogfMethod · 0.65

Tested by

no test coverage detected