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 testRemoveRowByKey()
|
|||
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.removeRow("R2");↵ | |
5 | assertEquals(1, data.getRowCount());↵ | 5 | assertEquals(1, data.getRowCount());↵ | |
6 | assertEquals("Obj2", data.getObject(0, 1));↵ | 6 | assertEquals("Obj1", data.getObject(0, 0));↵ | |
7 | ↵ | 7 | ↵ | |
8 | // try negative row index↵ | 8 | // try unknown row key↵ | |
9 | boolean pass = false;↵ | 9 | boolean pass = false;↵ | |
10 | try {↵ | 10 | try {↵ | |
11 | data.removeRow(-1);↵ | 11 | data.removeRow("XXX");↵ | |
12 | }↵ | 12 | }↵ | |
13 | catch (IndexOutOfBoundsException e) {↵ | 13 | catch (UnknownKeyException 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 null row key↵ | |
19 | pass = false;↵ | 19 | pass = false;↵ | |
20 | try {↵ | 20 | try {↵ | |
21 | data.removeRow(data.getRowCount());↵ | 21 | data.removeRow(null);↵ | |
22 | }↵ | 22 | }↵ | |
23 | catch (IndexOutOfBoundsException e) {↵ | 23 | catch (IllegalArgumentException e) {↵ | |
24 | pass = true;↵ | 24 | pass = true;↵ | |
25 | }↵ | 25 | }↵ | |
26 | assertTrue(pass); | 26 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.7 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 57 |
Number of mapped statements | 11 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 118.0 |
Clone type | Type 2 |
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("R2"); | ||||||||||||||
4 | data.removeRow(0); |
| | ||||||||||||||
5 | assertEquals(1, data.getRowCount()); | 5 | assertEquals(1, data.getRowCount()); | ||||||||||||||
6 | assertEquals("Obj2", data.getObject(0, 1)); |
| 6 | assertEquals("Obj1", data.getObject(0, 0)); | |||||||||||||
7 | boolean pass = false; | 7 | boolean pass = false; | ||||||||||||||
8 | try |
| 8 | try | |||||||||||||
|
| 9 | data.removeRow("XXX"); | ||||||||||||||
9 | data.removeRow(-1); |
| | ||||||||||||||
10 | assertTrue(pass); | 10 | assertTrue(pass); | ||||||||||||||
11 | pass = false; | 11 | pass = false; | ||||||||||||||
12 | try |
| 12 | try | |||||||||||||
|
| 13 | data.removeRow(null); | ||||||||||||||
13 | data.removeRow(data.getRowCount()); |
| | ||||||||||||||
14 | assertTrue(pass); | 14 | assertTrue(pass); |
Row | Violation |
---|---|
1 | Unmatched statement data.removeRow("R2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement data.removeRow(0); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement data.removeRow("XXX"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement data.removeRow("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 |
5 | Unmatched statement data.removeRow(-1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | 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 |
7 | Unmatched statement data.removeRow(null); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Unmatched statement data.removeRow(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 |
9 | Unmatched statement data.removeRow(data.getRowCount()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
10 | 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 |