diff --git a/ipc/tests/examples.rs b/ipc/tests/examples.rs index 9d5eb37c4..d2fdd54d2 100644 --- a/ipc/tests/examples.rs +++ b/ipc/tests/examples.rs @@ -101,4 +101,24 @@ mod tests { assert!(result.is_ok()); } + + #[test] + fn can_use_custom_params() { + let mut socket = TestSocket::new(); + socket.read_buffer = vec![1]; + let service_client = ServiceClient::init(socket); + + let result = service_client.push_custom(CustomData { a: 3, b: 11}); + + assert_eq!(vec![ + // message num.. + 0, 18, + // payload length + 0, 0, 0, 0, 0, 0, 0, 16, + // structure raw bytes (bigendians :( ) + 3, 0, 0, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 0, 0, 0, 0], + service_client.socket().borrow().write_buffer.clone()); + assert_eq!(true, result); + } } diff --git a/ipc/tests/service.rs.in b/ipc/tests/service.rs.in index bb3c6fbba..6bfa72680 100644 --- a/ipc/tests/service.rs.in +++ b/ipc/tests/service.rs.in @@ -26,8 +26,8 @@ pub struct Service { } pub struct CustomData { - a: usize, - b: usize, + pub a: usize, + pub b: usize, } impl FromRawBytes for CustomData { @@ -46,7 +46,7 @@ impl BytesConvertable for CustomData { unsafe { ::std::slice::from_raw_parts( ptr, - ::std::mem::size_of::() + ::std::mem::size_of::() ) } }