23 const START_OFFSET = 10;
25 const CONTENT =
"foo bar baz";
32 protected function setUp()
34 $this->fragment =
new TextFragment(self::START_OFFSET, self::CONTENT);
37 public function testGetStartOffset()
39 assertThat($this->fragment->getStartOffset(), is(self::START_OFFSET));
42 public function testGetEndOffset()
44 assertThat($this->fragment->getEndOffset(), is(self::START_OFFSET + 11));
47 public function testGetSliceRegular()
49 assertThat($this->fragment->getSlice(self::START_OFFSET, self::START_OFFSET + 3), is(
"foo"));
50 assertThat($this->fragment->getSlice(self::START_OFFSET + 4, self::START_OFFSET + 4 + 3), is(
"bar"));
51 assertThat($this->fragment->getSlice(self::START_OFFSET + 8, self::START_OFFSET + 8 + 3), is(
"baz"));
54 public function testGetSliceWithoutEnd()
56 assertThat($this->fragment->getSlice(self::START_OFFSET + 8), is(
"baz"));
59 public function testGetSliceAtLeftEdge()
61 assertThat($this->fragment->getSlice(self::START_OFFSET - 1, self::START_OFFSET - 1 + 3), is(
"fo"));
64 public function testGetSliceAtRightEdge()
66 assertThat($this->fragment->getSlice(self::START_OFFSET + 9, self::START_OFFSET + 9 + 3), is(
"az"));