tests for loading test json files

This commit is contained in:
debris
2016-03-15 19:32:07 +01:00
committed by arkpar
parent 24993b8d4e
commit c15e78cd95
7 changed files with 215 additions and 12 deletions

View File

@@ -46,8 +46,12 @@ impl Visitor for BytesVisitor {
let v = match value.len() {
0 => vec![],
2 if value.starts_with("0x") => vec![],
_ if value.starts_with("0x") => try!(FromHex::from_hex(&value[2..]).map_err(|_| Error::custom("Invalid hex value."))),
_ => try!(FromHex::from_hex(value).map_err(|_| Error::custom("Invalid hex value")))
_ if value.starts_with("0x") => try!(FromHex::from_hex(&value[2..]).map_err(|_| {
Error::custom(format!("Invalid hex value {}.", value).as_ref())
})),
_ => try!(FromHex::from_hex(value).map_err(|_| {
Error::custom(format!("Invalid hex value {}.", value).as_ref())
}))
};
Ok(Bytes(v))
}