reenabled testcases
This commit is contained in:
parent
447e5e0e59
commit
eb451e577f
@ -270,7 +270,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -287,28 +286,23 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_mut_scheduled() {
|
fn test_mut_scheduled() {
|
||||||
// With the current impl, seed of 1 will result in a split at pos 2.
|
// With the current impl, seed of 1 will result in a split at pos 2.
|
||||||
let mut rand = XKCDRand::new();
|
let mut rand = XKCDRand::with_seed(5);
|
||||||
let mut corpus: InMemoryCorpus<BytesInput, _> = InMemoryCorpus::new();
|
let mut corpus: InMemoryCorpus<BytesInput> = InMemoryCorpus::new();
|
||||||
corpus.add(Testcase::new(vec!['a' as u8, 'b' as u8, 'c' as u8]).into());
|
corpus
|
||||||
corpus.add(Testcase::new(vec!['d' as u8, 'e' as u8, 'f' as u8]).into());
|
.add(Testcase::new(vec!['a' as u8, 'b' as u8, 'c' as u8]).into())
|
||||||
|
.unwrap();
|
||||||
|
corpus
|
||||||
|
.add(Testcase::new(vec!['d' as u8, 'e' as u8, 'f' as u8]).into())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let (testcase, _) = corpus
|
let testcase = corpus.get(0).expect("Corpus did not contain entries");
|
||||||
.next(&mut rand)
|
|
||||||
.expect("Corpus did not contain entries");
|
|
||||||
let mut input = testcase.borrow_mut().load_input().unwrap().clone();
|
let mut input = testcase.borrow_mut().load_input().unwrap().clone();
|
||||||
|
|
||||||
let mut state = State::new(corpus, (), InMemoryCorpus::new(), ());
|
let mut state = State::new(rand, corpus, (), InMemoryCorpus::new(), ());
|
||||||
|
|
||||||
rand.set_seed(5);
|
rand.set_seed(5);
|
||||||
|
|
||||||
let mut mutator = StdScheduledMutator::<
|
mutation_splice(&mut state, &mut input).unwrap();
|
||||||
InMemoryCorpus<BytesInput, XKCDRand>,
|
|
||||||
_,
|
|
||||||
_,
|
|
||||||
State<_, (), _, InMemoryCorpus<BytesInput, XKCDRand>, (), _>,
|
|
||||||
>::new();
|
|
||||||
|
|
||||||
mutation_splice(&mut mutator, &mut rand, &mut state, &mut input).unwrap();
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
println!("{:?}", input.bytes());
|
println!("{:?}", input.bytes());
|
||||||
@ -321,27 +315,37 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_havoc() {
|
fn test_havoc() {
|
||||||
// With the current impl, seed of 1 will result in a split at pos 2.
|
// With the current impl, seed of 1 will result in a split at pos 2.
|
||||||
let mut rand = StdRand::new(0x1337);
|
let rand = StdRand::with_seed(0x1337);
|
||||||
let mut corpus: InMemoryCorpus<BytesInput, StdRand> = InMemoryCorpus::new();
|
let mut corpus: InMemoryCorpus<BytesInput> = InMemoryCorpus::new();
|
||||||
corpus.add(Testcase::new(vec!['a' as u8, 'b' as u8, 'c' as u8]).into());
|
corpus
|
||||||
corpus.add(Testcase::new(vec!['d' as u8, 'e' as u8, 'f' as u8]).into());
|
.add(Testcase::new(vec!['a' as u8, 'b' as u8, 'c' as u8]).into())
|
||||||
|
.unwrap();
|
||||||
|
corpus
|
||||||
|
.add(Testcase::new(vec!['d' as u8, 'e' as u8, 'f' as u8]).into())
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let (testcase, _) = corpus
|
let testcase = corpus.get(0).expect("Corpus did not contain entries");
|
||||||
.next(&mut rand)
|
|
||||||
.expect("Corpus did not contain entries");
|
|
||||||
let mut input = testcase.borrow_mut().load_input().unwrap().clone();
|
let mut input = testcase.borrow_mut().load_input().unwrap().clone();
|
||||||
let input_prior = input.clone();
|
let input_prior = input.clone();
|
||||||
|
|
||||||
let mut state = State::new(corpus, (), InMemoryCorpus::new(), ());
|
let mut state = State::new(rand, corpus, (), InMemoryCorpus::new(), ());
|
||||||
|
|
||||||
let mut havoc = HavocBytesMutator::new(StdScheduledMutator::new());
|
let havoc = HavocBytesMutator::new(StdScheduledMutator::new());
|
||||||
|
|
||||||
assert_eq!(input, input_prior);
|
assert_eq!(input, input_prior);
|
||||||
|
|
||||||
|
let mut equal_in_a_row = 0;
|
||||||
|
|
||||||
for i in 0..42 {
|
for i in 0..42 {
|
||||||
havoc.mutate(&mut rand, &mut state, &mut input, i).unwrap();
|
havoc.mutate(&mut state, &mut input, i).unwrap();
|
||||||
assert_ne!(input, input_prior);
|
|
||||||
|
// Make sure we actually mutate something, at least sometimes
|
||||||
|
equal_in_a_row = if input == input_prior {
|
||||||
|
equal_in_a_row + 1
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
assert_ne!(equal_in_a_row, 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user