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

Function TestIntn

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

Source from the content-addressed store, hash-verified

41}
42
43func TestIntn(t *testing.T) {
44 t.Parallel()
45
46 for i := 0; i < 20; i++ {
47 v, err := cryptorand.Intn(100)
48 require.NoError(t, err, "unexpected error from Intn")
49 t.Logf("value: %v <- random?", v)
50 require.GreaterOrEqual(t, v, 0, "values must be positive")
51 require.True(t, v < 100, "values must be less than 100")
52 }
53
54 // Ensure Intn works for int larger than 32 bits
55 _, err := cryptorand.Intn(1 << 35)
56 require.NoError(t, err, "expected Intn to work for 64-bit int")
57
58 // Expect a panic if max is negative
59 require.PanicsWithValue(t, "invalid argument to Intn", func() {
60 cryptorand.Intn(0)
61 })
62}
63
64func TestFloat64(t *testing.T) {
65 t.Parallel()

Callers

nothing calls this directly

Calls 2

IntnFunction · 0.92
LogfMethod · 0.65

Tested by

no test coverage detected