habbgo/text/string_test.go

22 lines
844 B
Go
Raw Normal View History

2021-09-16 05:27:15 +00:00
package text
import (
"testing"
2022-01-08 22:29:51 +00:00
"github.com/stretchr/testify/require"
2021-09-16 05:27:15 +00:00
)
func TestContainsAllowedChars(t *testing.T) {
allowedChars := "1234567890qwertyuiopasdfghjklzxcvbnm_-+=?!@:.,$"
require.True(t, ContainsAllowedChars("1", allowedChars))
require.False(t, ContainsAllowedChars(" lazar", allowedChars))
require.False(t, ContainsAllowedChars("la zar", allowedChars))
require.False(t, ContainsAllowedChars("lazar ", allowedChars))
require.False(t, ContainsAllowedChars("~ghost", allowedChars))
require.True(t, ContainsAllowedChars("____________", allowedChars))
require.True(t, ContainsAllowedChars("0nem", allowedChars))
require.True(t, ContainsAllowedChars("123456", allowedChars))
require.False(t, ContainsAllowedChars("!---the winner---!", allowedChars))
require.True(t, ContainsAllowedChars("____________", allowedChars))
}