I am implementing a gap buffer and am trying to write a test for the insert method, the test currently looks something like this:
gapBuffer.insert('a')
assertEquals(gapBuffer.getText(), "a")
gapBuffer.insert('c')
assertEquals(gapBuffer.getText(), "ac")
gapBuffer.insert('d')
assertEquals(gapBuffer.getText(), "acd")
gapBuffer.moveCursorTo(1)
gapBuffer.insert('d')
assertEquals(gapBuffer.getText(), "abcd")
Now the problem is that this method is not just testing the insert method because it depends on the correctness of the getText()
and moveCursorTo()
methods
Note: the getText()
and moveCursorTo()
methods are not trivial but do have tests of their own