feat(mavlink): adopt the kaptan-native dialect
This commit is contained in:
1 parent
1c90870634
commit
5f91465e66
87 files changed
+7733
-6850
No files matched your search
@@ -77,6 +77,8 @@ struct CompactSection {
|
||||
endpoint: u8,
|
||||
#[config(enum, id = 21, key = "compact.mode", unit = "mode")]
|
||||
mode: TestMode,
|
||||
#[config(id = 22, key = "compact.port", unit = "id", range(min = 1))]
|
||||
port: u16,
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -115,14 +117,16 @@ fn narrow_scalars_and_compact_enums_keep_native_types_and_generic_metadata() {
|
||||
let mut section = CompactSection {
|
||||
endpoint: 7,
|
||||
mode: TestMode::Quiet,
|
||||
port: 4861,
|
||||
};
|
||||
assert_eq!(CompactSection::SNAPSHOT_VALUE_BYTES, 1 + 1 + 2);
|
||||
assert_eq!(
|
||||
section.field_value(FieldId::new(20)),
|
||||
Some(ConfigValue::U32(7))
|
||||
Some(ConfigValue::U8(7))
|
||||
);
|
||||
assert_eq!(
|
||||
CompactSection::DESCRIPTORS[0].minimum,
|
||||
Some(ConfigValue::U32(1))
|
||||
Some(ConfigValue::U8(1))
|
||||
);
|
||||
assert_eq!(CompactSection::DESCRIPTORS[0].maximum, None);
|
||||
assert_eq!(
|
||||
@@ -134,19 +138,27 @@ fn narrow_scalars_and_compact_enums_keep_native_types_and_generic_metadata() {
|
||||
assert_eq!(TestMode::try_from_wire(2), None);
|
||||
|
||||
section
|
||||
.set_field(FieldId::new(21), ConfigValue::U32(3))
|
||||
.set_field(FieldId::new(21), ConfigValue::U8(3))
|
||||
.unwrap();
|
||||
assert_eq!(section.mode, TestMode::Loud);
|
||||
assert!(matches!(
|
||||
section.set_field(FieldId::new(21), ConfigValue::U32(2)),
|
||||
section.set_field(FieldId::new(21), ConfigValue::U8(2)),
|
||||
Err(FieldWriteError::Violation(issue))
|
||||
if issue.rule() == ValidationRule::InvalidEnumValue
|
||||
));
|
||||
assert!(matches!(
|
||||
section.set_field(FieldId::new(20), ConfigValue::U32(256)),
|
||||
section.set_field(FieldId::new(20), ConfigValue::U8(0)),
|
||||
Err(FieldWriteError::Violation(issue))
|
||||
if issue.rule() == ValidationRule::AboveMaximum
|
||||
if issue.rule() == ValidationRule::BelowMinimum
|
||||
));
|
||||
assert_eq!(
|
||||
section.field_value(FieldId::new(22)),
|
||||
Some(ConfigValue::U16(4861))
|
||||
);
|
||||
assert_eq!(
|
||||
CompactSection::DESCRIPTORS[2].kind,
|
||||
kaptan_config::ValueKind::U16
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -184,6 +196,7 @@ fn aggregate_routes_writes_and_defers_declared_post_validation() {
|
||||
|
||||
#[test]
|
||||
fn aggregate_derives_its_flattened_descriptor_order() {
|
||||
assert_eq!(Aggregate::SNAPSHOT_VALUE_BYTES, 4 * 4);
|
||||
let descriptors: Vec<_> = (0..Aggregate::FIELD_COUNT)
|
||||
.map(|index| Aggregate::descriptor(index).unwrap())
|
||||
.collect();
|
||||
|
||||
Reference in new issue
Block a user