KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeRow(0); assertEquals(1, data.getRowCount()); assertEquals("Obj2", data.getObject(0, 1)); // try negative row index boolean pass = false; try { data.removeRow(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // try row index too high pass = false; try { data.removeRow(data.getRowCount()); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass);
KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeColumn(0); assertEquals(1, data.getColumnCount()); assertEquals("Obj2", data.getObject(1, 0)); // try negative column index boolean pass = false; try { data.removeColumn(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // try column index too high pass = false; try { data.removeColumn(data.getColumnCount()); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjects2DTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjects2DTests.java
Method name: void testRemoveRowByIndex() Method name: void testRemoveColumnByIndex()
Number of AST nodes: 14 Number of AST nodes: 14
1
KeyedObjects2D data = new KeyedObjects2D();
1
KeyedObjects2D data = new KeyedObjects2D();
2
        data.setObject("Obj1", "R1", "C1");
2
        data.setObject("Obj1", "R1", "C1");
3
        data.setObject("Obj2", "R2", "C2");
3
        data.setObject("Obj2", "R2", "C2");
4
        data.removeRow(0);
4
        data.removeColumn(0);
5
        assertEquals(1, data.getRowCount());
5
        assertEquals(1, data.getColumnCount());
6
        assertEquals("Obj2", data.getObject(0, 1));
6
        assertEquals("Obj2", data.getObject(1, 0));
7
        
7
        
8
        // try negative row index
8
        // try negative column index
9
        boolean pass = false;
9
        boolean pass = false;
10
        try {
10
        try {
11
            data.removeRow(-1);
11
            data.removeColumn(-1);
12
        }
12
        }
13
        catch (IndexOutOfBoundsException e) {
13
        catch (IndexOutOfBoundsException e) {
14
            pass = true;
14
            pass = true;
15
        }
15
        }
16
        assertTrue(pass);
16
        assertTrue(pass);
17
        
17
        
18
        // try row index too high
18
        // try column index too high
19
        pass = false;
19
        pass = false;
20
        try {
20
        try {
21
            data.removeRow(data.getRowCount());
21
            data.removeColumn(data.getColumnCount());
22
        }
22
        }
23
        catch (IndexOutOfBoundsException e) {
23
        catch (IndexOutOfBoundsException e) {
24
            pass = true;
24
            pass = true;
25
        }
25
        }
26
        assertTrue(pass);
26
        assertTrue(pass);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons49
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)109.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    KeyedObjects2D data = new KeyedObjects2D();
    1
    KeyedObjects2D data = new KeyedObjects2D();
    2
    data.setObject("Obj1", "R1", "C1");
    2
    data.setObject("Obj1", "R1", "C1");
    3
    data.setObject("Obj2", "R2", "C2");
    3
    data.setObject("Obj2", "R2", "C2");
    4
    data.removeRow(0);
    4
    data.removeRow(0);
    4
    data.removeColumn(0);
    Differences
    Expression1Expression2Difference
    removeRowremoveColumnMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression data.removeRow(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.removeColumn(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.removeRow(0) is a void method call, and thus it cannot be parameterized
    Expression data.removeColumn(0) is a void method call, and thus it cannot be parameterized
    4
    data.removeColumn(0);
    5
    assertEquals(1, data.getRowCount());
    5
    assertEquals(1, data.getRowCount());
    5
    assertEquals(1, data.getColumnCount());
    Differences
    Expression1Expression2Difference
    getRowCountgetColumnCountMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression data.getRowCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.getColumnCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    assertEquals(1, data.getColumnCount());
    6
    assertEquals("Obj2", data.getObject(0, 1));
    6
    assertEquals("Obj2", data.getObject(0, 1));
    6
    assertEquals("Obj2", data.getObject(1, 0));
    Differences
    Expression1Expression2Difference
    01LITERAL_VALUE_MISMATCH
    10LITERAL_VALUE_MISMATCH
    6
    assertEquals("Obj2", data.getObject(1, 0));
    7
    boolean pass = false;
    7
    boolean pass = false;
    8
    try
    8
    try
    9
    data.removeRow(-1);
    9
    data.removeRow(-1);
    9
    data.removeColumn(-1);
    Differences
    Expression1Expression2Difference
    removeRowremoveColumnMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression data.removeRow(-1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.removeColumn(-1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.removeRow(-1) is a void method call, and thus it cannot be parameterized
    Expression data.removeColumn(-1) is a void method call, and thus it cannot be parameterized
    9
    data.removeColumn(-1);
    10
    assertTrue(pass);
    10
    assertTrue(pass);
    11
    pass = false;
    11
    pass = false;
    12
    try
    12
    try
    13
    data.removeRow(data.getRowCount());
    13
    data.removeRow(data.getRowCount());
    13
    data.removeColumn(data.getColumnCount());
    Differences
    Expression1Expression2Difference
    getRowCountgetColumnCountMETHOD_INVOCATION_NAME_MISMATCH
    removeRowremoveColumnMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression data.getRowCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.getColumnCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.removeRow(data.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.removeColumn(data.getColumnCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression data.removeRow(data.getRowCount()) is a void method call, and thus it cannot be parameterized
    Expression data.removeColumn(data.getColumnCount()) is a void method call, and thus it cannot be parameterized
    13
    data.removeColumn(data.getColumnCount());
    14
    assertTrue(pass);
    14
    assertTrue(pass);
    Precondition Violations (16)
    Row Violation
    1Expression data.removeRow(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression data.removeColumn(0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression data.removeRow(0) is a void method call, and thus it cannot be parameterized
    4Expression data.removeColumn(0) is a void method call, and thus it cannot be parameterized
    5Expression data.getRowCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression data.getColumnCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression data.removeRow(-1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression data.removeColumn(-1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression data.removeRow(-1) is a void method call, and thus it cannot be parameterized
    10Expression data.removeColumn(-1) is a void method call, and thus it cannot be parameterized
    11Expression data.getRowCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression data.getColumnCount() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression data.removeRow(data.getRowCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression data.removeColumn(data.getColumnCount()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression data.removeRow(data.getRowCount()) is a void method call, and thus it cannot be parameterized
    16Expression data.removeColumn(data.getColumnCount()) is a void method call, and thus it cannot be parameterized