Home | History | Annotate | Download | only in util
      1 /*
      2  * Copyright (c) 2007 Mockito contributors
      3  * This program is made available under the terms of the MIT License.
      4  */
      5 
      6 package org.mockito.internal.util;
      7 
      8 import static junit.framework.TestCase.assertEquals;
      9 import static org.assertj.core.api.Assertions.assertThat;
     10 
     11 import org.junit.Test;
     12 
     13 public class StringUtilTest  {
     14 
     15     @Test
     16     public void decamelizeMatcher() throws Exception {
     17         assertEquals("<Sentence with strong language>", StringUtil.decamelizeMatcher("SentenceWithStrongLanguage"));
     18         assertEquals("<W e i r d o 1>", StringUtil.decamelizeMatcher("WEIRDO1"));
     19         assertEquals("<_>", StringUtil.decamelizeMatcher("_"));
     20         assertEquals("<Has exactly 3 elements>", StringUtil.decamelizeMatcher("HasExactly3Elements"));
     21         assertEquals("<custom argument matcher>", StringUtil.decamelizeMatcher(""));
     22     }
     23 
     24     @Test
     25     public void join_non() throws Exception {
     26         assertThat(StringUtil.join()).isEmpty();;
     27     }
     28 
     29     @Test
     30     public void join_singleLine() throws Exception {
     31         assertThat(StringUtil.join("line1")).hasLineCount(2);
     32     }
     33 
     34     @Test
     35     public void join_twoLines() throws Exception {
     36         assertThat(StringUtil.join("line1","line2")).hasLineCount(3);
     37     }
     38 
     39     @Test
     40     public void join_hasPreceedingLinebreak() throws Exception {
     41         assertThat(StringUtil.join("line1")).isEqualTo("\nline1");
     42     }
     43 
     44     @Test
     45     public void removeFirstLine() throws Exception {
     46         assertThat(StringUtil.removeFirstLine("line1\nline2")).isEqualTo("line2");
     47     }
     48 }
     49