Skip to content

Commit

Permalink
📝 add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
Xudong-Huang committed Mar 2, 2024
1 parent 857fe74 commit d6af6f6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion may_rpc_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn test_foo() {

fn test_bar() {
use may_rpc::TcpServer;
use test_hello_foo::{HelloClient, HelloService};
use test_hello_bar::{HelloClient, HelloService};
let addr = ("127.0.0.1", 4000);

let service = HelloService;
Expand All @@ -48,6 +48,15 @@ fn test_bar() {
let data = client.add(i, i);
println!("recv = {:?}", data);
}

for _i in 0..10 {
let data = client.xxxx();
println!("recv = {:?}", data);
}

for _i in 0..10 {
client.yyyy("no return".to_string()).unwrap();
}
}

fn main() {
Expand Down
12 changes: 12 additions & 0 deletions may_rpc_test/src/test_hello_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ pub trait Hello {
fn echo(&self, data: String) -> String;
/// add two u32
fn add(&self, x: u32, y: u32) -> u32;
/// no args
fn xxxx(&self) -> String;
/// no return
fn yyyy(&self, data: String);
}

#[derive(may_rpc::Server)]
Expand All @@ -21,4 +25,12 @@ impl Hello for HelloService {
fn add(&self, x: u32, y: u32) -> u32 {
x + y
}

fn xxxx(&self) -> String {
"no args".to_string()
}

fn yyyy(&self, data: String) -> () {
println!("yyyy: {}", data);
}
}

0 comments on commit d6af6f6

Please sign in to comment.