/** * Asserts that the line count of the given {@code CharSequence} is equal to the expected one. * * @param info contains information about the assertion. * @param actual the given {@code CharSequence}. * @param expectedLineCount the expected line count of {@code actual}. * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the line count of the given {@code CharSequence} is different than the expected one. */ public void assertHasLineCount(AssertionInfo info, CharSequence actual, int expectedLineCount) { assertNotNull(info, actual); LineNumberReader reader = new LineNumberReader(new StringReader(actual.toString())); try { while (reader.readLine() != null); } catch (IOException e) { throw new InputStreamsException(format("Unable to count lines in `%s`", actual), e); } checkLineCounts(actual, reader.getLineNumber(), expectedLineCount, info); }
/** * Asserts that the line count of the given {@code CharSequence} is equal to the expected one. * * @param info contains information about the assertion. * @param actual the given {@code CharSequence}. * @param expectedLineCount the expected line count of {@code actual}. * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the line count of the given {@code CharSequence} is different than the expected one. */ public void assertHasLineCount(AssertionInfo info, CharSequence actual, int expectedLineCount) { assertNotNull(info, actual); LineNumberReader reader = new LineNumberReader(new StringReader(actual.toString())); try { while (reader.readLine() != null); } catch (IOException e) { throw new InputStreamsException(format("Unable to count lines in `%s`", actual), e); } checkLineCounts(actual, reader.getLineNumber(), expectedLineCount, info); }
/** * Asserts that the line count of the given {@code CharSequence} is equal to the expected one. * * @param info contains information about the assertion. * @param actual the given {@code CharSequence}. * @param expectedLineCount the expected line count of {@code actual}. * @throws AssertionError if the given {@code CharSequence} is {@code null}. * @throws AssertionError if the line count of the given {@code CharSequence} is different than the expected one. */ public void assertHasLineCount(AssertionInfo info, CharSequence actual, int expectedLineCount) { assertNotNull(info, actual); LineNumberReader reader = new LineNumberReader(new StringReader(actual.toString())); try { while ((reader.readLine()) != null); } catch (IOException e) { String msg = format("Unable to count lines in `%s`", actual); throw new InputStreamsException(msg, e); } checkLineCounts(actual, reader.getLineNumber(), expectedLineCount, info); }