tests for client_ident

This commit is contained in:
NikVolf 2016-06-30 16:23:10 +03:00
parent 6e8df6a6ce
commit 5c5f52c017
6 changed files with 85 additions and 3 deletions

View File

@ -58,6 +58,23 @@ pub fn main() {
registry.expand("", &src, &dst).unwrap(); registry.expand("", &src, &dst).unwrap();
} }
// rpc pass
if {
let src = Path::new("with_attrs.rs.in");
let dst = Path::new(&out_dir).join("with_attrs_ipc.rs");
let mut registry = syntex::Registry::new();
codegen::register(&mut registry);
registry.expand("", &src, &dst).is_ok()
}
// serialization pass
{
let src = Path::new(&out_dir).join("with_attrs_ipc.rs");
let dst = Path::new(&out_dir).join("with_attrs_cg.rs");
let mut registry = syntex::Registry::new();
codegen::register(&mut registry);
registry.expand("", &src, &dst).unwrap();
}
// rpc pass // rpc pass
{ {
let src = Path::new("binary.rs.in"); let src = Path::new("binary.rs.in");

View File

@ -86,7 +86,7 @@ mod tests {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
5, 0, 0, 0], 5, 0, 0, 0],
service_client.socket().borrow().write_buffer.clone()); service_client.socket().write().unwrap().write_buffer.clone());
assert_eq!(10, result); assert_eq!(10, result);
} }
@ -103,7 +103,7 @@ mod tests {
1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
8, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
5, 0, 0, 0, 10, 0, 0, 0], service_client.socket().borrow().write_buffer.clone()); 5, 0, 0, 0, 10, 0, 0, 0], service_client.socket().write().unwrap().write_buffer.clone());
assert_eq!(10, result); assert_eq!(10, result);
} }
@ -145,7 +145,7 @@ mod tests {
// items // items
3, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0,
11, 0, 0, 0, 0, 0, 0, 0], 11, 0, 0, 0, 0, 0, 0, 0],
service_client.socket().borrow().write_buffer.clone()); service_client.socket().write().unwrap().write_buffer.clone());
assert_eq!(true, result); assert_eq!(true, result);
} }

View File

@ -18,6 +18,7 @@
mod tests { mod tests {
use super::super::service::*; use super::super::service::*;
use super::super::with_attrs::PrettyNamedClient;
use nanoipc; use nanoipc;
use std::sync::Arc; use std::sync::Arc;
use std::io::Write; use std::io::Write;
@ -43,6 +44,12 @@ mod tests {
assert!(client.is_ok()); assert!(client.is_ok());
} }
#[test]
fn can_create_renamed_client() {
let client = nanoipc::init_duplex_client::<PrettyNamedClient<_>>("ipc:///tmp/parity-nano-test10.ipc");
assert!(client.is_ok());
}
#[test] #[test]
fn can_call_handshake() { fn can_call_handshake() {
let url = "ipc:///tmp/parity-test-nano-20.ipc"; let url = "ipc:///tmp/parity-test-nano-20.ipc";

View File

@ -28,3 +28,4 @@ mod examples;
mod over_nano; mod over_nano;
mod nested; mod nested;
mod binary; mod binary;
mod with_attrs;

18
ipc/tests/with_attrs.rs Normal file
View File

@ -0,0 +1,18 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
#![allow(dead_code, unused_assignments, unused_variables)] // codegen issues
include!(concat!(env!("OUT_DIR"), "/with_attrs_cg.rs"));

View File

@ -0,0 +1,39 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::sync::RwLock;
use std::ops::*;
use ipc::IpcConfig;
use std::mem;
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;
pub struct BadlyNamedService;
#[derive(Ipc)]
#[ipc(client_ident="PrettyNamedClient")]
impl BadlyNamedService {
fn is_zero(&self, x: u64) -> bool {
x == 0
}
}
impl ::ipc::IpcConfig for BadlyNamedService {}
#[test]
fn invoke() {
}