Exemplo n.º 1
0
 /**
  * Verify that CString can store and evaluate basic strings.
  *
  * @throws Exception e
  */
 @Test
 public void evalShouldReturnBasicValue() throws Exception {
   final String string = "basic";
   final CString cString = CString.create(string);
   final String eval = cString.toString();
   assertThat(eval).isEqualTo(string);
 }
Exemplo n.º 2
0
  @Test
  public void insertString() throws Exception {
    final CString foo = CString.create("fooar");
    final CString foobar = foo.insert("b", 3);

    assertThat(foobar.toString()).isEqualTo("foobar");
  }
Exemplo n.º 3
0
  @Test
  public void delete() throws Exception {
    CString foobar = CString.create("foobar");
    CString bar = foobar.delete(0, 3);

    assertThat(bar.toString()).isEqualTo("bar");
  }
Exemplo n.º 4
0
  @Test
  public void concatStringTest() throws Exception {
    final CString foo = CString.create("foo");
    final CString foobar = foo.concat("bar");

    assertThat(foobar.toString()).isEqualTo("foobar");
  }
Exemplo n.º 5
0
 /**
  * Verify that we can substring a value once.
  *
  * @throws Exception e
  */
 @Test
 public void shouldBeAbleToSubstring() throws Exception {
   final String string = "substr";
   final int index = 3;
   final CString initial = CString.create(string);
   final CString substring = initial.substring(index);
   final String evaluated = substring.toString();
   assertThat(evaluated).isEqualTo(string.substring(index));
 }
Exemplo n.º 6
0
 /**
  * Verify that substrings of substrings are working.
  *
  * @throws Exception e
  */
 @Test
 public void substringOfSubstring() throws Exception {
   final CString initial = CString.create("abc");
   final CString first = initial.substring(1);
   final CString second = first.substring(1);
   final String evaluated = second.toString();
   assertThat(evaluated).isEqualTo("c");
 }
Exemplo n.º 7
0
 /**
  * Verify that substring operations with an index higher than the length of the underlying
  * CString, then an empty string should be returned.
  */
 @Test
 public void substringWithIndexOutsideBoundsShouldBeEmptyString() {
   final String foobar = "foobar";
   final String substr = CString.create(foobar).substring(foobar.length()).toString();
   assertThat(substr).isEqualTo("");
 }
Exemplo n.º 8
0
  @Test
  public void create() throws Exception {
    CString foobar = CString.create("foobar");

    assertThat(foobar.toString()).isEqualTo("foobar");
  }
Exemplo n.º 9
0
 @Test
 public void substring() throws Exception {
   CString foobar = CString.create("foobar").substring(3, 4);
   String s = foobar.toString();
   assertThat(s).isEqualTo("foobar".substring(3, 4));
 }