Skip to content

Commit

Permalink
warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olafklingt committed Aug 8, 2024
1 parent dedda49 commit feb0549
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 66 deletions.
20 changes: 4 additions & 16 deletions src/client/test_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,8 @@ fn client_cback_reports_xruns() {
#[test]
fn client_cback_calls_port_registered() {
let ac = active_test_client("client_cback_cpr");
let _pa = ac
.as_client()
.register_port("pa", AudioIn::default())
.unwrap();
let _pb = ac
.as_client()
.register_port("pb", AudioIn::default())
.unwrap();
let _pa = ac.as_client().register_port("pa", AudioIn).unwrap();
let _pb = ac.as_client().register_port("pb", AudioIn).unwrap();
let counter = ac.deactivate().unwrap().1;
assert_eq!(
counter.port_register_history.len(),
Expand All @@ -224,14 +218,8 @@ fn client_cback_calls_port_registered() {
#[test]
fn client_cback_calls_port_unregistered() {
let ac = active_test_client("client_cback_cpr");
let pa = ac
.as_client()
.register_port("pa", AudioIn::default())
.unwrap();
let pb = ac
.as_client()
.register_port("pb", AudioIn::default())
.unwrap();
let pa = ac.as_client().register_port("pa", AudioIn).unwrap();
let pb = ac.as_client().register_port("pb", AudioIn).unwrap();
ac.as_client().unregister_port(pa).unwrap();
ac.as_client().unregister_port(pb).unwrap();
let counter = ac.deactivate().unwrap().1;
Expand Down
69 changes: 31 additions & 38 deletions src/port/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ fn open_test_client(name: &str) -> Client {
#[test]
fn client_port_can_register_port() {
let c = open_test_client("cp_can_register_port");
c.register_port("cpcrp_a", AudioIn::default()).unwrap();
c.register_port("cpcrp_a", AudioIn).unwrap();
}

#[test]
fn client_port_register_port_enforces_unique_names() {
let pname = "cprpeun_a";
let c = open_test_client("cp_can_register_port");
c.register_port(pname, AudioIn::default()).unwrap();
c.register_port(pname, AudioIn).unwrap();
assert_eq!(
c.register_port(pname, AudioIn::default()).err(),
c.register_port(pname, AudioIn).err(),
Some(Error::PortRegistrationError(pname.to_string()))
);
}
Expand All @@ -39,15 +39,15 @@ fn client_port_register_port_enforces_name_length() {
.collect::<Vec<&str>>()
.join("_");
assert_eq!(
c.register_port(&pname, AudioIn::default()).err(),
c.register_port(&pname, AudioIn).err(),
Some(Error::PortRegistrationError(pname.to_string()))
);
}

#[test]
fn client_port_can_request_monitor_by_name() {
let c = open_test_client("cp_can_request_monitor_by_name");
let p = c.register_port("cpcrmbn_a", AudioIn::default()).unwrap();
let p = c.register_port("cpcrmbn_a", AudioIn).unwrap();
c.request_monitor_by_name(&p.name().unwrap(), true).unwrap();
c.request_monitor_by_name(&p.name().unwrap(), false)
.unwrap();
Expand All @@ -56,7 +56,7 @@ fn client_port_can_request_monitor_by_name() {
#[test]
fn client_port_can_get_port_by_name() {
let c = open_test_client("cp_can_get_port_by_name");
let p = c.register_port("named_port", AudioIn::default()).unwrap();
let p = c.register_port("named_port", AudioIn).unwrap();
let _p = c.port_by_name(&p.name().unwrap()).unwrap();
}

Expand Down Expand Up @@ -87,10 +87,7 @@ fn client_port_can_get_port_by_id() {
let ac = c.activate_async(h, ()).unwrap();

// Register port
let _pa = ac
.as_client()
.register_port(port_name, AudioIn::default())
.unwrap();
let _pa = ac.as_client().register_port(port_name, AudioIn).unwrap();

// Get by id
let c = ac.deactivate().unwrap().0;
Expand All @@ -113,16 +110,16 @@ fn client_port_can_get_port_by_id() {
#[test]
fn client_port_fails_to_nonexistant_port() {
let c = open_test_client("cp_can_request_monitor_by_name");
let p = c.register_port("cpcrmbn_a", AudioIn::default()).unwrap();
let p = c.register_port("cpcrmbn_a", AudioIn).unwrap();
let _p = c.port_by_name(&p.name().unwrap()).unwrap();
}

#[test]
fn client_port_recognizes_my_ports() {
let ca = open_test_client("cp_cprmp_ca");
let cb = open_test_client("cp_cprmp_cb");
let first = ca.register_port("cpcprmp_pa", AudioIn::default()).unwrap();
let second = cb.register_port("cpcprmp_pb", AudioIn::default()).unwrap();
let first = ca.register_port("cpcprmp_pa", AudioIn).unwrap();
let second = cb.register_port("cpcprmp_pb", AudioIn).unwrap();
let first_alt = ca.port_by_name(&first.name().unwrap()).unwrap();
let second_alt = ca.port_by_name(&second.name().unwrap()).unwrap();
assert!(ca.is_mine(&first));
Expand All @@ -136,8 +133,8 @@ fn client_port_can_connect_ports() {
let client = open_test_client("client_port_ccp");

// initialize ports
let in_p = client.register_port("inp", AudioIn::default()).unwrap();
let out_p = client.register_port("outp", AudioOut::default()).unwrap();
let in_p = client.register_port("inp", AudioIn).unwrap();
let out_p = client.register_port("outp", AudioOut).unwrap();

// start client
let client = client.activate_async((), ()).unwrap();
Expand All @@ -151,8 +148,8 @@ fn client_port_can_connect_ports_by_name() {
let client = open_test_client("client_port_ccpbn");

// initialize ports
let _in_p = client.register_port("inp", AudioIn::default()).unwrap();
let _out_p = client.register_port("outp", AudioOut::default()).unwrap();
let _in_p = client.register_port("inp", AudioIn).unwrap();
let _out_p = client.register_port("outp", AudioOut).unwrap();

// start client
let client = client.activate_async((), ()).unwrap();
Expand All @@ -170,8 +167,8 @@ fn client_port_can_connect_unowned_ports() {
let connector = open_test_client("client_port_ccup_conn");

// initialize ports
let _in_p = client.register_port("inp", AudioIn::default()).unwrap();
let _out_p = client.register_port("outp", AudioOut::default()).unwrap();
let _in_p = client.register_port("inp", AudioIn).unwrap();
let _out_p = client.register_port("outp", AudioOut).unwrap();

// start client
let _client = client.activate_async((), ()).unwrap();
Expand All @@ -188,13 +185,9 @@ fn client_port_cant_connect_inactive_client() {
let other = open_test_client("client_port_ccic_other");

// initialize ports
let in_p = other
.register_port("inp", AudioIn::default())
.unwrap()
.name()
.unwrap();
let in_p = other.register_port("inp", AudioIn).unwrap().name().unwrap();
let out_p = other
.register_port("outp", AudioOut::default())
.register_port("outp", AudioOut)
.unwrap()
.name()
.unwrap();
Expand All @@ -216,8 +209,8 @@ fn client_port_recognizes_already_connected_ports() {
let client = open_test_client("client_port_racp");

// initialize ports
let in_p = client.register_port("conna", AudioIn::default()).unwrap();
let out_p = client.register_port("connb", AudioOut::default()).unwrap();
let in_p = client.register_port("conna", AudioIn).unwrap();
let out_p = client.register_port("connb", AudioOut).unwrap();

// start client
let client = client.activate_async((), ()).unwrap();
Expand Down Expand Up @@ -254,8 +247,8 @@ fn client_port_can_disconnect_port_from_all() {
let client = open_test_client("client_port_cdpfa");

// initialize ports
let in_p = client.register_port("conna", AudioIn::default()).unwrap();
let out_p = client.register_port("connb", AudioOut::default()).unwrap();
let in_p = client.register_port("conna", AudioIn).unwrap();
let out_p = client.register_port("connb", AudioOut).unwrap();

// start client
let client = client.activate_async((), ()).unwrap();
Expand All @@ -270,8 +263,8 @@ fn client_port_can_disconnect_ports() {
let client = open_test_client("client_port_cdp");

// initialize ports
let in_p = client.register_port("conna", AudioIn::default()).unwrap();
let out_p = client.register_port("connb", AudioOut::default()).unwrap();
let in_p = client.register_port("conna", AudioIn).unwrap();
let out_p = client.register_port("connb", AudioOut).unwrap();

// start client
let client = client.activate_async((), ()).unwrap();
Expand All @@ -286,8 +279,8 @@ fn client_port_can_disconnect_ports_by_name() {
let client = open_test_client("client_port_cdpbn");

// initialize ports
let in_p = client.register_port("conna", AudioIn::default()).unwrap();
let out_p = client.register_port("connb", AudioOut::default()).unwrap();
let in_p = client.register_port("conna", AudioIn).unwrap();
let out_p = client.register_port("connb", AudioOut).unwrap();

// start client
let client = client.activate_async((), ()).unwrap();
Expand All @@ -309,8 +302,8 @@ fn client_port_can_disconnect_unowned_ports() {
let disconnector = open_test_client("client_port_cdup_disc");

// initialize ports
let in_p = client.register_port("conna", AudioIn::default()).unwrap();
let out_p = client.register_port("connb", AudioOut::default()).unwrap();
let in_p = client.register_port("conna", AudioIn).unwrap();
let out_p = client.register_port("connb", AudioOut).unwrap();

// start client
let client = client.activate_async((), ()).unwrap();
Expand All @@ -331,8 +324,8 @@ fn client_port_can_get_existing_ports() {
let port_getter = open_test_client("client_port_cgep_getter");

// initialize ports
let in_p = client.register_port("conna", AudioIn::default()).unwrap();
let out_p = client.register_port("connb", AudioOut::default()).unwrap();
let in_p = client.register_port("conna", AudioIn).unwrap();
let out_p = client.register_port("connb", AudioOut).unwrap();

// retrieve
let known_ports = [
Expand Down Expand Up @@ -377,7 +370,7 @@ fn client_port_can_get_port_by_type_pattern() {
let client = open_test_client(c_name);

// register port with type name, like midi
let _p = client.register_port(p_name, MidiIn::default());
let _p = client.register_port(p_name, MidiIn);
thread::sleep(time::Duration::from_millis(400));

// retrieve
Expand Down
24 changes: 12 additions & 12 deletions src/port/test_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn open_test_client(name: &str) -> Client {

fn open_client_with_port(client: &str, port: &str) -> (Client, Port<AudioIn>) {
let c = open_test_client(client);
let p = c.register_port(port, AudioIn::default()).unwrap();
let p = c.register_port(port, AudioIn).unwrap();
(c, p)
}

Expand Down Expand Up @@ -52,10 +52,10 @@ fn port_can_rename() {
#[test]
fn port_connected_count() {
let c = open_test_client("port_connected_count");
let pa = c.register_port("pa", AudioIn::default()).unwrap();
let pb = c.register_port("pb", AudioOut::default()).unwrap();
let pc = c.register_port("pc", AudioOut::default()).unwrap();
let pd = c.register_port("pd", AudioOut::default()).unwrap();
let pa = c.register_port("pa", AudioIn).unwrap();
let pb = c.register_port("pb", AudioOut).unwrap();
let pc = c.register_port("pc", AudioOut).unwrap();
let pd = c.register_port("pd", AudioOut).unwrap();
let c = c.activate_async((), ()).unwrap();
c.as_client().connect_ports(&pb, &pa).unwrap();
c.as_client().connect_ports(&pc, &pa).unwrap();
Expand All @@ -68,10 +68,10 @@ fn port_connected_count() {
#[test]
fn port_knows_connections() {
let c = open_test_client("port_knows_connections");
let pa = c.register_port("pa", AudioIn::default()).unwrap();
let pb = c.register_port("pb", AudioOut::default()).unwrap();
let pc = c.register_port("pc", AudioOut::default()).unwrap();
let pd = c.register_port("pd", AudioOut::default()).unwrap();
let pa = c.register_port("pa", AudioIn).unwrap();
let pb = c.register_port("pb", AudioOut).unwrap();
let pc = c.register_port("pc", AudioOut).unwrap();
let pd = c.register_port("pd", AudioOut).unwrap();
let c = c.activate_async((), ()).unwrap();
c.as_client().connect_ports(&pb, &pa).unwrap();
c.as_client().connect_ports(&pc, &pa).unwrap();
Expand Down Expand Up @@ -155,18 +155,18 @@ fn port_can_unset_alias() {

#[test]
fn port_unowned_no_port_type() {
assert_eq!("", Unowned::default().jack_port_type());
assert_eq!("", Unowned.jack_port_type());
}

#[test]
fn port_unowned_no_port_flags() {
assert_eq!(PortFlags::empty(), Unowned::default().jack_flags());
assert_eq!(PortFlags::empty(), Unowned.jack_flags());
}

#[test]
#[should_panic]
fn port_unowned_no_port_size() {
Unowned::default().jack_buffer_size();
Unowned.jack_buffer_size();
}

#[test]
Expand Down

0 comments on commit feb0549

Please sign in to comment.