From 5616e978fe364a7bf34ff525a74d5703a127fe77 Mon Sep 17 00:00:00 2001 From: Romain Caire Date: Wed, 29 Nov 2023 07:24:21 +0100 Subject: [PATCH] feat: Add Vowels & NoVowels to the AlphaUpper charsets (#749) --- randx/sequence.go | 4 ++++ randx/sequence_test.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/randx/sequence.go b/randx/sequence.go index f3fc5450..0b0163ac 100644 --- a/randx/sequence.go +++ b/randx/sequence.go @@ -21,6 +21,10 @@ var ( AlphaUpperNum = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") // AlphaLower contains runes [abcdefghijklmnopqrstuvwxyz]. AlphaLower = []rune("abcdefghijklmnopqrstuvwxyz") + // AlphaUpperVowels contains runes [AEIOUY]. + AlphaUpperVowels = []rune("AEIOUY") + // AlphaUpperNoVowels contains runes [BCDFGHJKLMNPQRSTVWXZ]. + AlphaUpperNoVowels = []rune("BCDFGHJKLMNPQRSTVWXZ") // AlphaUpper contains runes [ABCDEFGHIJKLMNOPQRSTUVWXYZ]. AlphaUpper = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ") // Numeric contains runes [0123456789]. diff --git a/randx/sequence_test.go b/randx/sequence_test.go index c4d4bf97..7131fa01 100644 --- a/randx/sequence_test.go +++ b/randx/sequence_test.go @@ -18,6 +18,8 @@ func TestRunePatterns(t *testing.T) { {Alpha, "[a-zA-Z]{52}"}, {AlphaLower, "[a-z]{26}"}, {AlphaUpper, "[A-Z]{26}"}, + {AlphaUpperVowels, "[AEIOUY]{6}"}, + {AlphaUpperNoVowels, "[^AEIOUY]{20}"}, {AlphaNum, "[a-zA-Z0-9]{62}"}, {AlphaLowerNum, "[a-z0-9]{36}"}, {AlphaUpperNum, "[A-Z0-9]{36}"}, @@ -38,6 +40,8 @@ func TestRuneSequenceMatchesPattern(t *testing.T) { {Alpha, "[a-zA-Z]+", 25}, {AlphaLower, "[a-z]+", 46}, {AlphaUpper, "[A-Z]+", 21}, + {AlphaUpperVowels, "[AEIOUY]+", 12}, + {AlphaUpperNoVowels, "[^AEIOUY]+", 42}, {AlphaNum, "[a-zA-Z0-9]+", 123}, {AlphaLowerNum, "[a-z0-9]+", 41}, {AlphaUpperNum, "[A-Z0-9]+", 94914},