From feb054959375433cbb4003e0f712b5dfb2d0c53f Mon Sep 17 00:00:00 2001 From: olafklingt Date: Thu, 8 Aug 2024 20:16:47 +0200 Subject: [PATCH] warnings in tests --- src/client/test_callback.rs | 20 +++-------- src/port/test_client.rs | 69 +++++++++++++++++-------------------- src/port/test_port.rs | 24 ++++++------- 3 files changed, 47 insertions(+), 66 deletions(-) diff --git a/src/client/test_callback.rs b/src/client/test_callback.rs index 4daa8d5e..ca4c2f9c 100644 --- a/src/client/test_callback.rs +++ b/src/client/test_callback.rs @@ -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(), @@ -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; diff --git a/src/port/test_client.rs b/src/port/test_client.rs index 16efd79c..0aa13a26 100644 --- a/src/port/test_client.rs +++ b/src/port/test_client.rs @@ -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())) ); } @@ -39,7 +39,7 @@ fn client_port_register_port_enforces_name_length() { .collect::>() .join("_"); assert_eq!( - c.register_port(&pname, AudioIn::default()).err(), + c.register_port(&pname, AudioIn).err(), Some(Error::PortRegistrationError(pname.to_string())) ); } @@ -47,7 +47,7 @@ fn client_port_register_port_enforces_name_length() { #[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(); @@ -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(); } @@ -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; @@ -113,7 +110,7 @@ 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(); } @@ -121,8 +118,8 @@ fn client_port_fails_to_nonexistant_port() { 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)); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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 = [ @@ -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 diff --git a/src/port/test_port.rs b/src/port/test_port.rs index 3e86aeb7..82ce24b4 100644 --- a/src/port/test_port.rs +++ b/src/port/test_port.rs @@ -13,7 +13,7 @@ fn open_test_client(name: &str) -> Client { fn open_client_with_port(client: &str, port: &str) -> (Client, Port) { 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) } @@ -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(); @@ -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(); @@ -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]