Changeset 7098 in josm for trunk/test


Ignore:
Timestamp:
2014-05-10T20:07:23+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #9632 - fix relation comparator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/DefaultNameFormatterTest.java

    r7097 r7098  
    22package org.openstreetmap.josm.gui;
    33
     4import static org.junit.Assert.assertTrue;
    45import static org.junit.Assert.fail;
    56
     
    1617import org.openstreetmap.josm.TestUtils;
    1718import org.openstreetmap.josm.data.osm.DataSet;
     19import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1820import org.openstreetmap.josm.data.osm.Relation;
    1921import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
     
    5355        try (InputStream is = new FileInputStream(TestUtils.getTestDataRoot() + "regress/9632/data.osm.zip")) {
    5456            DataSet ds = OsmReader.parseDataSet(Compression.ZIP.getUncompressedInputStream(is), null);
     57
     58            // Test with 3 known primitives causing the problem. Correct order is p1, p3, p2 with this preset
     59            Relation p1 = (Relation) ds.getPrimitiveById(2983382, OsmPrimitiveType.RELATION);
     60            Relation p2 = (Relation) ds.getPrimitiveById(550315, OsmPrimitiveType.RELATION);
     61            Relation p3 = (Relation) ds.getPrimitiveById(167042, OsmPrimitiveType.RELATION);
     62
     63            System.out.println("p1: "+DefaultNameFormatter.getInstance().format(p1)+" - "+p1); // route_master ("Bus 453", 6 members)
     64            System.out.println("p2: "+DefaultNameFormatter.getInstance().format(p2)+" - "+p2); // TMC ("A 6 Kaiserslautern - Mannheim [negative]", 123 members)
     65            System.out.println("p3: "+DefaultNameFormatter.getInstance().format(p3)+" - "+p3); // route(lcn Sal  Salier-Radweg(412 members)
     66
     67            assertTrue(comparator.compare(p1, p2) == -1); // p1 < p2
     68            assertTrue(comparator.compare(p2, p1) ==  1); // p2 > p1
     69
     70            assertTrue(comparator.compare(p1, p3) == -1); // p1 < p3
     71            assertTrue(comparator.compare(p3, p1) ==  1); // p3 > p1
     72            assertTrue(comparator.compare(p2, p3) ==  1); // p2 > p3
     73            assertTrue(comparator.compare(p3, p2) == -1); // p3 < p2
     74
    5575            Relation[] relations = new ArrayList<>(ds.getRelations()).toArray(new Relation[0]);
    56             System.out.println(Arrays.toString(relations));
     76
    5777            // Check each compare possibility
    5878            for (int i=0; i<relations.length; i++) {
Note: See TracChangeset for help on using the changeset viewer.