forked from loafle/openapi-generator-original
Co-authored-by: Christopher Thonfeld-Guckes <ctg@triarc-labs.com>
This commit is contained in:
committed by
GitHub
parent
11c43c3c2b
commit
a3fbb82853
@@ -61,7 +61,15 @@ public class TitlecaseLambda implements Mustache.Lambda {
|
||||
}
|
||||
|
||||
private String titleCase(final String input) {
|
||||
return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1);
|
||||
if(input == null || "".equals(input)){
|
||||
return "";
|
||||
}
|
||||
|
||||
String firstLetter = input.substring(0, 1).toUpperCase(Locale.ROOT);
|
||||
if (input.length() == 1) {
|
||||
return firstLetter;
|
||||
}
|
||||
return firstLetter + input.substring(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,24 @@ public class TitlecaseLambdaTest extends LambdaTest {
|
||||
test("Once Upon A Time", "{{#titlecase}}once upon a time{{/titlecase}}", ctx);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void titlecaseSingleLetterTest() {
|
||||
// Given
|
||||
Map<String, Object> ctx = context("titlecase", new TitlecaseLambda());
|
||||
|
||||
// When & Then
|
||||
test("O", "{{#titlecase}}o{{/titlecase}}", ctx);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void titlecaseEmptyStringTest() {
|
||||
// Given
|
||||
Map<String, Object> ctx = context("titlecase", new TitlecaseLambda());
|
||||
|
||||
// When & Then
|
||||
test("", "{{#titlecase}}{{/titlecase}}", ctx);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void titlecaseWithDelimiterTest() {
|
||||
// Given
|
||||
|
||||
Reference in New Issue
Block a user