Skip to content

Commit b6af2a3

Browse files
authored
fix: handle camel case package (#52)
1 parent 0e6aa1d commit b6af2a3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pbjson-build/src/descriptor.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ pub struct Package {
1919

2020
impl Display for Package {
2121
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
22-
write!(f, "{}", self.path[0])?;
22+
write!(f, "{}", self.path[0].to_snake_case())?;
2323
for element in &self.path[1..self.path.len()] {
24-
write!(f, ".{}", element)?;
24+
write!(f, ".{}", element.to_snake_case())?;
2525
}
2626
Ok(())
2727
}
@@ -291,4 +291,12 @@ mod tests {
291291
assert_eq!(t.prefix_match(".foo.bar.Baz.Bar"), Some(4));
292292
assert_eq!(t.prefix_match(".foo.bar.Baz.Bar.Boo"), None);
293293
}
294+
295+
#[test]
296+
fn test_handle_camel_case_in_package() {
297+
assert_eq!(
298+
Package::new("fooBar.baz.boo").to_string(),
299+
String::from("foo_bar.baz.boo")
300+
)
301+
}
294302
}

0 commit comments

Comments
 (0)