#1573 - Incorrect CamelCase conversion when number proceeds uppercase letter

This commit is contained in:
rob bygrave
2018-12-13 00:19:40 +13:00
parent 4b0230e862
commit 8410de8831
2 changed files with 21 additions and 6 deletions
@@ -7,21 +7,36 @@ import static org.junit.Assert.assertEquals;
public class CamelCaseHelperTest {
@Test
public void when_underscore() throws Exception {
public void when_underscore() {
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello_there"), "helloThere");
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello_there_jim"), "helloThereJim");
}
@Test
public void when_trailing_numbers() throws Exception {
public void when_trailing_numbers() {
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello_1"), "hello1");
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello_there_2"), "helloThere2");
}
@Test
public void when_already_camel() throws Exception {
public void when_numbers() {
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello1_id"), "hello1Id");
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello_there2_foo"), "helloThere2Foo");
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello1id"), "hello1id");
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello_there2foo"), "helloThere2foo");
}
@Test
public void when_numbersProceedUppercase() {
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello1_id"), "hello1Id");
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello_there2_foo"), "helloThere2Foo");
assertEquals(CamelCaseHelper.toUnderscoreFromCamel("hello1Id"), "hello1_id");
assertEquals(CamelCaseHelper.toUnderscoreFromCamel("helloThere2Foo"), "hello_there2_foo");
}
@Test
public void when_already_camel() {
assertEquals(CamelCaseHelper.toCamelFromUnderscore("helloThere"), "helloThere");
assertEquals(CamelCaseHelper.toCamelFromUnderscore("helloThereJim"), "helloThereJim");
assertEquals(CamelCaseHelper.toCamelFromUnderscore("hello"), "hello");