@Test
  public void testErase() {
    engine.erase();
    Assert.assertTrue("Erase() - Buffer isn't empty", buffer.getText().equals(""));
    Assert.assertTrue(
        "Erase() - Selection isn't (0, 0)",
        selection.getStart() == 0 && selection.getLength() == 0);

    buffer.setText("test");
    engine.erase();
    Assert.assertTrue(
        "Erase() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue(
        "Erase() - Selection isn't (0, 0)",
        selection.getStart() == 0 && selection.getLength() == 0);

    selection.setStart(4);
    engine.erase();
    Assert.assertTrue(
        "Erase() - Buffer content isn't the set text", buffer.getText().equals("tes"));
    Assert.assertTrue(
        "Erase() - Selection isn't (3, 0)",
        selection.getStart() == 3 && selection.getLength() == 0);

    selection.setStart(0);
    selection.setLength(3);
    engine.erase();
    Assert.assertTrue("Erase() - Buffer content isn't the set text", buffer.getText().equals(""));
    Assert.assertTrue(
        "Erase() - Selection isn't (0, 0)",
        selection.getStart() == 0 && selection.getLength() == 0);
  }
  @Test
  public void testCopy() {
    engine.copy();
    Assert.assertTrue("Copy() - Buffer isn't empty", buffer.getText().equals(""));
    Assert.assertTrue("Copy() - Clipboard isn't empty", clipboard.getText().equals(""));
    Assert.assertTrue(
        "Copy() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0);

    buffer.setText("test");
    engine.copy();
    Assert.assertTrue(
        "Copy() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue("Copy() - Clipboard isn't empty", clipboard.getText().equals(""));
    Assert.assertTrue(
        "Copy() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0);

    selection.setStart(0);
    selection.setLength(4);
    engine.copy();
    Assert.assertTrue(
        "Copy() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue("Copy() - Clipboard is empty", clipboard.getText().equals("test"));
    Assert.assertTrue(
        "Copy() - Selection isn't (0, 4)", selection.getStart() == 0 && selection.getLength() == 4);

    selection.setLength(0);
    engine.copy();
    Assert.assertTrue(
        "Copy() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue(
        "Copy() - Clipboard is changed but copy when no text selected",
        clipboard.getText().equals("test"));
    Assert.assertTrue(
        "Copy() - Selection isn't (0, 0)", selection.getStart() == 0 && selection.getLength() == 0);
  }
  @Test
  public void testGetSelectionStart() {
    Assert.assertTrue(
        "GetSelectionStart() - Return start doesn't the selection start",
        engine.getSelectionStart() == 0);

    selection.setStart(1);
    Assert.assertTrue(
        "GetSelectionStart() - Return start doesn't the selection start",
        engine.getSelectionStart() == 1);
  }
  @Test
  public void testType() {
    engine.type('c');
    Assert.assertTrue("Type() - Buffer isn't empty", buffer.getText().equals("c"));
    Assert.assertTrue(
        "Type() - Selection isn't (0, 0)", selection.getStart() == 1 && selection.getLength() == 0);

    selection.setStart(0);
    selection.setLength(1);
    engine.type('a');
    Assert.assertTrue("Type() - Buffer content isn't the set text", buffer.getText().equals("a"));
    Assert.assertTrue(
        "Type() - Selection isn't (0, 0)", selection.getStart() == 1 && selection.getLength() == 0);
  }
  @Test
  public void testPaste() {
    engine.paste();
    Assert.assertTrue("Paste() - Buffer isn't empty", buffer.getText().equals(""));
    Assert.assertTrue("Paste() - Clipboard isn't empty", clipboard.getText().equals(""));
    Assert.assertTrue(
        "Paste() - Selection isn't (0, 0)",
        selection.getStart() == 0 && selection.getLength() == 0);

    clipboard.setText("test");
    engine.paste();
    Assert.assertTrue(
        "Paste() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue("Paste() - Clipboard is empty", clipboard.getText().equals("test"));
    Assert.assertTrue(
        "Paste() - Selection isn't (4, 0)",
        selection.getStart() == 4 && selection.getLength() == 0);

    selection.setStart(1);
    engine.paste();
    Assert.assertTrue(
        "Paste() - Buffer content isn't the set text", buffer.getText().equals("ttestest"));
    Assert.assertTrue("Paste() - Clipboard is empty", clipboard.getText().equals("test"));
    Assert.assertTrue(
        "Paste() - Selection isn't (5, 0)",
        selection.getStart() == 5 && selection.getLength() == 0);

    selection.setStart(0);
    selection.setLength(8);
    engine.paste();
    Assert.assertTrue(
        "Paste() - Buffer content isn't the set text", buffer.getText().equals("test"));
    Assert.assertTrue("Paste() - Clipboard is empty", clipboard.getText().equals("test"));
    Assert.assertTrue(
        "Paste() - Selection isn't (4, 0)",
        selection.getStart() == 4 && selection.getLength() == 0);
  }