auto typing bytesinput

This commit is contained in:
Dominik Maier 2020-11-15 02:26:37 +01:00
parent 4b8fa9d7b5
commit dea240a324
3 changed files with 8 additions and 7 deletions

View File

@ -195,9 +195,10 @@ where
}
/// Create a new Testcase instace given an input
pub fn new(input: I) -> Self {
pub fn new<T>(input: T) -> Self
where T: Into<I>{
Testcase {
input: Some(input),
input: Some(input.into()),
filename: None,
metadatas: HashMap::default(),
}

View File

@ -87,7 +87,7 @@ mod tests {
use core::cell::RefCell;
use crate::corpus::{Corpus, InMemoryCorpus, Testcase};
use crate::engines::{Engine, DefaultEngine};
use crate::engines::{DefaultEngine, Engine};
use crate::executors::inmemory::InMemoryExecutor;
use crate::executors::{Executor, ExitKind};
use crate::inputs::bytes::BytesInput;
@ -106,7 +106,7 @@ mod tests {
let rand: Rc<_> = DefaultRand::new(0).into();
let mut corpus = InMemoryCorpus::<BytesInput, _>::new(&rand);
let testcase = Testcase::new(BytesInput::new(vec![0; 4])).into();
let testcase = Testcase::new(vec![0; 4]).into();
corpus.add(testcase);
let executor: Rc<RefCell<InMemoryExecutor<BytesInput>>> =
InMemoryExecutor::new(harness).into();

View File

@ -339,9 +339,9 @@ mod tests {
// With the current impl, seed of 1 will result in a split at pos 2.
let rand: Rc<_> = XKCDRand::new().into();
let mut has_rand = DefaultHasRand::new(&rand);
let mut corpus = InMemoryCorpus::new(&rand);
corpus.add(Testcase::new(BytesInput::new(vec!['a' as u8, 'b' as u8, 'c' as u8])).into());
corpus.add(Testcase::new(BytesInput::new(vec!['d' as u8, 'e' as u8, 'f' as u8])).into());
let mut corpus: InMemoryCorpus<BytesInput, _> = InMemoryCorpus::new(&rand);
corpus.add(Testcase::new(vec!['a' as u8, 'b' as u8, 'c' as u8]).into());
corpus.add(Testcase::new(vec!['d' as u8, 'e' as u8, 'f' as u8]).into());
let testcase_rr = corpus.next().expect("Corpus did not contain entries");
let mut testcase = testcase_rr.borrow_mut();