Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

Camel keep beginning and doubled underscores #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ pub(crate) fn paste(segments: &[Segment]) -> Result<String> {
} else {
acc.push(ch);
}
} else if prev == '_' {
acc.push(ch);
}
prev = ch;
}
Expand Down
13 changes: 11 additions & 2 deletions tests/test_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down