mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-04-21 20:11:58 +00:00
Simplify tests
This commit is contained in:
parent
3bddc10797
commit
cd99035940
1 changed files with 7 additions and 18 deletions
|
|
@ -223,17 +223,6 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
macro_rules! or_panic {
|
|
||||||
($e:expr) => {
|
|
||||||
match $e {
|
|
||||||
Ok(e) => e,
|
|
||||||
Err(e) => {
|
|
||||||
panic!("{}", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn duplex_communication() {
|
fn duplex_communication() {
|
||||||
let socket_path = Path::new("//./pipe/basicsock");
|
let socket_path = Path::new("//./pipe/basicsock");
|
||||||
|
|
@ -241,20 +230,20 @@ mod tests {
|
||||||
let msg1 = b"hello";
|
let msg1 = b"hello";
|
||||||
let msg2 = b"world!";
|
let msg2 = b"world!";
|
||||||
|
|
||||||
let mut listener = or_panic!(PipeServer::bind(socket_path));
|
let mut listener = PipeServer::bind(socket_path).unwrap();
|
||||||
let thread = thread::spawn(move || {
|
let thread = thread::spawn(move || {
|
||||||
let mut stream = or_panic!(listener.accept());
|
let mut stream = listener.accept().unwrap();
|
||||||
let mut buf = [0; 5];
|
let mut buf = [0; 5];
|
||||||
or_panic!(stream.read(&mut buf));
|
stream.read(&mut buf).unwrap();
|
||||||
assert_eq!(&msg1[..], &buf[..]);
|
assert_eq!(&msg1[..], &buf[..]);
|
||||||
or_panic!(stream.write_all(msg2));
|
stream.write_all(msg2).unwrap();
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut stream = or_panic!(PipeClient::connect(socket_path));
|
let mut stream = PipeClient::connect(socket_path).unwrap();
|
||||||
|
|
||||||
or_panic!(stream.write_all(msg1));
|
stream.write_all(msg1).unwrap();
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
or_panic!(stream.read_to_end(&mut buf));
|
stream.read_to_end(&mut buf).unwrap();
|
||||||
assert_eq!(&msg2[..], &buf[..]);
|
assert_eq!(&msg2[..], &buf[..]);
|
||||||
drop(stream);
|
drop(stream);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue