Skip to content

Commit

Permalink
Add tests for bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolftimmermans committed Jun 1, 2020
1 parent c58c381 commit cb0344c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,25 @@ pub mod bytes {
use super::*;

quickcheck! {
fn check(value: Vec<u8>, tag: u32) -> TestResult {
fn check_vec(value: Vec<u8>, tag: u32) -> TestResult {
super::test::check_type::<Vec<u8>, Vec<u8>>(value, tag, WireType::LengthDelimited,
encode, merge, encoded_len)
}

fn check_repeated(value: Vec<Vec<u8>>, tag: u32) -> TestResult {
fn check_bytes(value: Vec<u8>, tag: u32) -> TestResult {
let value = Bytes::from(value);
super::test::check_type::<Bytes, Bytes>(value, tag, WireType::LengthDelimited,
encode, merge, encoded_len)
}

fn check_repeated_vec(value: Vec<Vec<u8>>, tag: u32) -> TestResult {
super::test::check_collection_type(value, tag, WireType::LengthDelimited,
encode_repeated, merge_repeated,
encoded_len_repeated)
}

fn check_repeated_bytes(value: Vec<Vec<u8>>, tag: u32) -> TestResult {
let value = value.into_iter().map(|v| Bytes::from(v)).collect();
super::test::check_collection_type(value, tag, WireType::LengthDelimited,
encode_repeated, merge_repeated,
encoded_len_repeated)
Expand Down

0 comments on commit cb0344c

Please sign in to comment.