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