File path: /jfreechart-1.0.10/tests/org/jfree/data/category/junit/DefaultCategoryDatasetTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjects2DTests.java | |||
Method name: void testRemoveColumn()
|
Method name: void testRemoveRowByIndex()
|
|||
Number of AST nodes: 14 | Number of AST nodes: 14 | |||
1 | DefaultCategoryDataset d = new DefaultCategoryDataset();↵ | |||
2 | d.addValue(1.0↵ | 1 | KeyedObjects2D data = new KeyedObjects2D();↵ | |
3 | , "R1", "C1");↵ | 2 | data.setObject("Obj1", "R1", "C1");↵ | |
4 | d.addValue(2.0, "R2", "C2");↵ | 3 | data.setObject("Obj2", "R2", "C2");↵ | |
4 | data.removeRow(0);↵ | |||
5 | assertEquals(2, d.getColumnCount());↵ | 5 | assertEquals(1, data.getRowCount());↵ | |
6 | d.removeColumn("C2");↵ | 6 | ↵ | |
7 | assertEquals(1, d.getColumnCount());↵ | |||
7 | assertEquals("Obj2", data.getObject(0, 1));↵ | |||
8 | ↵ | |||
9 | // try negative row index↵ | |||
8 | boolean pass = false;↵ | 10 | boolean pass = false;↵ | |
9 | try {↵ | 11 | try {↵ | |
10 | d.removeColumn("XXX");↵ | 12 | data.removeRow(-1);↵ | |
11 | }↵ | 13 | }↵ | |
12 | catch (UnknownKeyException e) {↵ | 14 | catch (IndexOutOfBoundsException e) {↵ | |
13 | pass = true;↵ | 15 | pass = true;↵ | |
14 | }↵ | 16 | }↵ | |
15 | assertTrue(pass);↵ | 17 | assertTrue(pass);↵ | |
18 | ↵ | |||
19 | // try row index too high↵ | |||
16 | pass = false;↵ | 20 | pass = false;↵ | |
17 | try {↵ | 21 | try {↵ | |
18 | d.removeColumn(null);↵ | 22 | data.removeRow(data.getRowCount());↵ | |
19 | }↵ | 23 | }↵ | |
20 | catch (IllegalArgumentException e) {↵ | 24 | catch (IndexOutOfBoundsException e) {↵ | |
21 | pass = true;↵ | 25 | pass = true;↵ | |
22 | }↵ | 26 | }↵ | |
23 | assertTrue(pass); | 27 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.7 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 81 |
Number of mapped statements | 6 |
Number of unmapped statements in the first code fragment | 8 |
Number of unmapped statements in the second code fragment | 8 |
Time elapsed for statement mapping (ms) | 19.5 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 1 | KeyedObjects2D data = new KeyedObjects2D(); | ||||||||||||||
1 | DefaultCategoryDataset d = new DefaultCategoryDataset(); |
| | ||||||||||||||
|
| 2 | data.setObject("Obj1", "R1", "C1"); | ||||||||||||||
2 | d.addValue(1.0, "R1", "C1"); |
| | ||||||||||||||
|
| 3 | data.setObject("Obj2", "R2", "C2"); | ||||||||||||||
3 | d.addValue(2.0, "R2", "C2"); |
| | ||||||||||||||
|
| 4 | data.removeRow(0); | ||||||||||||||
4 | assertEquals(2, d.getColumnCount()); | | |||||||||||||||
| 5 | assertEquals(1, data.getRowCount()); | |||||||||||||||
5 | d.removeColumn("C2"); |
| | ||||||||||||||
| 6 | assertEquals("Obj2", data.getObject(0, 1)); | |||||||||||||||
6 | assertEquals(1, d.getColumnCount()); | | |||||||||||||||
7 | boolean pass = false; | 7 | boolean pass = false; | ||||||||||||||
8 | try |
| 8 | try | |||||||||||||
|
| 9 | data.removeRow(-1); | ||||||||||||||
9 | d.removeColumn("XXX"); |
| | ||||||||||||||
10 | assertTrue(pass); | 10 | assertTrue(pass); | ||||||||||||||
11 | pass = false; | 11 | pass = false; | ||||||||||||||
12 | try |
| 12 | try | |||||||||||||
|
| 13 | data.removeRow(data.getRowCount()); | ||||||||||||||
13 | d.removeColumn(null); |
| | ||||||||||||||
14 | assertTrue(pass); | 14 | assertTrue(pass); |
Row | Violation |
---|---|
1 | Unmatched statement KeyedObjects2D data=new KeyedObjects2D(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement DefaultCategoryDataset d=new DefaultCategoryDataset(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement data.setObject("Obj1","R1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
4 | Unmatched statement d.addValue(1.0,"R1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
5 | Unmatched statement data.setObject("Obj2","R2","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
6 | Unmatched statement d.addValue(2.0,"R2","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
7 | Unmatched statement data.removeRow(0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
8 | Unmatched statement d.removeColumn("C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
9 | Unmatched statement data.removeRow(-1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
10 | Unmatched statement data.removeRow(-1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
11 | Unmatched statement d.removeColumn("XXX"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
12 | Unmatched statement d.removeColumn("XXX"); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
13 | Unmatched statement data.removeRow(data.getRowCount()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
14 | Unmatched statement data.removeRow(data.getRowCount()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
15 | Unmatched statement d.removeColumn(null); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
16 | Unmatched statement d.removeColumn(null); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |