Compares the lines in two strings for equivalence, ignoring line endings and whitespace. @param expected a string. @param actual a string. @param sort true iff the lines aer to be sorted before a comparison is done (use it if there is non-determinism in the order of the results) @return true if the
(final String expected, final String actual, final boolean sort)
| 671 | * @return true if the lines are the same. |
| 672 | */ |
| 673 | public static boolean sameLines(final String expected, final String actual, final boolean sort) { |
| 674 | final String[] erecs = splitLines(expected.trim()); |
| 675 | if (sort) { |
| 676 | Arrays.sort(erecs); |
| 677 | } |
| 678 | final String[] arecs = splitLines(actual.trim()); |
| 679 | if (sort) { |
| 680 | Arrays.sort(arecs); |
| 681 | } |
| 682 | final boolean same = sameLines(erecs, arecs); |
| 683 | if (!same) { |
| 684 | System.err.println("Actual output was:\n" + actual); |
| 685 | System.err.println("Expected output was:\n" + expected); |
| 686 | } |
| 687 | return same; |
| 688 | } |
| 689 | |
| 690 | /** |
| 691 | * Checks whether two arrays of lines are the same. |
no test coverage detected