Skip to content

Commit

Permalink
AVRO-3925: [Rust] Improve formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
  • Loading branch information
martin-g committed Jan 4, 2024
1 parent b0142ce commit 2628de4
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions lang/rust/avro/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ fn schema_name_r() -> &'static Regex {
SCHEMA_NAME_ONCE.get_or_init(|| {
Regex::new(
r"^((?P<namespace>([A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*)?)\.)?(?P<name>[A-Za-z_][A-Za-z0-9_]*)$",
)
.unwrap()
).unwrap()
})
}

Expand Down Expand Up @@ -6464,6 +6463,7 @@ mod tests {
Ok(())
}

#[test]
fn test_avro_3925_serialize_decimal_inner_fixed() -> TestResult {
let schema = Schema::Decimal(DecimalSchema {
precision: 36,
Expand All @@ -6480,15 +6480,16 @@ mod tests {
let serialized_json = serde_json::to_string_pretty(&schema)?;

let expected_json = r#"{
"type": "fixed",
"name": "decimal_36_10",
"size": 16,
"logicalType": "decimal",
"scale": 10,
"precision": 36
}"#;
"type": "fixed",
"name": "decimal_36_10",
"size": 16,
"logicalType": "decimal",
"scale": 10,
"precision": 36
}"#;

assert_eq!(serialized_json, expected_json);

Ok(())
}

Expand All @@ -6503,13 +6504,14 @@ mod tests {
let serialized_json = serde_json::to_string_pretty(&schema)?;

let expected_json = r#"{
"type": "bytes",
"logicalType": "decimal",
"scale": 10,
"precision": 36
}"#;
"type": "bytes",
"logicalType": "decimal",
"scale": 10,
"precision": 36
}"#;

assert_eq!(serialized_json, expected_json);

Ok(())
}

Expand Down

0 comments on commit 2628de4

Please sign in to comment.