Changeset 10133 in josm for trunk/test


Ignore:
Timestamp:
2016-04-10T13:37:15+02:00 (4 years ago)
Author:
Don-vip
Message:

increase code coverage

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTest.java

    r9967 r10133  
    2020import static org.junit.Assert.assertFalse;
    2121import static org.junit.Assert.assertNotNull;
     22import static org.junit.Assert.assertNull;
    2223import static org.junit.Assert.assertTrue;
    2324import static org.junit.Assert.fail;
     
    478479        return sorted && strictlySorted && lowerCase;
    479480    }
     481
     482    /**
     483     * Unit test of {@link DomainValidator#getValidatorName}.
     484     */
     485    @Test
     486    public void testValidatorName() {
     487        assertNull(DomainValidator.getInstance().getValidatorName());
     488    }
    480489}
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/EmailValidatorTest.java

    r9853 r10133  
    574574        assertTrue(validator.isValid("abc@school.school"));
    575575    }
     576
     577    /**
     578     * Unit test of {@link EmailValidator#getValidatorName}.
     579     */
     580    @Test
     581    public void testValidatorName() {
     582        assertEquals("Email validator", EmailValidator.getInstance().getValidatorName());
     583    }
    576584}
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/InetAddressValidatorTest.java

    r9853 r10133  
    1919
    2020import static org.junit.Assert.assertFalse;
     21import static org.junit.Assert.assertNull;
    2122import static org.junit.Assert.assertTrue;
    2223
     
    615616    // CHECKSTYLE.ON: MethodLengthCheck
    616617    // CHECKSTYLE.ON: LineLength
     618
     619    /**
     620     * Unit test of {@link InetAddressValidator#getValidatorName}.
     621     */
     622    @Test
     623    public void testValidatorName() {
     624        assertNull(new InetAddressValidator().getValidatorName());
     625    }
    617626}
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/RegexValidatorTest.java

    r9967 r10133  
    257257
    258258    /**
     259     * Unit test of {@link RegexValidator#getValidatorName}.
     260     */
     261    @Test
     262    public void testValidatorName() {
     263        assertNull(new RegexValidator(".*").getValidatorName());
     264    }
     265
     266    /**
    259267     * Compare two arrays
    260268     * @param label Label for the test
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/UrlValidatorTest.java

    r9967 r10133  
    546546   }
    547547
     548   /**
     549    * Unit test of {@link UrlValidator#getValidatorName}.
     550    */
     551   @Test
     552   public void testValidatorName() {
     553       assertEquals("URL validator", UrlValidator.getInstance().getValidatorName());
     554   }
     555
    548556   //-------------------- Test data for creating a composite URL
    549557   /**
  • trunk/test/unit/org/openstreetmap/josm/gui/correction/RoleCorrectionTableTest.java

    r10130 r10133  
    3939        RelationMember member = new RelationMember("foo", new Node());
    4040        r.addMember(member);
    41         RoleCorrectionTable t = new RoleCorrectionTable(Arrays.asList(new RoleCorrection(r, 0, member, "bar")));
     41        RoleCorrection rc = new RoleCorrection(r, 0, member, "bar");
     42        RoleCorrectionTable t = new RoleCorrectionTable(Arrays.asList(rc));
    4243        assertNotNull(t.getCellRenderer(0, 0));
    4344        assertNotNull(t.getCellRenderer(0, 1));
     
    6364        assertEquals(Boolean.TRUE, model.getValueAt(0, 3));
    6465        assertNull(model.getValueAt(0, 4));
     66        model.setValueAt("", 0, 0);
     67        assertEquals("relation (0, 1 member)", model.getValueAt(0, 0));
     68        model.setValueAt("", 0, 3);
     69        assertEquals(Boolean.TRUE, model.getValueAt(0, 3));
     70        model.setValueAt(Boolean.FALSE, 0, 3);
     71        assertEquals(Boolean.FALSE, model.getValueAt(0, 3));
     72        RoleCorrection[] array = new RoleCorrection[15];
     73        Arrays.fill(array, rc);
     74        t = new RoleCorrectionTable(Arrays.asList(array));
     75        assertEquals(array.length, t.getCorrectionTableModel().getCorrections().size());
    6576    }
    6677}
  • trunk/test/unit/org/openstreetmap/josm/gui/correction/TagCorrectionTableTest.java

    r10130 r10133  
    3333    @Test
    3434    public void testTagCorrectionTable() {
    35         TagCorrectionTable t = new TagCorrectionTable(Arrays.asList(new TagCorrection("foo", "bar", "foo", "baz")));
     35        TagCorrection tc1 = new TagCorrection("foo", "bar", "foo", "baz");
     36        TagCorrection tc2 = new TagCorrection("bar", "foo", "baz", "foo");
     37        TagCorrectionTable t = new TagCorrectionTable(Arrays.asList(tc1, tc2));
    3638        assertNotNull(t.getCellRenderer(0, 0));
    3739        assertNotNull(t.getCellRenderer(0, 1));
    3840        assertNotNull(t.getCellRenderer(0, 2));
    3941        assertNotNull(t.getCellRenderer(0, 3));
     42        assertNotNull(t.getCellRenderer(0, 4));
     43        assertNotNull(t.getCellRenderer(1, 0));
     44        assertNotNull(t.getCellRenderer(1, 1));
     45        assertNotNull(t.getCellRenderer(1, 2));
     46        assertNotNull(t.getCellRenderer(1, 3));
     47        assertNotNull(t.getCellRenderer(1, 4));
    4048        TagCorrectionTableModel model = t.getCorrectionTableModel();
    41         assertEquals(1, model.getCorrections().size());
    42         assertEquals(1, model.getRowCount());
     49        assertEquals(2, model.getCorrections().size());
     50        assertEquals(2, model.getRowCount());
    4351        assertEquals(4, model.getApplyColumn());
    4452        assertTrue(model.getApply(0));
     
    5260        assertNull(model.getColumnName(5));
    5361        assertFalse(model.isCellEditable(0, 0));
     62        assertFalse(model.isCellEditable(1, 0));
    5463        assertTrue(model.isCellEditable(0, 4));
     64        assertTrue(model.isCellEditable(1, 4));
    5565        assertEquals("foo", model.getValueAt(0, 0));
    5666        assertEquals("bar", model.getValueAt(0, 1));
     
    5969        assertEquals(Boolean.TRUE, model.getValueAt(0, 4));
    6070        assertNull(model.getValueAt(0, 5));
     71        assertEquals("bar", model.getValueAt(1, 0));
     72        assertEquals("foo", model.getValueAt(1, 1));
     73        assertEquals("baz", model.getValueAt(1, 2));
     74        assertEquals("foo", model.getValueAt(1, 3));
     75        assertEquals(Boolean.TRUE, model.getValueAt(1, 4));
     76        assertNull(model.getValueAt(1, 5));
     77        model.setValueAt("", 0, 0);
     78        assertEquals("foo", model.getValueAt(0, 0));
     79        model.setValueAt("", 0, 4);
     80        assertEquals(Boolean.TRUE, model.getValueAt(0, 4));
     81        model.setValueAt(Boolean.FALSE, 0, 4);
     82        assertEquals(Boolean.FALSE, model.getValueAt(0, 4));
     83        TagCorrection[] array = new TagCorrection[15];
     84        Arrays.fill(array, tc1);
     85        t = new TagCorrectionTable(Arrays.asList(array));
     86        assertEquals(array.length, t.getCorrectionTableModel().getCorrections().size());
    6187    }
    6288}
  • trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    r10108 r10133  
    187187        }
    188188    }
     189
     190    /**
     191     * Unit test to reach 100% code coverage.
     192     */
     193    @Test
     194    public void testCoverage() {
     195        assertNotNull(new DateUtils());
     196    }
    189197}
Note: See TracChangeset for help on using the changeset viewer.