Changeset 15864 in josm for trunk/src/org


Ignore:
Timestamp:
2020-02-16T15:46:03+01:00 (5 years ago)
Author:
simon04
Message:

UtilsTest: extend

Based on test coverage and mutation testing using Pitest.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r15863 r15864  
    10761076     * @param maxLength maximum number of characters to keep (not including the "...")
    10771077     * @return the shortened string
     1078     * @throws IllegalArgumentException if maxLength is less than the length of "..."
    10781079     */
    10791080    public static String shortenString(String s, int maxLength) {
     1081        final String ellipses = "...";
     1082        CheckParameterUtil.ensureThat(maxLength >= ellipses.length(), "maxLength is shorter than " + ellipses.length());
    10801083        if (s != null && s.length() > maxLength) {
    1081             return s.substring(0, maxLength - 3) + "...";
     1084            return s.substring(0, maxLength - ellipses.length()) + ellipses;
    10821085        } else {
    10831086            return s;
Note: See TracChangeset for help on using the changeset viewer.