codegen updated

This commit is contained in:
Nikolay Volf
2016-04-21 23:03:05 +03:00
parent bb6d47d0cd
commit 729f9c803d
3 changed files with 75 additions and 48 deletions

View File

@@ -16,16 +16,17 @@
use ipc::*;
use std::mem;
use std::collections::VecDeque;
#[derive(Binary)]
enum Root {
pub enum Root {
Top,
Middle(u32, u64),
}
#[derive(Binary)]
struct DoubleRoot {
x1: u32,
x2: u64,
x3: u32,
#[derive(Binary, PartialEq, Debug)]
pub struct DoubleRoot {
pub x1: u32,
pub x2: u64,
pub x3: u32,
}

View File

@@ -18,6 +18,7 @@
mod tests {
use super::super::service::*;
use super::super::binary::*;
use super::super::nested::{DBClient,DBWriter};
use ipc::*;
use devtools::*;
@@ -143,4 +144,19 @@ mod tests {
assert!(result.is_ok());
}
#[test]
fn can_serialize_dummy_structs() {
let mut socket = TestSocket::new();
let struct_ = DoubleRoot { x1: 0, x2: 100, x3: 100000};
let res = ::ipc::binary::serialize_into(&struct_, &mut socket);
assert!(res.is_ok());
let mut read_socket = TestSocket::new_ready(socket.write_buffer.clone());
let new_struct: DoubleRoot = ::ipc::binary::deserialize_from(&mut read_socket).unwrap();
assert_eq!(struct_, new_struct);
}
}