public function testCleanupSemanticLossless()
 {
     // Slide diffs to match logical boundaries.
     // Null case.
     $this->d->setChanges(array());
     $this->d->cleanupSemanticLossless();
     $this->assertEquals(array(), $this->d->getChanges());
     // Blank lines.
     $this->d->setChanges(array(array(Diff::EQUAL, "AAA\r\n\r\nBBB"), array(Diff::INSERT, "\r\nDDD\r\n\r\nBBB"), array(Diff::EQUAL, "\r\nEEE")));
     $this->d->cleanupSemanticLossless();
     $this->assertEquals(array(array(Diff::EQUAL, "AAA\r\n\r\n"), array(Diff::INSERT, "BBB\r\nDDD\r\n\r\n"), array(Diff::EQUAL, "BBB\r\nEEE")), $this->d->getChanges());
     // Line boundaries.
     $this->d->setChanges(array(array(Diff::EQUAL, "AAA\r\nBBB"), array(Diff::INSERT, " DDD\r\nBBB"), array(Diff::EQUAL, " EEE")));
     $this->d->cleanupSemanticLossless();
     $this->assertEquals(array(array(Diff::EQUAL, "AAA\r\n"), array(Diff::INSERT, "BBB DDD\r\n"), array(Diff::EQUAL, "BBB EEE")), $this->d->getChanges());
     // Word boundaries.
     $this->d->setChanges(array(array(Diff::EQUAL, "The c"), array(Diff::INSERT, "ow and the c"), array(Diff::EQUAL, "at.")));
     $this->d->cleanupSemanticLossless();
     $this->assertEquals(array(array(Diff::EQUAL, "The "), array(Diff::INSERT, "cow and the "), array(Diff::EQUAL, "cat.")), $this->d->getChanges());
     // Alphanumeric boundaries.
     $this->d->setChanges(array(array(Diff::EQUAL, "The-c"), array(Diff::INSERT, "ow-and-the-c"), array(Diff::EQUAL, "at.")));
     $this->d->cleanupSemanticLossless();
     $this->assertEquals(array(array(Diff::EQUAL, "The-"), array(Diff::INSERT, "cow-and-the-"), array(Diff::EQUAL, "cat.")), $this->d->getChanges());
     // Hitting the start.
     $this->d->setChanges(array(array(Diff::EQUAL, "a"), array(Diff::DELETE, "a"), array(Diff::EQUAL, "ax")));
     $this->d->cleanupSemanticLossless();
     $this->assertEquals(array(array(Diff::DELETE, "a"), array(Diff::EQUAL, "aax")), $this->d->getChanges());
     // Hitting the end.
     $this->d->setChanges(array(array(Diff::EQUAL, "xa"), array(Diff::DELETE, "a"), array(Diff::EQUAL, "a")));
     $this->d->cleanupSemanticLossless();
     $this->assertEquals(array(array(Diff::EQUAL, "xaa"), array(Diff::DELETE, "a")), $this->d->getChanges());
     // Sentence boundaries.
     $this->d->setChanges(array(array(Diff::EQUAL, "The xxx. The "), array(Diff::INSERT, "zzz. The "), array(Diff::EQUAL, "yyy.")));
     $this->d->cleanupSemanticLossless();
     $this->assertEquals(array(array(Diff::EQUAL, "The xxx."), array(Diff::INSERT, " The zzz."), array(Diff::EQUAL, " The yyy.")), $this->d->getChanges());
 }