mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic http protocol: add quickcheck test for urlencode/decode 20 bytes
This commit is contained in:
parent
909f0edce9
commit
597a2a83d1
1 changed files with 30 additions and 0 deletions
|
|
@ -146,6 +146,8 @@ pub fn serialize_response_peers_ipv6<S>(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use quickcheck_macros::*;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
|
@ -176,6 +178,34 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[quickcheck]
|
||||
fn test_urlencode_urldecode_20_bytes(
|
||||
a: u8,
|
||||
b: u8,
|
||||
c: u8,
|
||||
d: u8,
|
||||
e: u8,
|
||||
f: u8,
|
||||
g: u8,
|
||||
h: u8,
|
||||
) -> bool {
|
||||
let input: [u8; 20] = [
|
||||
a, b, c, d, e, f, g, h, b, c, d, a, e, f, g, h, a, b, d, c
|
||||
];
|
||||
|
||||
let mut output = Vec::new();
|
||||
|
||||
urlencode_20_bytes(input, &mut output);
|
||||
|
||||
let s = ::std::str::from_utf8(&output).unwrap();
|
||||
|
||||
let decoded = urldecode_20_bytes(s).unwrap();
|
||||
|
||||
assert_eq!(input, decoded);
|
||||
|
||||
input == decoded
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_urldecode(){
|
||||
assert_eq!(urldecode("").unwrap(), "".to_string());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue