Skip to content

Commit e13ed4b

Browse files
Add tests for all macro options
1 parent 22a022a commit e13ed4b

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

rclrs/src/parameter/structured.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ pub trait StructuredParameters: Sized {
8585
/// - [`crate::OptionalParameter<T>`]
8686
/// - [`crate::ReadOnlyParameter<T>`]
8787
///
88-
/// In these cases the [`Self`] != [`T`] and forces the usage of a generic trait.
88+
/// In these cases [`Self`] != [`T`] and forces the usage of a generic trait.
8989
/// However, a generic trait also requires annotating this default value in the derive macro.
9090
/// For the container based structured parameters [`T`] is always [`DefaultForbidden`]
91-
/// and therefore we can hide this form the trait + macro by using this helper trait.
91+
/// and therefore we can hide this from the trait + macro by using this helper trait.
9292
/// The previously mentioned leaf types that actually hold parameters, are to be implemented manually anyway.
9393
///
9494
pub trait StructuredParametersMeta<T: ParameterVariant>: Sized {
@@ -356,4 +356,30 @@ mod tests {
356356
node.declare_parameters("").unwrap();
357357
println!("{:?}", _params);
358358
}
359+
#[derive(Debug, StructuredParameters)]
360+
struct AllMacroOptions {
361+
#[param(
362+
default = 42.0,
363+
ignore_override,
364+
description = "_mandatory",
365+
constraints = "some_constraints",
366+
discard_mismatching_prior_value,
367+
discriminate = |av| av.default_value,
368+
range = rclrs::ParameterRange { lower: Some(1.0), ..Default::default()},
369+
)]
370+
_mandatory: rclrs::MandatoryParameter<f64>,
371+
}
372+
373+
#[test]
374+
fn test_all_macro_options() {
375+
let args: Vec<String> = ["test", "--ros-args"]
376+
.into_iter()
377+
.map(str::to_string)
378+
.collect();
379+
let context = crate::Context::new(args, rclrs::InitOptions::default()).unwrap();
380+
let exec = context.create_basic_executor();
381+
let node = exec.create_node(rclrs::NodeOptions::new("test")).unwrap();
382+
let _params: AllMacroOptions = node.declare_parameters("").unwrap();
383+
println!("{:?}", _params);
384+
}
359385
}

0 commit comments

Comments
 (0)