Changeset 10299 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2016-05-29T16:33:08+02:00 (8 years ago)
Author:
Don-vip
Message:

sonar - Performance - Method passes constant String of length 1 to character overridden method + add unit tests/javadoc

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

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/ExtensionFileFilterTest.java

    r9669 r10299  
    22package org.openstreetmap.josm.actions;
    33
    4 import nl.jqno.equalsverifier.EqualsVerifier;
     4import static org.junit.Assert.assertEquals;
    55
    66import org.junit.Test;
     7
     8import nl.jqno.equalsverifier.EqualsVerifier;
    79
    810/**
     
    1012 */
    1113public class ExtensionFileFilterTest {
     14
     15    private static void test(String extensions, String defaultExtension, String description, boolean addArchiveExtensionsToDescription,
     16            String expectedExtensions, String expectedDescription) {
     17        ExtensionFileFilter ext = ExtensionFileFilter.newFilterWithArchiveExtensions(
     18                extensions, defaultExtension, description, addArchiveExtensionsToDescription);
     19        assertEquals(expectedExtensions, ext.getExtensions());
     20        assertEquals(defaultExtension, ext.getDefaultExtension());
     21        assertEquals(expectedDescription, ext.getDescription());
     22    }
     23
     24    /**
     25     * Unit test of method {@link ExtensionFileFilter#newFilterWithArchiveExtensions}.
     26     */
     27    @Test
     28    public void testNewFilterWithArchiveExtensions() {
     29        test("ext1", "ext1", "description", true,
     30                "ext1,ext1.gz,ext1.bz2", "description (*.ext1, *.ext1.gz, *.ext1.bz2)");
     31        test("ext1", "ext1", "description", false,
     32                "ext1,ext1.gz,ext1.bz2", "description (*.ext1)");
     33        test("ext1,ext2", "ext1", "description", true,
     34                "ext1,ext1.gz,ext1.bz2,ext2,ext2.gz,ext2.bz2", "description (*.ext1, *.ext1.gz, *.ext1.bz2, *.ext2, *.ext2.gz, *.ext2.bz2)");
     35        test("ext1,ext2", "ext1", "description", false,
     36                "ext1,ext1.gz,ext1.bz2,ext2,ext2.gz,ext2.bz2", "description (*.ext1, *.ext2)");
     37    }
    1238
    1339    /**
  • trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java

    r9940 r10299  
    427427        final SearchCompiler.Match c4 = SearchCompiler.compile("foo1 OR (bar1 bar2 baz1 XOR baz2) OR foo2");
    428428        assertEquals("foo1 || (bar1 && bar2 && (baz1 ^ baz2)) || foo2", c4.toString());
     429        final SearchCompiler.Match c5 = SearchCompiler.compile("foo1 XOR (baz1 XOR (bar baz))");
     430        assertEquals("foo1 ^ baz1 ^ (bar && baz)", c5.toString());
     431        final SearchCompiler.Match c6 = SearchCompiler.compile("foo1 XOR ((baz1 baz2) XOR (bar OR baz))");
     432        assertEquals("foo1 ^ (baz1 && baz2) ^ (bar || baz)", c6.toString());
    429433    }
    430434
Note: See TracChangeset for help on using the changeset viewer.