Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ioppermann committed Mar 19, 2024
1 parent c7ee4f1 commit 3a43cd7
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions internal/rand/rand_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package rand

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestRandomString(t *testing.T) {
s1, err := RandomString(42, AlphaNumericCharset)
require.NoError(t, err)

s2, err := RandomString(42, AlphaNumericCharset)
require.NoError(t, err)

require.NotEqual(t, s1, s2)
}

func TestUint32(t *testing.T) {
u1, err := Uint32()
require.NoError(t, err)

u2, err := Uint32()
require.NoError(t, err)

require.NotEqual(t, u1, u2)
}

func TestInt63(t *testing.T) {
u1, err := Int63()
require.NoError(t, err)

u2, err := Int63()
require.NoError(t, err)

require.NotEqual(t, u1, u2)
}

func TestInt63n(t *testing.T) {
u1, err := Int63n(42)
require.NoError(t, err)

u2, err := Int63n(42)
require.NoError(t, err)

require.NotEqual(t, u1, u2)

u3, err := Int63n(64)
require.NoError(t, err)

u4, err := Int63n(64)
require.NoError(t, err)

require.NotEqual(t, u3, u4)
}

0 comments on commit 3a43cd7

Please sign in to comment.