Compare commits
1 commit
71d6d632db
...
4b0e62394e
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b0e62394e |
1 changed files with 19 additions and 38 deletions
|
|
@ -12,11 +12,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_serialization() -> Result<(), ZError> {
|
fn basic_serialization() -> Result<(), ZError> {
|
||||||
let basic = Basic {
|
let basic = Basic { unsigned_int: 82, signed_int: -1234, strn: "abc".to_string() };
|
||||||
unsigned_int: 82,
|
|
||||||
signed_int: -1234,
|
|
||||||
strn: "abc".to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut buf = ByteBuffer::<1024>::new();
|
let mut buf = ByteBuffer::<1024>::new();
|
||||||
let mut caps = Vec::new();
|
let mut caps = Vec::new();
|
||||||
|
|
@ -31,11 +27,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_serialization_as_request() -> Result<(), ZError> {
|
fn basic_serialization_as_request() -> Result<(), ZError> {
|
||||||
let basic = Basic {
|
let basic = Basic { unsigned_int: 82, signed_int: -1234, strn: "abc".to_string() };
|
||||||
unsigned_int: 82,
|
|
||||||
signed_int: -1234,
|
|
||||||
strn: "abc".to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut buf = ByteBuffer::<1024>::new();
|
let mut buf = ByteBuffer::<1024>::new();
|
||||||
let mut caps = Vec::new();
|
let mut caps = Vec::new();
|
||||||
|
|
@ -71,9 +63,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn repeated_serialization() -> Result<(), ZError> {
|
fn repeated_serialization() -> Result<(), ZError> {
|
||||||
let rep = Repeated {
|
let rep = Repeated { unsigned_ints: vec![0, 1, 3],};
|
||||||
unsigned_ints: vec![0, 1, 3],
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut buf = ByteBuffer::<1024>::new();
|
let mut buf = ByteBuffer::<1024>::new();
|
||||||
let mut caps = Vec::new();
|
let mut caps = Vec::new();
|
||||||
|
|
@ -89,11 +79,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn nested_serialization() -> Result<(), ZError> {
|
fn nested_serialization() -> Result<(), ZError> {
|
||||||
let nested = Nested {
|
let nested = Nested {
|
||||||
basic: Basic {
|
basic: Basic { unsigned_int: 82, signed_int: -1234, strn: "abc".to_string() },
|
||||||
unsigned_int: 82,
|
|
||||||
signed_int: -1234,
|
|
||||||
strn: "abc".to_string(),
|
|
||||||
},
|
|
||||||
cap1: Cap { cap: 37},
|
cap1: Cap { cap: 37},
|
||||||
cap2: Cap { cap: 39},
|
cap2: Cap { cap: 39},
|
||||||
};
|
};
|
||||||
|
|
@ -104,6 +90,7 @@ mod tests {
|
||||||
|
|
||||||
let parsed = Nested::parse(&buf, 0, &caps)?;
|
let parsed = Nested::parse(&buf, 0, &caps)?;
|
||||||
|
|
||||||
|
|
||||||
assert!(parsed == nested);
|
assert!(parsed == nested);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -112,18 +99,8 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn repeated_nested_serialization() -> Result<(), ZError> {
|
fn repeated_nested_serialization() -> Result<(), ZError> {
|
||||||
let nested = RepeatedNested {
|
let nested = RepeatedNested {
|
||||||
basics: vec![
|
basics: vec![Basic { unsigned_int: 82, signed_int: -1234, strn: "abc".to_string(),},
|
||||||
Basic {
|
Basic { unsigned_int: 21, signed_int: -8, strn: "def".to_string(), },],
|
||||||
unsigned_int: 82,
|
|
||||||
signed_int: -1234,
|
|
||||||
strn: "abc".to_string(),
|
|
||||||
},
|
|
||||||
Basic {
|
|
||||||
unsigned_int: 21,
|
|
||||||
signed_int: -8,
|
|
||||||
strn: "def".to_string(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
caps: vec![Cap{ cap: 123}, Cap {cap: 12343}],
|
caps: vec![Cap{ cap: 123}, Cap {cap: 12343}],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -133,8 +110,12 @@ mod tests {
|
||||||
|
|
||||||
let parsed = RepeatedNested::parse(&buf, 0, &caps)?;
|
let parsed = RepeatedNested::parse(&buf, 0, &caps)?;
|
||||||
|
|
||||||
|
|
||||||
assert!(parsed == nested);
|
assert!(parsed == nested);
|
||||||
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue