/** * 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); }
@Test public void insertString() throws Exception { final CString foo = CString.create("fooar"); final CString foobar = foo.insert("b", 3); assertThat(foobar.toString()).isEqualTo("foobar"); }
@Test public void delete() throws Exception { CString foobar = CString.create("foobar"); CString bar = foobar.delete(0, 3); assertThat(bar.toString()).isEqualTo("bar"); }
@Test public void concatStringTest() throws Exception { final CString foo = CString.create("foo"); final CString foobar = foo.concat("bar"); assertThat(foobar.toString()).isEqualTo("foobar"); }
/** * 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)); }
/** * 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"); }
/** * 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(""); }
@Test public void create() throws Exception { CString foobar = CString.create("foobar"); assertThat(foobar.toString()).isEqualTo("foobar"); }
@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)); }