Skip to content

Commit

Permalink
AVRO-3631: Add test for serializing fixed fields
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RikHeijdens authored and martin-g committed Jul 17, 2024
1 parent d754177 commit 612af8b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lang/rust/avro/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,11 @@ mod tests {
Val2(f32, f32, f32),
}

#[derive(Debug, Serialize, Deserialize)]
struct TestStructFixedField {
field: [u8; 6],
}

#[test]
fn test_to_value() -> TestResult {
let test = Test {
Expand Down Expand Up @@ -1031,4 +1036,18 @@ mod tests {

assert!(ser.is_human_readable());
}

#[test]
fn test_to_value_fixed_field_avro_3631() {
let test = TestStructFixedField { field: [1; 6] };
let expected = Value::Record(vec![(
"field".to_owned(),
Value::Fixed(6, Vec::from(test.field.clone())),
)]);
assert_eq!(
to_value(test).unwrap(),
expected,
"error serializing fixed array"
);
}
}

0 comments on commit 612af8b

Please sign in to comment.