mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 02:05:30 +00:00
aquatic_http_protocol: add test for Request serde, fix Request.write bug
This commit is contained in:
parent
2893fffd20
commit
1b2b4f0eb5
2 changed files with 99 additions and 6 deletions
|
|
@ -61,13 +61,39 @@ impl FromStr for AnnounceEvent {
|
|||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for InfoHash {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
let mut arr = [b'x'; 20];
|
||||
let mut arr = [b'0'; 20];
|
||||
|
||||
arr[0] = u8::arbitrary(g);
|
||||
arr[1] = u8::arbitrary(g);
|
||||
arr[18] = u8::arbitrary(g);
|
||||
arr[19] = u8::arbitrary(g);
|
||||
for byte in arr.iter_mut(){
|
||||
*byte = u8::arbitrary(g);
|
||||
}
|
||||
|
||||
Self(arr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for PeerId {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
let mut arr = [b'0'; 20];
|
||||
|
||||
for byte in arr.iter_mut(){
|
||||
*byte = u8::arbitrary(g);
|
||||
}
|
||||
|
||||
Self(arr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
impl quickcheck::Arbitrary for AnnounceEvent {
|
||||
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
|
||||
match (bool::arbitrary(g), bool::arbitrary(g)){
|
||||
(false, false) => Self::Started,
|
||||
(true, false) => Self::Started,
|
||||
(false, true) => Self::Completed,
|
||||
(true, true) => Self::Empty,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue