diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-29 10:56:56 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-08-29 10:56:56 +0900 |
| commit | 7e5c662a6f2e8435f8103bc16185bed6759cc557 (patch) | |
| tree | c8e6fb7cbc431e59400cf6f9200a335462b4ce88 /test/ruby | |
| parent | c4fc9477aa5f77a69a40b619b7144f2b118b772e (diff) | |
[Feature #18183] Add `chars:` option to `Random#alphanumeric`
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_random_formatter.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_random_formatter.rb b/test/ruby/test_random_formatter.rb index a5072099e1..2c01d99b3d 100644 --- a/test/ruby/test_random_formatter.rb +++ b/test/ruby/test_random_formatter.rb @@ -83,6 +83,20 @@ module Random::Formatter end end + def test_alphanumeric_chars + [ + [[*"0".."9"], /\A\d*\z/], + [[*"a".."t"], /\A[a-t]*\z/], + ["一二三四五六七八九十".chars, /\A[一二三四五六七八九十]*\z/], + ].each do |chars, pattern| + 10.times do |n| + an = @it.alphanumeric(n, chars: chars) + assert_match(pattern, an) + assert_equal(n, an.length) + end + end + end + def assert_in_range(range, result, mesg = nil) assert(range.cover?(result), build_message(mesg, "Expected #{result} to be in #{range}")) end |
