MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / generate

Function generate

fuzz/build.rs:181–196  ·  view source on GitHub ↗
(
        rng: &mut StdRng,
        mut f: impl FnMut(&mut Unstructured<'_>) -> arbitrary::Result<T>,
    )

Source from the content-addressed store, hash-verified

179 }
180
181 fn generate<T>(
182 rng: &mut StdRng,
183 mut f: impl FnMut(&mut Unstructured<'_>) -> arbitrary::Result<T>,
184 ) -> Result<T> {
185 let mut bytes = Vec::new();
186 loop {
187 let count = rng.random_range(1000..2000);
188 bytes.extend(iter::repeat_with(|| rng.random::<u8>()).take(count));
189
190 match f(&mut Unstructured::new(&bytes)) {
191 Ok(ret) => break Ok(ret),
192 Err(arbitrary::Error::NotEnoughData) => (),
193 Err(error) => break Err(Error::from(error)),
194 }
195 }
196 }
197}

Callers 3

write_static_api_testsFunction · 0.70
arbitraryMethod · 0.50
arbitraryMethod · 0.50

Calls 6

OkFunction · 0.85
fromFunction · 0.85
newFunction · 0.50
fFunction · 0.50
extendMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected