Changeset 17914 in josm for trunk/test/unit


Ignore:
Timestamp:
2021-05-27T19:41:24+02:00 (3 years ago)
Author:
simon04
Message:

fix #20933 - NumberFormatException: For input string: "333,662" (patch by taylor.smock, modified)

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/vectortile/mapbox/FeatureTest.java

    r17862 r17914  
    1313
    1414import java.text.NumberFormat;
     15import java.util.ArrayList;
    1516import java.util.Arrays;
     17import java.util.List;
    1618
    1719import org.junit.jupiter.api.Test;
     20import org.openstreetmap.josm.testutils.annotations.I18n;
    1821
    1922/**
     
    5154        // 49 74 24 00 == 1_000_000f
    5255        // 3f 80 00 00 == 1f
    53         byte[] newBytes = new byte[] {0x22, 0x09, 0x15, 0x00, 0x24, 0x74, 0x49};
     56        byte[] newBytes = new byte[] {0x22, 0x05, 0x15, 0x00, 0x24, 0x74, 0x49};
    5457        byte[] copyBytes = Arrays.copyOf(getSimpleFeatureLayerBytes(), getSimpleFeatureLayerBytes().length + newBytes.length - 4);
    5558        // Change last few bytes
     
    7881        checkDefaultGeometry(feature);
    7982        assertEquals("1000000", feature.getTags().get("a"));
     83    }
     84
     85    /**
     86     * Non-regression test for #20933 (Russian)
     87     * @see #testNumberGroupingDecimalEn()
     88     */
     89    @I18n("ru")
     90    @Test
     91    void testNumberGroupingDecimalRu() {
     92        testNumberGroupingDecimal();
     93    }
     94
     95    /**
     96     * Non-regression test for #20933 (English)
     97     * @see #testNumberGroupingDecimalRu()
     98     */
     99    @I18n("en")
     100    @Test
     101    void testNumberGroupingDecimalEn() {
     102        testNumberGroupingDecimal();
     103    }
     104
     105    /**
     106     * Common parts for non-regression tests for #20933
     107     * @see #testNumberGroupingDecimalEn()
     108     * @see #testNumberGroupingDecimalRu()
     109     */
     110    private void testNumberGroupingDecimal() {
     111        byte[] newBytes = new byte[] {0x22, 0x09, 0x19, -45, 0x4D, 0x62, 0x10, 0x58, -71, 0x67, 0x40};
     112        byte[] copyBytes = Arrays.copyOf(getSimpleFeatureLayerBytes(), getSimpleFeatureLayerBytes().length + newBytes.length - 4);
     113        // Change last few bytes
     114        System.arraycopy(newBytes, 0, copyBytes, 25, newBytes.length);
     115        // Update the length of the record
     116        copyBytes[1] = (byte) (copyBytes[1] + newBytes.length - 4);
     117        Layer layer = assertDoesNotThrow(() -> getLayer(copyBytes));
     118        layer.getKey(0);
     119        List<Feature> features = new ArrayList<>(layer.getFeatures());
     120        assertEquals(1, features.size());
     121        assertEquals("189.792", features.get(0).getTags().get("a"));
    80122    }
    81123
Note: See TracChangeset for help on using the changeset viewer.