void (String initial, String expected, TextChangeImpl ... changes) { if (myConfig.inplace()) { int diff = 0; for (TextChangeImpl change : changes) { diff += change.getDiff(); } int outputUsefulLength = initial.length() + diff; int dataLength = myConfig.dataArrayLength(); if (dataLength < 0) { dataLength = Math.max(outputUsefulLength, initial.length()); } char[] data = new char[dataLength]; System.arraycopy(initial.toCharArray(), 0, data, 0, initial.length()); myMerger.mergeInPlace(data, initial.length(), Arrays.asList(changes)); assertEquals(expected, new String(data, 0, outputUsefulLength)); } else { int interestedSymbolsNumber = myConfig.initialTextLength(); if (interestedSymbolsNumber < 0) { interestedSymbolsNumber = initial.length(); } CharSequence actual = myMerger.mergeToCharSequence(initial.toCharArray(), interestedSymbolsNumber, Arrays.asList(changes)); assertEquals(expected, actual.toString()); } }