Skip to content

Commit

Permalink
✅ Add tests for macros with 'interface' arms.
Browse files Browse the repository at this point in the history
This adds four tests to cover when the macros are called with an interface arg.
  • Loading branch information
luukvanderduim committed Sep 24, 2023
1 parent a0da6e2 commit 965f2fd
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion zbus-lockstep/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ macro_rules! property_type_signature {
xml_path,
member,
interface,
MsgType::Property,
MsgType::Property
);

let file = std::fs::File::open(file_path).expect("Failed to open file");
Expand Down Expand Up @@ -540,6 +540,15 @@ mod test {
assert_eq_signatures!(&sig, &zbus::zvariant::Signature::from_str_unchecked("(so)"));
}

#[test]
fn test_signal_body_signature_macro_with_interface() {
// path to XML files
std::env::set_var("LOCKSTEP_XML_PATH", "../xml");

let sig = zbus_lockstep::signal_body_type_signature!("AddNode", "org.example.Node");
assert_eq_signatures!(&sig, &zbus::zvariant::Signature::from_str_unchecked("(so)"));
}

#[test]
fn test_method_args_signature_macro() {
// path to XML files
Expand All @@ -549,6 +558,15 @@ mod test {
assert_eq_signatures!(&sig, &zbus::zvariant::Signature::from_str_unchecked("(su)"));
}

#[test]
fn test_method_args_signature_macro_with_interface() {
// path to XML files
std::env::set_var("LOCKSTEP_XML_PATH", "../xml");

let sig = zbus_lockstep::method_args_signature!("RequestName", "org.example.Node");
assert_eq_signatures!(&sig, &zbus::zvariant::Signature::from_str_unchecked("(su)"));
}

#[test]
fn test_method_return_signature_macro() {
// path to XML files
Expand All @@ -558,6 +576,15 @@ mod test {
assert_eq_signatures!(&sig, &zbus::zvariant::Signature::from_str_unchecked("u"));
}

#[test]
fn test_method_return_signature_macro_with_interface() {
// path to XML files
std::env::set_var("LOCKSTEP_XML_PATH", "../xml");

let sig = zbus_lockstep::method_return_signature!("RequestName", "org.example.Node");
assert_eq_signatures!(&sig, &zbus::zvariant::Signature::from_str_unchecked("u"));
}

#[test]
fn test_property_type_signature_macro() {
// path to XML files
Expand All @@ -566,4 +593,13 @@ mod test {
let sig = zbus_lockstep::property_type_signature!("Features");
assert_eq_signatures!(&sig, &zbus::zvariant::Signature::from_str_unchecked("as"));
}

#[test]
fn test_property_type_signature_macro_with_interface() {
// path to XML files
std::env::set_var("LOCKSTEP_XML_PATH", "../xml");

let sig = zbus_lockstep::property_type_signature!("Features", "org.example.Node");
assert_eq_signatures!(&sig, &zbus::zvariant::Signature::from_str_unchecked("as"));
}
}

0 comments on commit 965f2fd

Please sign in to comment.