Changeset 6992 in josm for trunk/test
 Timestamp:
 20140422T01:06:55+02:00 (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/unit/org/openstreetmap/josm/gui/SystemOfMeasurementTest.java
r6881 r6992 10 10 import org.junit.Test; 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm. gui.NavigatableComponent.SystemOfMeasurement;12 import org.openstreetmap.josm.data.SystemOfMeasurement; 13 13 14 14 /** … … 31 31 public void testGetDistText() { 32 32 33 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(1));34 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0.99));35 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0));36 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0));33 assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(1)); 34 assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(0.99)); 35 assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(0)); 36 assertEquals("< 0.01 m", SystemOfMeasurement.METRIC.getDistText(0)); 37 37 38 assertEquals("0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0.01));38 assertEquals("0.01 m", SystemOfMeasurement.METRIC.getDistText(0.01)); 39 39 40 assertEquals("0.99 m", NavigatableComponent.METRIC_SOM.getDistText(0.99));41 assertEquals("1.00 m", NavigatableComponent.METRIC_SOM.getDistText(1.0));42 assertEquals("1.01 m", NavigatableComponent.METRIC_SOM.getDistText(1.01));40 assertEquals("0.99 m", SystemOfMeasurement.METRIC.getDistText(0.99)); 41 assertEquals("1.00 m", SystemOfMeasurement.METRIC.getDistText(1.0)); 42 assertEquals("1.01 m", SystemOfMeasurement.METRIC.getDistText(1.01)); 43 43 44 assertEquals("9.99 m", NavigatableComponent.METRIC_SOM.getDistText(9.99));45 assertEquals("10.0 m", NavigatableComponent.METRIC_SOM.getDistText(10.0));46 assertEquals("10.0 m", NavigatableComponent.METRIC_SOM.getDistText(10.01));47 assertEquals("10.0 m", NavigatableComponent.METRIC_SOM.getDistText(10.049));48 assertEquals("10.1 m", NavigatableComponent.METRIC_SOM.getDistText(10.050));49 assertEquals("10.1 m", NavigatableComponent.METRIC_SOM.getDistText(10.051));44 assertEquals("9.99 m", SystemOfMeasurement.METRIC.getDistText(9.99)); 45 assertEquals("10.0 m", SystemOfMeasurement.METRIC.getDistText(10.0)); 46 assertEquals("10.0 m", SystemOfMeasurement.METRIC.getDistText(10.01)); 47 assertEquals("10.0 m", SystemOfMeasurement.METRIC.getDistText(10.049)); 48 assertEquals("10.1 m", SystemOfMeasurement.METRIC.getDistText(10.050)); 49 assertEquals("10.1 m", SystemOfMeasurement.METRIC.getDistText(10.051)); 50 50 51 assertEquals("100.0 m", NavigatableComponent.METRIC_SOM.getDistText(99.99));52 assertEquals("100.0 m", NavigatableComponent.METRIC_SOM.getDistText(100.0));53 assertEquals("100.0 m", NavigatableComponent.METRIC_SOM.getDistText(100.01));51 assertEquals("100.0 m", SystemOfMeasurement.METRIC.getDistText(99.99)); 52 assertEquals("100.0 m", SystemOfMeasurement.METRIC.getDistText(100.0)); 53 assertEquals("100.0 m", SystemOfMeasurement.METRIC.getDistText(100.01)); 54 54 55 assertEquals("1000.0 m", NavigatableComponent.METRIC_SOM.getDistText(999.99)); // TODO ? 1.00 km should be better56 assertEquals("1000.0 m", NavigatableComponent.METRIC_SOM.getDistText(1000.0)); // TODO ? 1.00 km should be better57 assertEquals("1.00 km", NavigatableComponent.METRIC_SOM.getDistText(1000.01));55 assertEquals("1000.0 m", SystemOfMeasurement.METRIC.getDistText(999.99)); // TODO ? 1.00 km should be better 56 assertEquals("1000.0 m", SystemOfMeasurement.METRIC.getDistText(1000.0)); // TODO ? 1.00 km should be better 57 assertEquals("1.00 km", SystemOfMeasurement.METRIC.getDistText(1000.01)); 58 58 59 assertEquals("10.00 km", NavigatableComponent.METRIC_SOM.getDistText(9999.99)); // TODO ? 10.0 km should be better60 assertEquals("10.0 km", NavigatableComponent.METRIC_SOM.getDistText(10000.0));61 assertEquals("10.0 km", NavigatableComponent.METRIC_SOM.getDistText(10000.01));59 assertEquals("10.00 km", SystemOfMeasurement.METRIC.getDistText(9999.99)); // TODO ? 10.0 km should be better 60 assertEquals("10.0 km", SystemOfMeasurement.METRIC.getDistText(10000.0)); 61 assertEquals("10.0 km", SystemOfMeasurement.METRIC.getDistText(10000.01)); 62 62 63 assertEquals("100.0 km", NavigatableComponent.METRIC_SOM.getDistText(99999.99));64 assertEquals("100.0 km", NavigatableComponent.METRIC_SOM.getDistText(100000.0));65 assertEquals("100.0 km", NavigatableComponent.METRIC_SOM.getDistText(100000.01));63 assertEquals("100.0 km", SystemOfMeasurement.METRIC.getDistText(99999.99)); 64 assertEquals("100.0 km", SystemOfMeasurement.METRIC.getDistText(100000.0)); 65 assertEquals("100.0 km", SystemOfMeasurement.METRIC.getDistText(100000.01)); 66 66 } 67 67 … … 72 72 public void testGetDistTextLocalized() { 73 73 final DecimalFormat format = new DecimalFormat("0.000", DecimalFormatSymbols.getInstance(Locale.GERMAN)); 74 assertEquals("0,001 m", NavigatableComponent.METRIC_SOM.getDistText(0.001, format, 1e6));75 assertEquals("< 0,010 m", NavigatableComponent.METRIC_SOM.getDistText(0.001, format, 0.01));76 assertEquals("10,051 m", NavigatableComponent.METRIC_SOM.getDistText(10.0514, format, 0.01));77 assertEquals("10,052 m", NavigatableComponent.METRIC_SOM.getDistText(10.0515, format, 0.01));78 assertEquals("100,000 km", NavigatableComponent.METRIC_SOM.getDistText(100000.0, format, 0.01));74 assertEquals("0,001 m", SystemOfMeasurement.METRIC.getDistText(0.001, format, 1e6)); 75 assertEquals("< 0,010 m", SystemOfMeasurement.METRIC.getDistText(0.001, format, 0.01)); 76 assertEquals("10,051 m", SystemOfMeasurement.METRIC.getDistText(10.0514, format, 0.01)); 77 assertEquals("10,052 m", SystemOfMeasurement.METRIC.getDistText(10.0515, format, 0.01)); 78 assertEquals("100,000 km", SystemOfMeasurement.METRIC.getDistText(100000.0, format, 0.01)); 79 79 } 80 80 … … 84 84 @Test 85 85 public void testGetAreaText() { 86 assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(1));87 assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.99));88 assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0));89 assertEquals("< 0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0));86 assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(1)); 87 assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(0.99)); 88 assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(0)); 89 assertEquals("< 0.01 m²", SystemOfMeasurement.METRIC.getAreaText(0)); 90 90 91 assertEquals("0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.01));91 assertEquals("0.01 m²", SystemOfMeasurement.METRIC.getAreaText(0.01)); 92 92 93 assertEquals("0.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.99));94 assertEquals("1.00 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.0));95 assertEquals("1.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.01));93 assertEquals("0.99 m²", SystemOfMeasurement.METRIC.getAreaText(0.99)); 94 assertEquals("1.00 m²", SystemOfMeasurement.METRIC.getAreaText(1.0)); 95 assertEquals("1.01 m²", SystemOfMeasurement.METRIC.getAreaText(1.01)); 96 96 97 assertEquals("9.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(9.99));98 assertEquals("10.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.0));99 assertEquals("10.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.01));100 assertEquals("10.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.049));101 assertEquals("10.1 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.050));102 assertEquals("10.1 m²", NavigatableComponent.METRIC_SOM.getAreaText(10.051));97 assertEquals("9.99 m²", SystemOfMeasurement.METRIC.getAreaText(9.99)); 98 assertEquals("10.0 m²", SystemOfMeasurement.METRIC.getAreaText(10.0)); 99 assertEquals("10.0 m²", SystemOfMeasurement.METRIC.getAreaText(10.01)); 100 assertEquals("10.0 m²", SystemOfMeasurement.METRIC.getAreaText(10.049)); 101 assertEquals("10.1 m²", SystemOfMeasurement.METRIC.getAreaText(10.050)); 102 assertEquals("10.1 m²", SystemOfMeasurement.METRIC.getAreaText(10.051)); 103 103 104 assertEquals("100.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(99.99));105 assertEquals("100.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(100.0));106 assertEquals("100.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(100.01));104 assertEquals("100.0 m²", SystemOfMeasurement.METRIC.getAreaText(99.99)); 105 assertEquals("100.0 m²", SystemOfMeasurement.METRIC.getAreaText(100.0)); 106 assertEquals("100.0 m²", SystemOfMeasurement.METRIC.getAreaText(100.01)); 107 107 108 assertEquals("1000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(999.99));109 assertEquals("1000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(1000.0));110 assertEquals("1000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(1000.01));108 assertEquals("1000.0 m²", SystemOfMeasurement.METRIC.getAreaText(999.99)); 109 assertEquals("1000.0 m²", SystemOfMeasurement.METRIC.getAreaText(1000.0)); 110 assertEquals("1000.0 m²", SystemOfMeasurement.METRIC.getAreaText(1000.01)); 111 111 112 assertEquals("10000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(9999.99)); // TODO ? 1.00 ha should be better113 assertEquals("10000.0 m²", NavigatableComponent.METRIC_SOM.getAreaText(10000.0)); // TODO ? 1.00 ha should be better114 assertEquals("1.00 ha", NavigatableComponent.METRIC_SOM.getAreaText(10000.01));112 assertEquals("10000.0 m²", SystemOfMeasurement.METRIC.getAreaText(9999.99)); // TODO ? 1.00 ha should be better 113 assertEquals("10000.0 m²", SystemOfMeasurement.METRIC.getAreaText(10000.0)); // TODO ? 1.00 ha should be better 114 assertEquals("1.00 ha", SystemOfMeasurement.METRIC.getAreaText(10000.01)); 115 115 116 assertEquals("10.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(99999.99));117 assertEquals("10.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(100000.0));118 assertEquals("10.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(100000.01));116 assertEquals("10.0 ha", SystemOfMeasurement.METRIC.getAreaText(99999.99)); 117 assertEquals("10.0 ha", SystemOfMeasurement.METRIC.getAreaText(100000.0)); 118 assertEquals("10.0 ha", SystemOfMeasurement.METRIC.getAreaText(100000.01)); 119 119 120 assertEquals("100.0 ha", NavigatableComponent.METRIC_SOM.getAreaText(999999.99)); // TODO ? 1.00 km² should be better121 assertEquals("1.00 km²", NavigatableComponent.METRIC_SOM.getAreaText(1000000.0));122 assertEquals("1.00 km²", NavigatableComponent.METRIC_SOM.getAreaText(1000000.01));120 assertEquals("100.0 ha", SystemOfMeasurement.METRIC.getAreaText(999999.99)); // TODO ? 1.00 km² should be better 121 assertEquals("1.00 km²", SystemOfMeasurement.METRIC.getAreaText(1000000.0)); 122 assertEquals("1.00 km²", SystemOfMeasurement.METRIC.getAreaText(1000000.01)); 123 123 124 assertEquals("10.0 km²", NavigatableComponent.METRIC_SOM.getAreaText(9999999.99));125 assertEquals("10.0 km²", NavigatableComponent.METRIC_SOM.getAreaText(10000000.0));126 assertEquals("10.0 km²", NavigatableComponent.METRIC_SOM.getAreaText(10000000.01));124 assertEquals("10.0 km²", SystemOfMeasurement.METRIC.getAreaText(9999999.99)); 125 assertEquals("10.0 km²", SystemOfMeasurement.METRIC.getAreaText(10000000.0)); 126 assertEquals("10.0 km²", SystemOfMeasurement.METRIC.getAreaText(10000000.01)); 127 127 } 128 128 }
Note: See TracChangeset
for help on using the changeset viewer.