Ignore:
Timestamp:
2018-08-06T00:26:16+02:00 (6 years ago)
Author:
Don-vip
Message:

increase test coverage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java

    r13920 r14100  
    1414import java.util.Collection;
    1515import java.util.Collections;
    16 
     16import java.util.Set;
     17
     18import org.junit.Assert;
    1719import org.junit.Rule;
    1820import org.junit.Test;
     
    3941import org.openstreetmap.josm.gui.tagging.presets.items.Key;
    4042import org.openstreetmap.josm.testutils.JOSMTestRules;
     43import org.openstreetmap.josm.tools.Logging;
    4144import org.openstreetmap.josm.tools.date.DateUtils;
    4245
    4346import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     47import nl.jqno.equalsverifier.EqualsVerifier;
     48import nl.jqno.equalsverifier.Warning;
    4449
    4550/**
     
    701706        }
    702707    }
     708
     709    /**
     710     * Unit test of methods {@link Match#equals} and {@link Match#hashCode}, including all subclasses.
     711     */
     712    @Test
     713    public void testEqualsContract() {
     714        TestUtils.assumeWorkingEqualsVerifier();
     715        Set<Class<? extends Match>> matchers = TestUtils.getJosmSubtypes(Match.class);
     716        Assert.assertTrue(matchers.size() >= 10); // if it finds less than 10 classes, something is broken
     717        for (Class<?> c : matchers) {
     718            Logging.debug(c.toString());
     719            EqualsVerifier.forClass(c).usingGetClass()
     720                .suppress(Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT)
     721                .withPrefabValues(TaggingPreset.class, newTaggingPreset("foo"), newTaggingPreset("bar"))
     722                .verify();
     723        }
     724    }
     725
     726    private static TaggingPreset newTaggingPreset(String name) {
     727        TaggingPreset result = new TaggingPreset();
     728        result.name = name;
     729        return result;
     730    }
    703731}
Note: See TracChangeset for help on using the changeset viewer.