From 93738f631983e10f4cd1e023c85accde700c84de Mon Sep 17 00:00:00 2001 From: Bourumir Wyngs Date: Sun, 26 May 2024 12:47:15 +0200 Subject: [PATCH] Improving infrastructure for future tests --- src/tests/urdf_extractor.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/tests/urdf_extractor.rs b/src/tests/urdf_extractor.rs index b9d5e26..9bf8340 100644 --- a/src/tests/urdf_extractor.rs +++ b/src/tests/urdf_extractor.rs @@ -131,6 +131,16 @@ fn test_extraction_kr6r700sixx() { assert_eq!(urdf.c4, yaml.c4, "c4 parameter mismatch"); } +fn assert_parameter_extraction(yaml: Parameters, urdf: URDFParameters, robot: &str) { + assert_eq!(urdf.a1, yaml.a1, "a1 parameter mismatch for {}", robot); + assert_eq!(urdf.a2, yaml.a2, "a2 parameter mismatch for {}", robot); + assert_eq!(urdf.b, yaml.b, "b parameter mismatch for {}", robot); + assert_eq!(urdf.c1, yaml.c1, "c1 parameter mismatch for {}", robot); + assert_eq!(urdf.c2, yaml.c2, "c2 parameter mismatch for {}", robot); + assert_eq!(urdf.c3, yaml.c3, "c3 parameter mismatch for {}", robot); + assert_eq!(urdf.c4, yaml.c4, "c4 parameter mismatch for {}", robot); +} + #[test] fn test_extraction_kr150() { let yaml = Parameters::from_yaml_file("\ @@ -138,13 +148,7 @@ fn test_extraction_kr150() { .expect("Failed to read or parse URDF"); let urdf = read_urdf("src/tests/data/kuka/kr150r3100_2_macro.xacro"); - assert_eq!(urdf.a1, yaml.a1, "a1 parameter mismatch"); - assert_eq!(urdf.a2, yaml.a2, "a2 parameter mismatch"); - assert_eq!(urdf.b, yaml.b, "b parameter mismatch"); - assert_eq!(urdf.c1, yaml.c1, "c1 parameter mismatch"); - assert_eq!(urdf.c2, yaml.c2, "c2 parameter mismatch"); - assert_eq!(urdf.c3, yaml.c3, "c3 parameter mismatch"); - assert_eq!(urdf.c4, yaml.c4, "c4 parameter mismatch"); + assert_parameter_extraction(yaml, urdf, "kr150r3100_2"); } #[test] @@ -154,13 +158,7 @@ fn test_extraction_kr10r1420() { .expect("Failed to read or parse URDF"); let urdf = read_urdf("src/tests/data/kuka/kr10r1420_macro.xacro"); - assert_eq!(urdf.a1, yaml.a1, "a1 parameter mismatch"); - assert_eq!(urdf.a2, yaml.a2, "a2 parameter mismatch"); - assert_eq!(urdf.b, yaml.b, "b parameter mismatch"); - assert_eq!(urdf.c1, yaml.c1, "c1 parameter mismatch"); - assert_eq!(urdf.c2, yaml.c2, "c2 parameter mismatch"); - assert_eq!(urdf.c3, yaml.c3, "c3 parameter mismatch"); - assert_eq!(urdf.c4, yaml.c4, "c4 parameter mismatch"); + assert_parameter_extraction(yaml, urdf, "kr10r1420"); }