class FuzzBert::Mutator

Public Class Methods

new(value) click to toggle source
Calls superclass method FuzzBert::Generator::new
# 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