Changeset 8857 in josm for trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
- Timestamp:
- 2015-10-11T17:28:19+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r8756 r8857 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 7 6 import java.io.BufferedReader; … … 109 108 @Test 110 109 public void testPositionListString() { 111 assert That(Utils.getPositionListString(Arrays.asList(1)), is("1"));112 assert That(Utils.getPositionListString(Arrays.asList(1, 2, 3)), is("1-3"));113 assert That(Utils.getPositionListString(Arrays.asList(3, 1, 2)), is("1-3"));114 assert That(Utils.getPositionListString(Arrays.asList(1, 2, 3, 6, 7, 8)), is("1-3,6-8"));115 assert That(Utils.getPositionListString(Arrays.asList(1, 5, 2, 6, 7)), is("1-2,5-7"));110 assertEquals("1", Utils.getPositionListString(Arrays.asList(1))); 111 assertEquals("1-3", Utils.getPositionListString(Arrays.asList(1, 2, 3))); 112 assertEquals("1-3", Utils.getPositionListString(Arrays.asList(3, 1, 2))); 113 assertEquals("1-3,6-8", Utils.getPositionListString(Arrays.asList(1, 2, 3, 6, 7, 8))); 114 assertEquals("1-2,5-7", Utils.getPositionListString(Arrays.asList(1, 5, 2, 6, 7))); 116 115 } 117 116 … … 122 121 public void testDurationString() { 123 122 I18n.set("en"); 124 assert That(Utils.getDurationString(123), is("123 ms"));125 assert That(Utils.getDurationString(1234), is("1.2 s"));126 assert That(Utils.getDurationString(57 * 1000), is("57.0 s"));127 assert That(Utils.getDurationString(507 * 1000), is("8 min 27 s"));128 assert That(Utils.getDurationString((long) (8.4 * 60 * 60 * 1000)), is("8 h 24 min"));129 assert That(Utils.getDurationString((long) (1.5 * 24 * 60 * 60 * 1000)), is("1 day 12 h"));130 assert That(Utils.getDurationString((long) (8.5 * 24 * 60 * 60 * 1000)), is("8 days 12 h"));123 assertEquals("123 ms", Utils.getDurationString(123)); 124 assertEquals("1.2 s", Utils.getDurationString(1234)); 125 assertEquals("57.0 s", Utils.getDurationString(57 * 1000)); 126 assertEquals("8 min 27 s", Utils.getDurationString(507 * 1000)); 127 assertEquals("8 h 24 min", Utils.getDurationString((long) (8.4 * 60 * 60 * 1000))); 128 assertEquals("1 day 12 h", Utils.getDurationString((long) (1.5 * 24 * 60 * 60 * 1000))); 129 assertEquals("8 days 12 h", Utils.getDurationString((long) (8.5 * 24 * 60 * 60 * 1000))); 131 130 } 132 131 132 /** 133 * Test of {@link Utils#escapeReservedCharactersHTML} method. 134 */ 133 135 @Test 134 public void testEscapeReservedCharactersHTML() throws Exception{135 assert That(Utils.escapeReservedCharactersHTML("foo -> bar -> '&'"), is("foo -> bar -> '&'"));136 public void testEscapeReservedCharactersHTML() { 137 assertEquals("foo -> bar -> '&'", Utils.escapeReservedCharactersHTML("foo -> bar -> '&'")); 136 138 } 137 139 140 /** 141 * Test of {@link Utils#restrictStringLines} method. 142 */ 138 143 @Test 139 public void testRestrictStringLines() throws Exception{140 assert That(Utils.restrictStringLines("1\n2\n3", 2), is("1\n..."));141 assert That(Utils.restrictStringLines("1\n2\n3", 3), is("1\n2\n3"));142 assert That(Utils.restrictStringLines("1\n2\n3", 4), is("1\n2\n3"));144 public void testRestrictStringLines() { 145 assertEquals("1\n...", Utils.restrictStringLines("1\n2\n3", 2)); 146 assertEquals("1\n2\n3", Utils.restrictStringLines("1\n2\n3", 3)); 147 assertEquals("1\n2\n3", Utils.restrictStringLines("1\n2\n3", 4)); 143 148 } 144 149 }
Note:
See TracChangeset
for help on using the changeset viewer.