HasLen for input and exec_time in Testcase
This commit is contained in:
parent
a60ef073ed
commit
31d94925d0
@ -181,6 +181,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! tuple_for_each {
|
||||
($fn_name:ident, $trait_name:path, $tuple_name:ident, $body:expr) => {
|
||||
mod $fn_name {
|
||||
@ -211,6 +212,7 @@ macro_rules! tuple_for_each {
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! tuple_for_each_mut {
|
||||
($fn_name:ident, $trait_name:path, $tuple_name:ident, $body:expr) => {
|
||||
mod $fn_name {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//! It will contain a respective input, and metadata.
|
||||
|
||||
use alloc::string::String;
|
||||
use core::{convert::Into, default::Default, option::Option};
|
||||
use core::{convert::Into, default::Default, option::Option, time::Duration};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
@ -26,6 +26,8 @@ where
|
||||
fitness: u32,
|
||||
/// Map of metadatas associated with this testcase
|
||||
metadatas: SerdeAnyMap,
|
||||
/// Time needed to execute the input
|
||||
exec_time: Option<Duration>,
|
||||
}
|
||||
|
||||
/// Impl of a testcase
|
||||
@ -141,6 +143,7 @@ where
|
||||
filename: None,
|
||||
fitness: 0,
|
||||
metadatas: SerdeAnyMap::new(),
|
||||
exec_time: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,6 +155,7 @@ where
|
||||
filename: Some(filename),
|
||||
fitness: 0,
|
||||
metadatas: SerdeAnyMap::new(),
|
||||
exec_time: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,6 +166,7 @@ where
|
||||
filename: None,
|
||||
fitness: 0,
|
||||
metadatas: SerdeAnyMap::new(),
|
||||
exec_time: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use alloc::{borrow::ToOwned, rc::Rc, vec::Vec};
|
||||
use core::{cell::RefCell, convert::From};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::inputs::{HasBytesVec, HasTargetBytes, Input, TargetBytes};
|
||||
use crate::inputs::{HasBytesVec, HasTargetBytes, HasLen, Input, TargetBytes};
|
||||
|
||||
/// A bytes input is the basic input
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq)]
|
||||
@ -42,6 +42,13 @@ impl HasTargetBytes for BytesInput {
|
||||
}
|
||||
}
|
||||
|
||||
impl HasLen for BytesInput {
|
||||
#[inline]
|
||||
fn len(&self) -> usize {
|
||||
self.bytes.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<u8>> for BytesInput {
|
||||
fn from(bytes: Vec<u8>) -> Self {
|
||||
Self::new(bytes)
|
||||
|
@ -33,7 +33,9 @@ pub trait Input: Clone + serde::Serialize + serde::de::DeserializeOwned + Debug
|
||||
#[cfg(not(feature = "std"))]
|
||||
/// Write this input to the file
|
||||
fn to_file<P>(&self, _path: P) -> Result<(), Error>
|
||||
where {
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
Err(Error::NotImplemented("Not suppored in no_std".into()))
|
||||
}
|
||||
|
||||
@ -52,7 +54,9 @@ where {
|
||||
/// Write this input to the file
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn from_file<P>(_path: P) -> Result<Self, Error>
|
||||
where {
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
Err(Error::NotImplemented("Not suppored in no_std".into()))
|
||||
}
|
||||
}
|
||||
@ -96,3 +100,10 @@ pub trait HasBytesVec {
|
||||
/// The internal bytes map (as mutable borrow)
|
||||
fn bytes_mut(&mut self) -> &mut Vec<u8>;
|
||||
}
|
||||
|
||||
/// Has a length field
|
||||
pub trait HasLen {
|
||||
/// The lenght
|
||||
fn len(&self) -> usize;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user