@@ -5,7 +5,6 @@ use super::TypeErasedSequence;
5
5
use crate :: rcl_bindings:: rosidl_typesupport_introspection_c__MessageMember as rosidl_message_member_t;
6
6
use crate :: rcl_bindings:: rosidl_typesupport_introspection_c__MessageMembers as rosidl_message_members_t;
7
7
use crate :: rcl_bindings:: * ;
8
- use crate :: rcl_bindings:: rosidl_typesupport_introspection_c_field_types:: * ;
9
8
10
9
/// Possible base types for fields in a message.
11
10
// The field variants are self-explaining, no need to add redundant documentation.
@@ -114,10 +113,7 @@ impl BaseType {
114
113
string_upper_bound : Option < NonZeroUsize > ,
115
114
inner : * const rosidl_message_type_support_t ,
116
115
) -> Self {
117
- <<<<<<< HEAD
118
- =======
119
116
use rosidl_typesupport_introspection_c_field_types:: * ;
120
- >>>>>>> 4 e1c0be ( Clear warnings )
121
117
match u32:: from ( type_id) {
122
118
x if x == rosidl_typesupport_introspection_c__ROS_TYPE_FLOAT as u32 => Self :: Float ,
123
119
x if x == rosidl_typesupport_introspection_c__ROS_TYPE_DOUBLE as u32 => Self :: Double ,
@@ -1070,3 +1066,74 @@ mod tests {
1070
1066
}
1071
1067
}
1072
1068
}
1069
+
1070
+ #[ test]
1071
+ fn dynamic_message_has_defaults ( ) {
1072
+ let dyn_msg = DynamicMessage :: new ( "test_msgs/msg/Defaults" ) . unwrap ( ) ;
1073
+ assert_eq ! (
1074
+ dyn_msg. get( "bool_value" ) ,
1075
+ Some ( Value :: Simple ( SimpleValue :: Boolean ( & true ) ) )
1076
+ ) ;
1077
+ assert_eq ! (
1078
+ dyn_msg. get( "byte_value" ) ,
1079
+ Some ( Value :: Simple ( SimpleValue :: Octet ( & 50u8 ) ) )
1080
+ ) ;
1081
+ assert_eq ! (
1082
+ dyn_msg. get( "char_value" ) ,
1083
+ Some ( Value :: Simple ( SimpleValue :: Uint8 ( & 100u8 ) ) )
1084
+ ) ;
1085
+ assert_eq ! (
1086
+ dyn_msg. get( "float32_value" ) ,
1087
+ Some ( Value :: Simple ( SimpleValue :: Float ( & 1.125f32 ) ) )
1088
+ ) ;
1089
+ assert_eq ! (
1090
+ dyn_msg. get( "float64_value" ) ,
1091
+ Some ( Value :: Simple ( SimpleValue :: Double ( & 1.125f64 ) ) )
1092
+ ) ;
1093
+ assert_eq ! (
1094
+ dyn_msg. get( "int8_value" ) ,
1095
+ Some ( Value :: Simple ( SimpleValue :: Int8 ( & -50i8 ) ) )
1096
+ ) ;
1097
+ assert_eq ! (
1098
+ dyn_msg. get( "uint8_value" ) ,
1099
+ Some ( Value :: Simple ( SimpleValue :: Uint8 ( & 200u8 ) ) )
1100
+ ) ;
1101
+ assert_eq ! (
1102
+ dyn_msg. get( "int16_value" ) ,
1103
+ Some ( Value :: Simple ( SimpleValue :: Int16 ( & -1000i16 ) ) )
1104
+ ) ;
1105
+ assert_eq ! (
1106
+ dyn_msg. get( "uint16_value" ) ,
1107
+ Some ( Value :: Simple ( SimpleValue :: Uint16 ( & 2000u16 ) ) )
1108
+ ) ;
1109
+ assert_eq ! (
1110
+ dyn_msg. get( "int32_value" ) ,
1111
+ Some ( Value :: Simple ( SimpleValue :: Int32 ( & -30000i32 ) ) )
1112
+ ) ;
1113
+ assert_eq ! (
1114
+ dyn_msg. get( "uint32_value" ) ,
1115
+ Some ( Value :: Simple ( SimpleValue :: Uint32 ( & 60000u32 ) ) )
1116
+ ) ;
1117
+ assert_eq ! (
1118
+ dyn_msg. get( "int64_value" ) ,
1119
+ Some ( Value :: Simple ( SimpleValue :: Int64 ( & -40000000i64 ) ) )
1120
+ ) ;
1121
+ assert_eq ! (
1122
+ dyn_msg. get( "uint64_value" ) ,
1123
+ Some ( Value :: Simple ( SimpleValue :: Uint64 ( & 50000000u64 ) ) )
1124
+ ) ;
1125
+
1126
+ let _dyn_msg = DynamicMessage :: new ( "test_msgs/msg/Arrays" ) . unwrap ( ) ;
1127
+ let _dyn_msg = DynamicMessage :: new ( "test_msgs/msg/UnboundedSequences" ) . unwrap ( ) ;
1128
+ let _dyn_msg = DynamicMessage :: new ( "test_msgs/msg/BoundedSequences" ) . unwrap ( ) ;
1129
+ }
1130
+
1131
+ // #[test]
1132
+ // fn test_mut_value_same_as_value() {
1133
+
1134
+ // }
1135
+
1136
+ // #[test]
1137
+ // fn test_setting_value() {
1138
+
1139
+ // }
0 commit comments