
com.natpryce.snodge.internal.EncodedStringMutator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snodge Show documentation
Show all versions of snodge Show documentation
A small, extensible Java library to randomly mutate JSON documents. Useful for fuzz testing.
package com.natpryce.snodge.internal;
import com.natpryce.snodge.Mutator;
import java.nio.charset.Charset;
import java.util.stream.Stream;
public class EncodedStringMutator implements Mutator {
private final Mutator stringMutator;
private final Charset charset;
public EncodedStringMutator(Charset charset, Mutator stringMutator) {
this.charset = charset;
this.stringMutator = stringMutator;
}
@Override
public Stream mutate(byte[] originalBytes, int mutationCount) {
return stringMutator.mutate(new String(originalBytes, charset), mutationCount)
.map(stringMutant -> stringMutant.getBytes(charset));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy