StringUtils { public static int addLineSeparator(SpannableStringBuilder sb, boolean force) { int start = sb.length(); if (force || start > 0) { sb.append(LINE_SEPARATOR); start++; } return start; } private  StringUtils(); static String appendOptional(String first, String second); static String appendOptional(String first, String second, String separator); static String strJoin(List<String> entries, String separator); static int addLineSeparator(SpannableStringBuilder sb, boolean force); static int addLineSeparator(SpannableStringBuilder sb); static Spanned createSpannedHtmlLink(String name, String url); static final String COMMA_SEPARATOR; static final String LINE_SEPARATOR; static final String HTML_LINE_SEPARATOR; static final String ZERO_WIDTH_SPACE; }
@Test public void should_add_line_separator_to_non_empty_spannable_string_builder() { SpannableStringBuilder sb = new SpannableStringBuilder("Hello"); StringUtils.addLineSeparator(sb); assertThat(sb.toString()).isEqualTo("Hello" + StringUtils.LINE_SEPARATOR); }
@Test public void should_not_add_line_separator_to_empty_spannable_string_builder() { SpannableStringBuilder sb = new SpannableStringBuilder(); StringUtils.addLineSeparator(sb); assertThat(sb.toString()).isEmpty(); }
@Test public void should_add_line_separator_to_empty_spannable_string_builder_if_force_arg_is_true() { SpannableStringBuilder sb = new SpannableStringBuilder(); StringUtils.addLineSeparator(sb, true); assertThat(sb.toString()).isEqualTo(StringUtils.LINE_SEPARATOR); }