Class: FuzzBert::Mutator
Instance Attribute Summary
Attributes inherited from Generator
Instance Method Summary collapse
-
#initialize(value) ⇒ Mutator
constructor
A new instance of Mutator.
Methods inherited from Generator
Methods included from Generation
Constructor Details
#initialize(value) ⇒ Mutator
Returns a new instance of Mutator.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fuzzbert/mutator.rb', line 4 def initialize(value) orig = value.dup orig.force_encoding(Encoding::BINARY) super("Mutator") do #select a byte i = FuzzBert::PRNG.rand(value.size) old = orig[i].ord #map a random value from 0..254 to 0..255 excluding the current value b = FuzzBert::PRNG.rand(255) b = b < old ? b : b + 1 orig.dup.tap { |s| s.setbyte(i, b) } end end |