Class: JSON::Fuzz::Generator::Keyword::MaxLength

Inherits:
Object
  • Object
show all
Defined in:
lib/json/fuzz/generator/keyword/max_length.rb

Class Method Summary collapse

Class Method Details

.invalid_params(attributes) ⇒ Object

[View source]

7
8
9
10
11
12
13
14
15
16
# File 'lib/json/fuzz/generator/keyword/max_length.rb', line 7

def invalid_params(attributes)
  max_length = attributes["maxLength"]
  raise "No maxLength keyword given: #{attributes}" unless max_length

  generated_params = []

  generated_params << /\w{1}/.gen * (max_length + 1)

  return generated_params
end

.valid_param(attributes) ⇒ Object

[View source]

18
19
20
21
22
23
# File 'lib/json/fuzz/generator/keyword/max_length.rb', line 18

def valid_param(attributes)
  max_length = attributes["maxLength"]
  raise "No maxLength keyword given: #{attributes}" unless max_length

  /\w{1}/.gen * max_length
end