DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0), EPSILON); assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON);
DefaultKeyedValues2D table = new DefaultKeyedValues2D(); table.addValue(new Double(1.0), "R0", "C0"); table.addValue(new Double(2.0), "R0", "C1"); table.addValue(new Double(3.0), "R1", "C0"); table.addValue(new Double(4.0), "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0), EPSILON); assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1), EPSILON); table.setValue(null, "R1", "C1"); assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1), EPSILON);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DataUtilitiesTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DataUtilitiesTests.java
Method name: void testCalculateColumnTotal() Method name: void testCalculateRowTotal()
Number of AST nodes: 9 Number of AST nodes: 9
1
DefaultKeyedValues2D table = new DefaultKeyedValues2D();
1
DefaultKeyedValues2D table = new DefaultKeyedValues2D();
2
        table.addValue(new Double(1.0), "R0", "C0");
2
        table.addValue(new Double(1.0), "R0", "C0");
3
        table.addValue(new Double(2.0), "R0", "C1");
3
        table.addValue(new Double(2.0), "R0", "C1");
4
        table.addValue(new Double(3.0), "R1", "C0");
4
        table.addValue(new Double(3.0), "R1", "C0");
5
        table.addValue(new Double(4.0), "R1", "C1");
5
        table.addValue(new Double(4.0), "R1", "C1");
6
        assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0), EPSILON);
6
        assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0), EPSILON);
7
        assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON);
7
        assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1), EPSILON);
8
        table.setValue(null, "R1", "C1");
8
        table.setValue(null, "R1", "C1");
9
        assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON);
9
        assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1), EPSILON);
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.0
Clones locationClones are declared in the same class
Number of node comparisons45
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultKeyedValues2D table = new DefaultKeyedValues2D();
    1
    DefaultKeyedValues2D table = new DefaultKeyedValues2D();
    2
    table.addValue(new Double(1.0), "R0", "C0");
    2
    table.addValue(new Double(1.0), "R0", "C0");
    3
    table.addValue(new Double(2.0), "R0", "C1");
    3
    table.addValue(new Double(2.0), "R0", "C1");
    4
    table.addValue(new Double(3.0), "R1", "C0");
    4
    table.addValue(new Double(3.0), "R1", "C0");
    5
    table.addValue(new Double(4.0), "R1", "C1");
    5
    table.addValue(new Double(4.0), "R1", "C1");
    6
    assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0), EPSILON);
    6
    assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0), EPSILON);
    6
    assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0), EPSILON);
    Differences
    Expression1Expression2Difference
    4.03.0LITERAL_VALUE_MISMATCH
    calculateColumnTotalcalculateRowTotalMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression DataUtilities.calculateColumnTotal(table,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression DataUtilities.calculateRowTotal(table,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0), EPSILON);
    7
    assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON);
    7
    assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON);
    7
    assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1), EPSILON);
    Differences
    Expression1Expression2Difference
    6.07.0LITERAL_VALUE_MISMATCH
    calculateColumnTotalcalculateRowTotalMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression DataUtilities.calculateColumnTotal(table,1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression DataUtilities.calculateRowTotal(table,1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1), EPSILON);
    8
    table.setValue(null, "R1", "C1");
    8
    table.setValue(null, "R1", "C1");
    9
    assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON);
    9
    assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON);
    9
    assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1), EPSILON);
    Differences
    Expression1Expression2Difference
    2.03.0LITERAL_VALUE_MISMATCH
    calculateColumnTotalcalculateRowTotalMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression DataUtilities.calculateColumnTotal(table,1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression DataUtilities.calculateRowTotal(table,1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1), EPSILON);
    Precondition Violations (6)
    Row Violation
    1Expression DataUtilities.calculateColumnTotal(table,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression DataUtilities.calculateRowTotal(table,0) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression DataUtilities.calculateColumnTotal(table,1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression DataUtilities.calculateRowTotal(table,1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression DataUtilities.calculateColumnTotal(table,1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression DataUtilities.calculateRowTotal(table,1) cannot be parameterized, because it has dependencies to/from statements that will be extracted