mirror of
https://github.com/shekhargulati/strman-java.git
synced 2026-10-20 06:24:05 +00:00
cleanup and added tests
This commit is contained in:
@@ -944,7 +944,11 @@ public abstract class Strman {
|
||||
*/
|
||||
public static String htmlEncode(final String html) {
|
||||
validate(html, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
|
||||
return html.chars().mapToObj(c -> "\\u" + String.format("%04x", c).toUpperCase()).map(e -> HtmlEntities.encodedEntities.get(e)).collect(joining());
|
||||
return html
|
||||
.chars()
|
||||
.mapToObj(c -> "\\u" + String.format("%04x", c).toUpperCase())
|
||||
.map(HtmlEntities.encodedEntities::get)
|
||||
.collect(joining());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
package strman;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -800,7 +801,8 @@ public class StrmanTest {
|
||||
" de_camelize"
|
||||
};
|
||||
|
||||
Arrays.stream(fixture).forEach(el -> assertThat(String.format("toKebabCase(%s) should be de-camelize", el), toKebabCase(el), equalTo("de-camelize")));
|
||||
Arrays.stream(fixture).forEach(el ->
|
||||
assertThat(String.format("toKebabCase(%s) should be de-camelize", el), toKebabCase(el), equalTo("de-camelize")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -845,4 +847,42 @@ public class StrmanTest {
|
||||
String result = removeRight("Remove the END at the end", " END", false);
|
||||
assertThat(result, is("Remove the END at the"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transliterate_shouldDeburrTheString() throws Exception {
|
||||
String result = transliterate("déjà vu");
|
||||
assertThat(result, is(equalTo("deja vu")));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public void htmlEncode_shouldConvertCharactersToTheirHtmlEntities() throws Exception {
|
||||
String result = htmlEncode("fred, barney, & pebbles");
|
||||
assertThat(result, is(equalTo("fred, barney, & pebbles")));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public void kebabCase_shouldConvertAStringToKebabCase() throws Exception {
|
||||
String[] input = {
|
||||
"Foo Bar",
|
||||
"fooBar",
|
||||
"__FOO_BAR__"
|
||||
};
|
||||
|
||||
Arrays.stream(input).forEach(el ->
|
||||
assertThat(String.format("%s should be foo-bar", el), toKebabCase(el), is(equalTo("foo-bar"))));
|
||||
|
||||
}
|
||||
|
||||
@Ignore
|
||||
public void snakeCase_shouldConvertAStringToSnakecase() throws Exception {
|
||||
String[] input = {
|
||||
"Foo Bar",
|
||||
"fooBar",
|
||||
"--FOO-BAR--"
|
||||
};
|
||||
|
||||
Arrays.stream(input).forEach(el ->
|
||||
assertThat(String.format("%s should be foo_bar", el), toSnakeCase(el), is(equalTo("foo_bar"))));
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user