Changeset 14518 in josm for trunk


Ignore:
Timestamp:
2018-12-07T12:25:31+01:00 (6 months ago)
Author:
GerdP
Message:

fix #17081 correction and unit test

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java

    r14303 r14518  
    123123        if (primitives == null || primitives.isEmpty()) return tags;
    124124        // initialize with the first
    125         //
    126125        tags.add(TagCollection.from(primitives.iterator().next()));
    127126
     
    132131                continue;
    133132            }
    134             tags.add(tags.intersect(TagCollection.from(primitive)));
     133            tags = tags.intersect(TagCollection.from(primitive));
     134            if (tags.isEmpty())
     135                break;
    135136        }
    136137        return tags;
  • trunk/test/unit/org/openstreetmap/josm/data/osm/TagCollectionTest.java

    r14302 r14518  
    706706        assertEquals("0", f.getSummedValues("k"));
    707707    }
     708
     709    /**
     710     * Test method for {@link TagCollection#commonToAllPrimitives(Collection)}.
     711     */
     712    @Test
     713    public void testCommonToAllPrimitives() {
     714        Tagged t1 = new Node();
     715        t1.put("k1", "10");
     716        t1.put("k2", "20");
     717        Tagged t2 = new Node();
     718        t2.put("k2", "20");
     719        TagCollection c = TagCollection.commonToAllPrimitives(Arrays.asList(t1, t2));
     720        assertEquals(1, c.size());
     721        assertFalse(c.hasValuesFor("k1"));
     722        assertTrue(c.hasValuesFor("k2"));
     723        assertEquals(1, c.getValues("k2").size());
     724        assertEquals("20", c.getValues("k2").iterator().next());
     725    }
    708726}
Note: See TracChangeset for help on using the changeset viewer.