Skip to content

Commit a31fcfc

Browse files
author
Rik Heijdens
committed
AVRO-3631: Add test for serializing fixed fields
This test-case mainly demonstrates the issue reported in AVRO-3631. It is unclear to me whether we should actually expect the serializer to serialize to a Value::Fixed right away given that Schema information is not available at this stage.
1 parent 12ef14b commit a31fcfc

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lang/rust/avro/src/ser.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,11 @@ mod tests {
677677
Val2(f32, f32, f32),
678678
}
679679

680+
#[derive(Debug, Serialize, Deserialize)]
681+
struct TestStructFixedField {
682+
field: [u8; 6],
683+
}
684+
680685
#[test]
681686
fn test_to_value() {
682687
let test = Test {
@@ -998,4 +1003,18 @@ mod tests {
9981003
"error serializing tuple untagged enum"
9991004
);
10001005
}
1006+
1007+
#[test]
1008+
fn test_to_value_fixed_field_avro_3631() {
1009+
let test = TestStructFixedField { field: [1; 6] };
1010+
let expected = Value::Record(vec![(
1011+
"field".to_owned(),
1012+
Value::Fixed(6, Vec::from(test.field.clone())),
1013+
)]);
1014+
assert_eq!(
1015+
to_value(test).unwrap(),
1016+
expected,
1017+
"error serializing fixed array"
1018+
);
1019+
}
10011020
}

0 commit comments

Comments
 (0)