2024-01-10 17:23:08 +01:00
|
|
|
package rnd
|
|
|
|
|
|
|
|
import (
|
2024-01-13 16:27:05 +01:00
|
|
|
"strings"
|
2024-01-10 17:23:08 +01:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestName(t *testing.T) {
|
2024-01-13 16:27:05 +01:00
|
|
|
name := Name()
|
|
|
|
assert.NotEmpty(t, name)
|
|
|
|
assert.Equal(t, 1, strings.Count(name, " "))
|
2024-01-10 17:23:08 +01:00
|
|
|
|
|
|
|
for n := 0; n < 10; n++ {
|
|
|
|
s := Name()
|
|
|
|
t.Logf("Name %d: %s", n, s)
|
2024-01-13 16:27:05 +01:00
|
|
|
assert.NotEmpty(t, s)
|
|
|
|
assert.Equal(t, 1, strings.Count(s, " "))
|
2024-01-10 17:23:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkName(b *testing.B) {
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
|
|
Name()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNameN(t *testing.T) {
|
2024-01-13 16:27:05 +01:00
|
|
|
name := NameN(2)
|
|
|
|
assert.NotEmpty(t, name)
|
|
|
|
assert.Equal(t, 1, strings.Count(name, " "))
|
2024-01-10 17:23:08 +01:00
|
|
|
|
|
|
|
for n := 0; n < 10; n++ {
|
|
|
|
s := NameN(n + 1)
|
|
|
|
t.Logf("NameN %d: %s", n, s)
|
2024-01-13 16:27:05 +01:00
|
|
|
assert.NotEmpty(t, s)
|
|
|
|
assert.Equal(t, n, strings.Count(s, " "))
|
2024-01-10 17:23:08 +01:00
|
|
|
}
|
|
|
|
}
|