void (String message, String expected, String actual) { int posInExpected = 0; int posInActual = 0; while (posInExpected < expected.length()) { int placeholderPos = expected.indexOf(PLATFORM_SPECIFIC_PLACEHOLDER, posInExpected); if (placeholderPos < 0) { if (posInExpected == 0 ? actual.equals(expected) : actual.substring(posInActual).endsWith(expected.substring(posInExpected))) { return; } else { throw new ComparisonFailure(message, expected, actual); } } String fixedSubstring = expected.substring(posInExpected, placeholderPos); int matchedPosInActual = actual.indexOf(fixedSubstring, posInActual); if (matchedPosInActual < 0 || posInExpected == 0 && matchedPosInActual > 0) { throw new ComparisonFailure(message, expected, actual); } posInExpected = placeholderPos + PLATFORM_SPECIFIC_PLACEHOLDER.length(); posInActual = matchedPosInActual + fixedSubstring.length(); } }