diff --git a/src/segment.rs b/src/segment.rs index 592a047..79ce206 100644 --- a/src/segment.rs +++ b/src/segment.rs @@ -208,6 +208,8 @@ pub(crate) fn paste(segments: &[Segment]) -> Result { } else { acc.push(ch); } + } else if prev == '_' { + acc.push(ch); } prev = ch; } diff --git a/tests/test_item.rs b/tests/test_item.rs index a3dff48..33a9956 100644 --- a/tests/test_item.rs +++ b/tests/test_item.rs @@ -153,14 +153,23 @@ mod test_to_camel { }; } - m!(this_is_but_a_test); - #[test] fn test_to_camel() { + m!(this_is_but_a_test); + assert_eq!(DEFAULT_CAMEL, "ThisIsButATest"); assert_eq!(LOWER_CAMEL, "thisisbutatest"); assert_eq!(UPPER_CAMEL, "THISISBUTATEST"); } + + #[test] + fn test_to_camel_with_underscores() { + m!(__this_is_but__a_test); + + assert_eq!(DEFAULT_CAMEL, "__ThisIsBut_ATest"); + assert_eq!(LOWER_CAMEL, "__thisisbut_atest"); + assert_eq!(UPPER_CAMEL, "__THISISBUT_ATEST"); + } } mod test_doc_expr {