aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2011-01-16 18:54:23 +0000
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2011-01-16 18:54:23 +0000
commit2581e65594849fca406fa1d169505a59e4012394 (patch)
tree358f41f4dec5aa1e50e395e2fab50ac81175a5f8
parentd37ff3d49e64d6c2d1088840e794c482593d484d (diff)
downloadjacoco-2581e65594849fca406fa1d169505a59e4012394.tar.gz
Code cleanup: move getStatus() to ICounter.
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/analysis/CounterImplTest.java24
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/analysis/LineImplTest.java16
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/BlocksBeforeSuperConstructorTest.java5
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/BooleanExpressionsTest.java58
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/ClassInitializerTest.java22
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/ControlStructuresTest.java117
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/ExceptionsTest.java71
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/FieldInitializationInTwoConstructorsTest.java13
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitDefaultConstructorTest.java5
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitFieldInitializationTest.java14
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/InterfaceClassInitializerTest.java12
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/PrivateEmptyDefaultConstructorTest.java8
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java19
-rw-r--r--org.jacoco.core/src/org/jacoco/core/analysis/ICounter.java34
-rw-r--r--org.jacoco.core/src/org/jacoco/core/analysis/ILine.java47
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java8
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java12
-rw-r--r--org.jacoco.examples/src/org/jacoco/examples/CoreTutorial.java7
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/html/SourceHighlighter.java44
-rw-r--r--org.jacoco.report/src/org/jacoco/report/internal/xml/XMLReportNodeHandler.java2
20 files changed, 278 insertions, 260 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/CounterImplTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/CounterImplTest.java
index afc952b0..bb26bc7b 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/CounterImplTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/CounterImplTest.java
@@ -117,6 +117,30 @@ public class CounterImplTest {
}
@Test
+ public void testGetMissedStatus1() {
+ ICounter c = CounterImpl.getInstance(0, 0);
+ assertEquals(ICounter.EMPTY, c.getStatus());
+ }
+
+ @Test
+ public void testGetMissedStatus2() {
+ ICounter c = CounterImpl.getInstance(5, 0);
+ assertEquals(ICounter.NOT_COVERED, c.getStatus());
+ }
+
+ @Test
+ public void testGetMissedStatus3() {
+ ICounter c = CounterImpl.getInstance(0, 5);
+ assertEquals(ICounter.FULLY_COVERED, c.getStatus());
+ }
+
+ @Test
+ public void testGetMissedStatus4() {
+ ICounter c = CounterImpl.getInstance(2, 3);
+ assertEquals(ICounter.PARTLY_COVERED, c.getStatus());
+ }
+
+ @Test
public void testEquals1() {
ICounter c1 = CounterImpl.getInstance(300, 123);
ICounter c2 = CounterImpl.getInstance(300, 123);
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/LineImplTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/LineImplTest.java
index 9fc3bb55..b5d12706 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/LineImplTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/LineImplTest.java
@@ -14,7 +14,7 @@ package org.jacoco.core.internal.analysis;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import org.jacoco.core.analysis.ILine;
+import org.jacoco.core.analysis.ICounter;
import org.junit.Before;
import org.junit.Test;
@@ -34,7 +34,7 @@ public class LineImplTest {
public void testEMPTY() {
assertEquals(CounterImpl.COUNTER_0_0, line.getInstructionCounter());
assertEquals(CounterImpl.COUNTER_0_0, line.getBranchCounter());
- assertEquals(ILine.NO_CODE, line.getStatus());
+ assertEquals(ICounter.EMPTY, line.getStatus());
}
@Test
@@ -89,42 +89,42 @@ public class LineImplTest {
public void testGetStatus1() {
line = line.increment(CounterImpl.getInstance(1, 0),
CounterImpl.getInstance(0, 0));
- assertEquals(ILine.NOT_COVERED, line.getStatus());
+ assertEquals(ICounter.NOT_COVERED, line.getStatus());
}
@Test
public void testGetStatus2() {
line = line.increment(CounterImpl.getInstance(0, 0),
CounterImpl.getInstance(1, 0));
- assertEquals(ILine.NOT_COVERED, line.getStatus());
+ assertEquals(ICounter.NOT_COVERED, line.getStatus());
}
@Test
public void testGetStatus3() {
line = line.increment(CounterImpl.getInstance(0, 1),
CounterImpl.getInstance(0, 0));
- assertEquals(ILine.FULLY_COVERED, line.getStatus());
+ assertEquals(ICounter.FULLY_COVERED, line.getStatus());
}
@Test
public void testGetStatus4() {
line = line.increment(CounterImpl.getInstance(0, 0),
CounterImpl.getInstance(0, 1));
- assertEquals(ILine.FULLY_COVERED, line.getStatus());
+ assertEquals(ICounter.FULLY_COVERED, line.getStatus());
}
@Test
public void testGetStatus5() {
line = line.increment(CounterImpl.getInstance(1, 1),
CounterImpl.getInstance(0, 0));
- assertEquals(ILine.PARTLY_COVERED, line.getStatus());
+ assertEquals(ICounter.PARTLY_COVERED, line.getStatus());
}
@Test
public void testGetStatus6() {
line = line.increment(CounterImpl.getInstance(0, 1),
CounterImpl.getInstance(1, 1));
- assertEquals(ILine.PARTLY_COVERED, line.getStatus());
+ assertEquals(ICounter.PARTLY_COVERED, line.getStatus());
}
@Test
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/BlocksBeforeSuperConstructorTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/BlocksBeforeSuperConstructorTest.java
index 0c1f0288..b42784c9 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/BlocksBeforeSuperConstructorTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/BlocksBeforeSuperConstructorTest.java
@@ -11,8 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.PARTLY_COVERED;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target10;
import org.junit.Test;
@@ -33,7 +32,7 @@ public class BlocksBeforeSuperConstructorTest extends ValidationTestBase {
@Test
public void testCoverageResult() {
- assertLine("super", PARTLY_COVERED, 1, 1);
+ assertLine("super", ICounter.PARTLY_COVERED, 1, 1);
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/BooleanExpressionsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/BooleanExpressionsTest.java
index d1754b92..7cee4b1a 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/BooleanExpressionsTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/BooleanExpressionsTest.java
@@ -11,9 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.FULLY_COVERED;
-import static org.jacoco.core.analysis.ILine.PARTLY_COVERED;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target02;
import org.junit.Test;
@@ -36,51 +34,51 @@ public class BooleanExpressionsTest extends ValidationTestBase {
public void testCoverageResult() {
// 1. Boolean comparison result (one case)
- assertLine("booleancmp1", PARTLY_COVERED, 1, 1);
+ assertLine("booleancmp1", ICounter.PARTLY_COVERED, 1, 1);
// 2. Boolean comparison result (both cases)
- assertLine("booleancmp2", FULLY_COVERED, 0, 2);
+ assertLine("booleancmp2", ICounter.FULLY_COVERED, 0, 2);
// 3. And
- assertLine("andFF", FULLY_COVERED, 1, 1);
- assertLine("andFT", FULLY_COVERED, 1, 1);
- assertLine("andTF", FULLY_COVERED, 1, 1);
- assertLine("andTT", FULLY_COVERED, 1, 1);
+ assertLine("andFF", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("andFT", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("andTF", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("andTT", ICounter.FULLY_COVERED, 1, 1);
// 4. Conditional And
- assertLine("conditionalandFF", PARTLY_COVERED, 3, 1);
- assertLine("conditionalandFT", PARTLY_COVERED, 3, 1);
- assertLine("conditionalandTF", FULLY_COVERED, 2, 2);
- assertLine("conditionalandTT", FULLY_COVERED, 2, 2);
+ assertLine("conditionalandFF", ICounter.PARTLY_COVERED, 3, 1);
+ assertLine("conditionalandFT", ICounter.PARTLY_COVERED, 3, 1);
+ assertLine("conditionalandTF", ICounter.FULLY_COVERED, 2, 2);
+ assertLine("conditionalandTT", ICounter.FULLY_COVERED, 2, 2);
// 5. Or
- assertLine("orFF", FULLY_COVERED, 1, 1);
- assertLine("orFT", FULLY_COVERED, 1, 1);
- assertLine("orTF", FULLY_COVERED, 1, 1);
- assertLine("orTT", FULLY_COVERED, 1, 1);
+ assertLine("orFF", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("orFT", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("orTF", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("orTT", ICounter.FULLY_COVERED, 1, 1);
// 6. Conditional Or
- assertLine("conditionalorFF", FULLY_COVERED, 2, 2);
- assertLine("conditionalorFT", FULLY_COVERED, 2, 2);
- assertLine("conditionalorTF", PARTLY_COVERED, 3, 1);
- assertLine("conditionalorTT", PARTLY_COVERED, 3, 1);
+ assertLine("conditionalorFF", ICounter.FULLY_COVERED, 2, 2);
+ assertLine("conditionalorFT", ICounter.FULLY_COVERED, 2, 2);
+ assertLine("conditionalorTF", ICounter.PARTLY_COVERED, 3, 1);
+ assertLine("conditionalorTT", ICounter.PARTLY_COVERED, 3, 1);
// 7. Exclusive Or
- assertLine("xorFF", FULLY_COVERED, 1, 1);
- assertLine("xorFT", FULLY_COVERED, 1, 1);
- assertLine("xorTF", FULLY_COVERED, 1, 1);
- assertLine("xorTT", FULLY_COVERED, 1, 1);
+ assertLine("xorFF", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("xorFT", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("xorTF", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("xorTT", ICounter.FULLY_COVERED, 1, 1);
// 8. Conditional Operator
- assertLine("condT", PARTLY_COVERED, 1, 1);
- assertLine("condF", PARTLY_COVERED, 1, 1);
+ assertLine("condT", ICounter.PARTLY_COVERED, 1, 1);
+ assertLine("condF", ICounter.PARTLY_COVERED, 1, 1);
// 9. Not (one case)
- assertLine("notT", PARTLY_COVERED, 1, 1);
- assertLine("notF", PARTLY_COVERED, 1, 1);
+ assertLine("notT", ICounter.PARTLY_COVERED, 1, 1);
+ assertLine("notF", ICounter.PARTLY_COVERED, 1, 1);
// 10. Not (both cases)
- assertLine("notTF", FULLY_COVERED);
+ assertLine("notTF", ICounter.FULLY_COVERED);
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ClassInitializerTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ClassInitializerTest.java
index b164856d..92a728b5 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ClassInitializerTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ClassInitializerTest.java
@@ -11,9 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.FULLY_COVERED;
-import static org.jacoco.core.analysis.ILine.NO_CODE;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target05;
import org.junit.Test;
@@ -35,18 +33,18 @@ public class ClassInitializerTest extends ValidationTestBase {
@Test
public void testCoverageResult() {
- assertLine("const1", NO_CODE);
- assertLine("const2", NO_CODE);
+ assertLine("const1", ICounter.EMPTY);
+ assertLine("const2", ICounter.EMPTY);
- assertLine("const3", FULLY_COVERED);
- assertLine("const4", FULLY_COVERED);
+ assertLine("const3", ICounter.FULLY_COVERED);
+ assertLine("const4", ICounter.FULLY_COVERED);
- assertLine("field1", FULLY_COVERED);
- assertLine("field2", FULLY_COVERED);
- assertLine("field3", FULLY_COVERED);
- assertLine("field4", FULLY_COVERED);
+ assertLine("field1", ICounter.FULLY_COVERED);
+ assertLine("field2", ICounter.FULLY_COVERED);
+ assertLine("field3", ICounter.FULLY_COVERED);
+ assertLine("field4", ICounter.FULLY_COVERED);
- assertLine("staticblock", FULLY_COVERED);
+ assertLine("staticblock", ICounter.FULLY_COVERED);
}
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ControlStructuresTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ControlStructuresTest.java
index 4106be36..5975a1a0 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ControlStructuresTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ControlStructuresTest.java
@@ -11,10 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.FULLY_COVERED;
-import static org.jacoco.core.analysis.ILine.NOT_COVERED;
-import static org.jacoco.core.analysis.ILine.PARTLY_COVERED;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target01;
import org.junit.Test;
@@ -37,100 +34,100 @@ public class ControlStructuresTest extends ValidationTestBase {
public void testCoverageResult() {
// 1. Direct unconditional execution
- assertLine("unconditional", FULLY_COVERED);
+ assertLine("unconditional", ICounter.FULLY_COVERED);
// 2. Missed if block
- assertLine("iffalse", FULLY_COVERED, 1, 1);
- assertLine("missedif", NOT_COVERED);
- assertLine("executedelse", FULLY_COVERED);
+ assertLine("iffalse", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("missedif", ICounter.NOT_COVERED);
+ assertLine("executedelse", ICounter.FULLY_COVERED);
// 3. Executed if block
- assertLine("iftrue", FULLY_COVERED, 1, 1);
- assertLine("executedif", FULLY_COVERED);
- assertLine("missedelse", NOT_COVERED);
+ assertLine("iftrue", ICounter.FULLY_COVERED, 1, 1);
+ assertLine("executedif", ICounter.FULLY_COVERED);
+ assertLine("missedelse", ICounter.NOT_COVERED);
// 4. Missed while block
- assertLine("missedwhile", NOT_COVERED);
+ assertLine("missedwhile", ICounter.NOT_COVERED);
// 5. Executed while block
- assertLine("whiletruefalse", FULLY_COVERED, 0, 2);
- assertLine("executedwhile", FULLY_COVERED);
+ assertLine("whiletruefalse", ICounter.FULLY_COVERED, 0, 2);
+ assertLine("executedwhile", ICounter.FULLY_COVERED);
// 6. Executed do while block
- assertLine("executeddowhile", FULLY_COVERED);
+ assertLine("executeddowhile", ICounter.FULLY_COVERED);
// 7. Missed for block
- assertLine("missedforincrementer", PARTLY_COVERED, 1, 1);
- assertLine("missedfor", NOT_COVERED);
+ assertLine("missedforincrementer", ICounter.PARTLY_COVERED, 1, 1);
+ assertLine("missedfor", ICounter.NOT_COVERED);
// 8. Executed for block
- assertLine("executedforincrementer", FULLY_COVERED, 0, 2);
- assertLine("executedfor", FULLY_COVERED);
+ assertLine("executedforincrementer", ICounter.FULLY_COVERED, 0, 2);
+ assertLine("executedfor", ICounter.FULLY_COVERED);
// 9. Missed for each block
- assertLine("missedforeachincrementer", PARTLY_COVERED, 1, 1);
- assertLine("missedforeach", NOT_COVERED);
+ assertLine("missedforeachincrementer", ICounter.PARTLY_COVERED, 1, 1);
+ assertLine("missedforeach", ICounter.NOT_COVERED);
// 10. Executed for each block
- assertLine("executedforeachincrementer", FULLY_COVERED, 0, 2);
- assertLine("executedforeach", FULLY_COVERED);
+ assertLine("executedforeachincrementer", ICounter.FULLY_COVERED, 0, 2);
+ assertLine("executedforeach", ICounter.FULLY_COVERED);
// 11. Table switch with hit
- assertLine("tswitch1", FULLY_COVERED, 3, 1);
- assertLine("tswitch1case1", NOT_COVERED);
- assertLine("tswitch1case2", FULLY_COVERED);
- assertLine("tswitch1case3", NOT_COVERED);
- assertLine("tswitch1default", NOT_COVERED);
+ assertLine("tswitch1", ICounter.FULLY_COVERED, 3, 1);
+ assertLine("tswitch1case1", ICounter.NOT_COVERED);
+ assertLine("tswitch1case2", ICounter.FULLY_COVERED);
+ assertLine("tswitch1case3", ICounter.NOT_COVERED);
+ assertLine("tswitch1default", ICounter.NOT_COVERED);
// 12. Continued table switch with hit
- assertLine("tswitch2", FULLY_COVERED, 3, 1);
- assertLine("tswitch2case1", NOT_COVERED);
- assertLine("tswitch2case2", FULLY_COVERED);
- assertLine("tswitch2case3", FULLY_COVERED);
- assertLine("tswitch2default", FULLY_COVERED);
+ assertLine("tswitch2", ICounter.FULLY_COVERED, 3, 1);
+ assertLine("tswitch2case1", ICounter.NOT_COVERED);
+ assertLine("tswitch2case2", ICounter.FULLY_COVERED);
+ assertLine("tswitch2case3", ICounter.FULLY_COVERED);
+ assertLine("tswitch2default", ICounter.FULLY_COVERED);
// 13. Table switch without hit
- assertLine("tswitch2", FULLY_COVERED, 3, 1);
- assertLine("tswitch3case1", NOT_COVERED);
- assertLine("tswitch3case2", NOT_COVERED);
- assertLine("tswitch3case3", NOT_COVERED);
- assertLine("tswitch3default", FULLY_COVERED);
+ assertLine("tswitch2", ICounter.FULLY_COVERED, 3, 1);
+ assertLine("tswitch3case1", ICounter.NOT_COVERED);
+ assertLine("tswitch3case2", ICounter.NOT_COVERED);
+ assertLine("tswitch3case3", ICounter.NOT_COVERED);
+ assertLine("tswitch3default", ICounter.FULLY_COVERED);
// 14. Lookup switch with hit
- assertLine("lswitch1", FULLY_COVERED, 3, 1);
- assertLine("lswitch1case1", NOT_COVERED);
- assertLine("lswitch1case2", FULLY_COVERED);
- assertLine("lswitch1case3", NOT_COVERED);
- assertLine("lswitch1default", NOT_COVERED);
+ assertLine("lswitch1", ICounter.FULLY_COVERED, 3, 1);
+ assertLine("lswitch1case1", ICounter.NOT_COVERED);
+ assertLine("lswitch1case2", ICounter.FULLY_COVERED);
+ assertLine("lswitch1case3", ICounter.NOT_COVERED);
+ assertLine("lswitch1default", ICounter.NOT_COVERED);
// 15. Continued lookup switch with hit
- assertLine("lswitch2", FULLY_COVERED, 3, 1);
- assertLine("lswitch2case1", NOT_COVERED);
- assertLine("lswitch2case2", FULLY_COVERED);
- assertLine("lswitch2case3", FULLY_COVERED);
- assertLine("lswitch2default", FULLY_COVERED);
+ assertLine("lswitch2", ICounter.FULLY_COVERED, 3, 1);
+ assertLine("lswitch2case1", ICounter.NOT_COVERED);
+ assertLine("lswitch2case2", ICounter.FULLY_COVERED);
+ assertLine("lswitch2case3", ICounter.FULLY_COVERED);
+ assertLine("lswitch2default", ICounter.FULLY_COVERED);
// 16. Lookup switch without hit
- assertLine("lswitch3", FULLY_COVERED, 3, 1);
- assertLine("lswitch3case1", NOT_COVERED);
- assertLine("lswitch3case2", NOT_COVERED);
- assertLine("lswitch3case3", NOT_COVERED);
- assertLine("lswitch3default", FULLY_COVERED);
+ assertLine("lswitch3", ICounter.FULLY_COVERED, 3, 1);
+ assertLine("lswitch3case1", ICounter.NOT_COVERED);
+ assertLine("lswitch3case2", ICounter.NOT_COVERED);
+ assertLine("lswitch3case3", ICounter.NOT_COVERED);
+ assertLine("lswitch3default", ICounter.FULLY_COVERED);
// 17. Break statement
- assertLine("executedbreak", FULLY_COVERED);
- assertLine("missedafterbreak", NOT_COVERED);
+ assertLine("executedbreak", ICounter.FULLY_COVERED);
+ assertLine("missedafterbreak", ICounter.NOT_COVERED);
// 18. Continue statement
- assertLine("executedcontinue", FULLY_COVERED);
- assertLine("missedaftercontinue", NOT_COVERED);
+ assertLine("executedcontinue", ICounter.FULLY_COVERED);
+ assertLine("missedaftercontinue", ICounter.NOT_COVERED);
// 19. Return statement
- assertLine("return", FULLY_COVERED);
- assertLine("afterreturn", NOT_COVERED);
+ assertLine("return", ICounter.FULLY_COVERED);
+ assertLine("afterreturn", ICounter.NOT_COVERED);
// 20. Implicit return
- assertLine("implicitreturn", FULLY_COVERED);
+ assertLine("implicitreturn", ICounter.FULLY_COVERED);
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ExceptionsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ExceptionsTest.java
index 25bb8caa..63cea3ba 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ExceptionsTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ExceptionsTest.java
@@ -11,10 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.FULLY_COVERED;
-import static org.jacoco.core.analysis.ILine.NOT_COVERED;
-import static org.jacoco.core.analysis.ILine.PARTLY_COVERED;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target03;
import org.junit.Test;
@@ -39,54 +36,62 @@ public class ExceptionsTest extends ValidationTestBase {
// 1. Implicit Exception
// Currently no coverage at all, as we don't see when a block aborts
// somewhere in the middle.
- assertLine("implicitException.before", NOT_COVERED);
- assertLine("implicitException.exception", NOT_COVERED);
- assertLine("implicitException.after", NOT_COVERED);
+ assertLine("implicitException.before", ICounter.NOT_COVERED);
+ assertLine("implicitException.exception", ICounter.NOT_COVERED);
+ assertLine("implicitException.after", ICounter.NOT_COVERED);
// 2. Explicit Exception
// Full coverage, as we recognize throw statements as block boundaries.
- assertLine("explicitException.before", FULLY_COVERED);
- assertLine("explicitException.throw", FULLY_COVERED);
+ assertLine("explicitException.before", ICounter.FULLY_COVERED);
+ assertLine("explicitException.throw", ICounter.FULLY_COVERED);
// 3. Try/Catch Block Without Exception Thrown
- assertLine("noExceptionTryCatch.beforeBlock", FULLY_COVERED);
- assertLine("noExceptionTryCatch.tryBlock", FULLY_COVERED);
- assertLine("noExceptionTryCatch.catchBlock", NOT_COVERED);
+ assertLine("noExceptionTryCatch.beforeBlock", ICounter.FULLY_COVERED);
+ assertLine("noExceptionTryCatch.tryBlock", ICounter.FULLY_COVERED);
+ assertLine("noExceptionTryCatch.catchBlock", ICounter.NOT_COVERED);
// 4. Try/Catch Block Without a Implicit Exception Thrown
// As always with implicit exceptions we don't see when a block aborts
// somewhere in the middle.
- assertLine("implicitExceptionTryCatch.beforeBlock", FULLY_COVERED);
- assertLine("implicitExceptionTryCatch.before", NOT_COVERED);
- assertLine("implicitExceptionTryCatch.exception", NOT_COVERED);
- assertLine("implicitExceptionTryCatch.after", NOT_COVERED);
- assertLine("implicitExceptionTryCatch.catchBlock", FULLY_COVERED);
+ assertLine("implicitExceptionTryCatch.beforeBlock",
+ ICounter.FULLY_COVERED);
+ assertLine("implicitExceptionTryCatch.before", ICounter.NOT_COVERED);
+ assertLine("implicitExceptionTryCatch.exception", ICounter.NOT_COVERED);
+ assertLine("implicitExceptionTryCatch.after", ICounter.NOT_COVERED);
+ assertLine("implicitExceptionTryCatch.catchBlock",
+ ICounter.FULLY_COVERED);
// 5. Try/Catch Block With Exception Thrown Explicitly
- assertLine("explicitExceptionTryCatch.beforeBlock", FULLY_COVERED);
- assertLine("explicitExceptionTryCatch.before", FULLY_COVERED);
- assertLine("explicitExceptionTryCatch.throw", FULLY_COVERED);
- assertLine("explicitExceptionTryCatch.catchBlock", FULLY_COVERED);
+ assertLine("explicitExceptionTryCatch.beforeBlock",
+ ICounter.FULLY_COVERED);
+ assertLine("explicitExceptionTryCatch.before", ICounter.FULLY_COVERED);
+ assertLine("explicitExceptionTryCatch.throw", ICounter.FULLY_COVERED);
+ assertLine("explicitExceptionTryCatch.catchBlock",
+ ICounter.FULLY_COVERED);
// 6. Finally Block Without Exception Thrown
// Finally block is yellow as the exception path is missing.
- assertLine("noExceptionFinally.beforeBlock", FULLY_COVERED);
- assertLine("noExceptionFinally.tryBlock", FULLY_COVERED);
- assertLine("noExceptionFinally.finallyBlock", PARTLY_COVERED);
+ assertLine("noExceptionFinally.beforeBlock", ICounter.FULLY_COVERED);
+ assertLine("noExceptionFinally.tryBlock", ICounter.FULLY_COVERED);
+ assertLine("noExceptionFinally.finallyBlock", ICounter.PARTLY_COVERED);
// 7. Finally Block With Implicit Exception
// Finally block is yellow as the non-exception path is missing.
- assertLine("implicitExceptionFinally.beforeBlock", FULLY_COVERED);
- assertLine("implicitExceptionFinally.before", NOT_COVERED);
- assertLine("implicitExceptionFinally.exception", NOT_COVERED);
- assertLine("implicitExceptionFinally.after", NOT_COVERED);
- assertLine("implicitExceptionFinally.finallyBlock", PARTLY_COVERED);
+ assertLine("implicitExceptionFinally.beforeBlock",
+ ICounter.FULLY_COVERED);
+ assertLine("implicitExceptionFinally.before", ICounter.NOT_COVERED);
+ assertLine("implicitExceptionFinally.exception", ICounter.NOT_COVERED);
+ assertLine("implicitExceptionFinally.after", ICounter.NOT_COVERED);
+ assertLine("implicitExceptionFinally.finallyBlock",
+ ICounter.PARTLY_COVERED);
// 8. Finally Block With Exception Thrown Explicitly
- assertLine("explicitExceptionFinally.beforeBlock", FULLY_COVERED);
- assertLine("explicitExceptionFinally.before", FULLY_COVERED);
- assertLine("explicitExceptionFinally.throw", FULLY_COVERED);
- assertLine("explicitExceptionFinally.finallyBlock", FULLY_COVERED);
+ assertLine("explicitExceptionFinally.beforeBlock",
+ ICounter.FULLY_COVERED);
+ assertLine("explicitExceptionFinally.before", ICounter.FULLY_COVERED);
+ assertLine("explicitExceptionFinally.throw", ICounter.FULLY_COVERED);
+ assertLine("explicitExceptionFinally.finallyBlock",
+ ICounter.FULLY_COVERED);
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/FieldInitializationInTwoConstructorsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/FieldInitializationInTwoConstructorsTest.java
index d6794b6d..7a1f90fe 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/FieldInitializationInTwoConstructorsTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/FieldInitializationInTwoConstructorsTest.java
@@ -11,10 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.FULLY_COVERED;
-import static org.jacoco.core.analysis.ILine.NOT_COVERED;
-import static org.jacoco.core.analysis.ILine.PARTLY_COVERED;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target09;
import org.junit.Test;
@@ -36,10 +33,10 @@ public class FieldInitializationInTwoConstructorsTest extends
@Test
public void testCoverageResult() {
- assertLine("field1", PARTLY_COVERED);
- assertLine("field2", PARTLY_COVERED);
- assertLine("constr1", FULLY_COVERED);
- assertLine("constr2", NOT_COVERED);
+ assertLine("field1", ICounter.PARTLY_COVERED);
+ assertLine("field2", ICounter.PARTLY_COVERED);
+ assertLine("constr1", ICounter.FULLY_COVERED);
+ assertLine("constr2", ICounter.NOT_COVERED);
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitDefaultConstructorTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitDefaultConstructorTest.java
index 67943655..2d68fb78 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitDefaultConstructorTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitDefaultConstructorTest.java
@@ -11,8 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.FULLY_COVERED;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target06;
import org.junit.Test;
@@ -33,7 +32,7 @@ public class ImplicitDefaultConstructorTest extends ValidationTestBase {
@Test
public void testCoverageResult() {
- assertLine("classdef", FULLY_COVERED);
+ assertLine("classdef", ICounter.FULLY_COVERED);
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitFieldInitializationTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitFieldInitializationTest.java
index 69618399..26d11d04 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitFieldInitializationTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ImplicitFieldInitializationTest.java
@@ -11,9 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.FULLY_COVERED;
-import static org.jacoco.core.analysis.ILine.NO_CODE;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target08;
import org.junit.Test;
@@ -34,11 +32,11 @@ public class ImplicitFieldInitializationTest extends ValidationTestBase {
@Test
public void testCoverageResult() {
- assertLine("classdef", FULLY_COVERED);
- assertLine("field1", NO_CODE);
- assertLine("field2", FULLY_COVERED);
- assertLine("field3", NO_CODE);
- assertLine("field4", FULLY_COVERED);
+ assertLine("classdef", ICounter.FULLY_COVERED);
+ assertLine("field1", ICounter.EMPTY);
+ assertLine("field2", ICounter.FULLY_COVERED);
+ assertLine("field3", ICounter.EMPTY);
+ assertLine("field4", ICounter.FULLY_COVERED);
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/InterfaceClassInitializerTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/InterfaceClassInitializerTest.java
index 41a7f1c6..56eaa135 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/InterfaceClassInitializerTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/InterfaceClassInitializerTest.java
@@ -11,9 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.FULLY_COVERED;
-import static org.jacoco.core.analysis.ILine.NO_CODE;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target04;
import org.junit.Test;
@@ -35,11 +33,11 @@ public class InterfaceClassInitializerTest extends ValidationTestBase {
@Test
public void testCoverageResult() {
- assertLine("const1", NO_CODE);
- assertLine("const2", NO_CODE);
+ assertLine("const1", ICounter.EMPTY);
+ assertLine("const2", ICounter.EMPTY);
- assertLine("const3", FULLY_COVERED);
- assertLine("const4", FULLY_COVERED);
+ assertLine("const3", ICounter.FULLY_COVERED);
+ assertLine("const4", ICounter.FULLY_COVERED);
}
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/PrivateEmptyDefaultConstructorTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/PrivateEmptyDefaultConstructorTest.java
index 3cde39d3..4a09d293 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/PrivateEmptyDefaultConstructorTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/PrivateEmptyDefaultConstructorTest.java
@@ -11,9 +11,7 @@
*******************************************************************************/
package org.jacoco.core.test.validation;
-import static org.jacoco.core.analysis.ILine.NOT_COVERED;
-import static org.jacoco.core.analysis.ILine.NO_CODE;
-
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target07;
import org.junit.Test;
@@ -35,8 +33,8 @@ public class PrivateEmptyDefaultConstructorTest extends ValidationTestBase {
@Test
public void testCoverageResult() {
- assertLine("classdef", NO_CODE);
- assertLine("constructor", NOT_COVERED);
+ assertLine("classdef", ICounter.EMPTY);
+ assertLine("constructor", ICounter.NOT_COVERED);
}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
index 96ca7f7a..43a42e9a 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java
@@ -18,6 +18,7 @@ import java.util.Collection;
import org.jacoco.core.analysis.Analyzer;
import org.jacoco.core.analysis.CoverageBuilder;
import org.jacoco.core.analysis.IClassCoverage;
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.analysis.ILine;
import org.jacoco.core.analysis.ISourceFileCoverage;
import org.jacoco.core.data.ExecutionDataStore;
@@ -38,10 +39,10 @@ public abstract class ValidationTestBase {
private static final String[] STATUS_NAME = new String[4];
{
- STATUS_NAME[ILine.NO_CODE] = "NO_CODE";
- STATUS_NAME[ILine.NOT_COVERED] = "NOT_COVERED";
- STATUS_NAME[ILine.FULLY_COVERED] = "FULLY_COVERED";
- STATUS_NAME[ILine.PARTLY_COVERED] = "PARTLY_COVERED";
+ STATUS_NAME[ICounter.EMPTY] = "NO_CODE";
+ STATUS_NAME[ICounter.NOT_COVERED] = "NOT_COVERED";
+ STATUS_NAME[ICounter.FULLY_COVERED] = "FULLY_COVERED";
+ STATUS_NAME[ICounter.PARTLY_COVERED] = "PARTLY_COVERED";
}
protected final Class<?> target;
@@ -101,15 +102,9 @@ public abstract class ValidationTestBase {
final int missedBranches, final int coveredBranches) {
final int nr = source.getLineNumber(tag);
final ILine line = sourceCoverage.getLine(nr);
- String msg = String.format("L%s: %s", Integer.valueOf(nr),
+ final String msg = String.format("L%s: %s", Integer.valueOf(nr),
source.getLine(nr));
- int insnStatus = ILine.NO_CODE;
- if (line.getInstructionCounter().getMissedCount() > 0) {
- insnStatus |= ILine.NOT_COVERED;
- }
- if (line.getInstructionCounter().getCoveredCount() > 0) {
- insnStatus |= ILine.FULLY_COVERED;
- }
+ final int insnStatus = line.getInstructionCounter().getStatus();
assertEquals(msg, STATUS_NAME[status], STATUS_NAME[insnStatus]);
assertEquals(msg + " branches",
CounterImpl.getInstance(missedBranches, coveredBranches),
diff --git a/org.jacoco.core/src/org/jacoco/core/analysis/ICounter.java b/org.jacoco.core/src/org/jacoco/core/analysis/ICounter.java
index 324a9b21..77f872b3 100644
--- a/org.jacoco.core/src/org/jacoco/core/analysis/ICounter.java
+++ b/org.jacoco.core/src/org/jacoco/core/analysis/ICounter.java
@@ -13,7 +13,7 @@ package org.jacoco.core.analysis;
/**
* A counter holds the missed and the covered number of particular items like
- * classes, methods, blocks or instructions.
+ * classes, methods, branches or instructions.
*
* @author Marc R. Hoffmann
* @version $Revision: 11 $
@@ -21,6 +21,26 @@ package org.jacoco.core.analysis;
public interface ICounter {
/**
+ * Status flag for no items (value is 0x00).
+ */
+ public static final int EMPTY = 0x00;
+
+ /**
+ * Status flag when all items are not covered (value is 0x01).
+ */
+ public static final int NOT_COVERED = 0x01;
+
+ /**
+ * Status flag when all items are covered (value is 0x02).
+ */
+ public static final int FULLY_COVERED = 0x02;
+
+ /**
+ * Status flag when items are partly covered (value is 0x03).
+ */
+ public static final int PARTLY_COVERED = NOT_COVERED | FULLY_COVERED;
+
+ /**
* Returns the total count of items.
*
* @return total count of items
@@ -57,4 +77,16 @@ public interface ICounter {
*/
public double getMissedRatio();
+ /**
+ * Returns the coverage status of this counter.
+ *
+ * @see ICounter#EMPTY
+ * @see ICounter#NOT_COVERED
+ * @see ICounter#PARTLY_COVERED
+ * @see ICounter#FULLY_COVERED
+ *
+ * @return status of this line
+ */
+ public int getStatus();
+
}
diff --git a/org.jacoco.core/src/org/jacoco/core/analysis/ILine.java b/org.jacoco.core/src/org/jacoco/core/analysis/ILine.java
index 28c694d3..f96788c4 100644
--- a/org.jacoco.core/src/org/jacoco/core/analysis/ILine.java
+++ b/org.jacoco.core/src/org/jacoco/core/analysis/ILine.java
@@ -21,40 +21,6 @@ package org.jacoco.core.analysis;
public interface ILine {
/**
- * Flag for lines that do not contain instructions (value is 0x00).
- */
- public static final byte NO_CODE = 0x00;
-
- /**
- * Flag for lines where no instruction or branch is covered (value is 0x01).
- */
- public static final byte NOT_COVERED = 0x01;
-
- /**
- * Flag for lines where all instructions and branches are covered (value is
- * 0x02).
- */
- public static final byte FULLY_COVERED = 0x02;
-
- /**
- * Flag for lines where only a part of the instructions or branches are
- * covered (value is 0x03).
- */
- public static final byte PARTLY_COVERED = NOT_COVERED | FULLY_COVERED;
-
- /**
- * Returns the coverage status of the given line.
- *
- * @see #NO_CODE
- * @see #NOT_COVERED
- * @see #PARTLY_COVERED
- * @see #FULLY_COVERED
- *
- * @return status of this line
- */
- public byte getStatus();
-
- /**
* Returns the instruction counter for this line.
*
* @return instruction counter
@@ -68,4 +34,17 @@ public interface ILine {
*/
public ICounter getBranchCounter();
+ /**
+ * Returns the coverage status of this line, calculated from the
+ * instructions counter and branch counter.
+ *
+ * @see ICounter#EMPTY
+ * @see ICounter#NOT_COVERED
+ * @see ICounter#PARTLY_COVERED
+ * @see ICounter#FULLY_COVERED
+ *
+ * @return status of this line
+ */
+ public int getStatus();
+
}
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java
index d936a7bc..36dcd04b 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/CounterImpl.java
@@ -167,6 +167,14 @@ public abstract class CounterImpl implements ICounter {
return (double) missed / (missed + covered);
}
+ public int getStatus() {
+ int status = covered > 0 ? FULLY_COVERED : EMPTY;
+ if (missed > 0) {
+ status |= NOT_COVERED;
+ }
+ return status;
+ }
+
@Override
public boolean equals(final Object obj) {
if (obj instanceof ICounter) {
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java b/org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java
index 12ef7f7b..b53b64fb 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/analysis/LineImpl.java
@@ -119,16 +119,8 @@ public abstract class LineImpl implements ILine {
// === ILine implementation ===
- public byte getStatus() {
- byte status = NO_CODE;
- if (instructions.getMissedCount() > 0 || branches.getMissedCount() > 0) {
- status = NOT_COVERED;
- }
- if (instructions.getCoveredCount() > 0
- || branches.getCoveredCount() > 0) {
- status |= FULLY_COVERED;
- }
- return status;
+ public int getStatus() {
+ return instructions.getStatus() | branches.getStatus();
}
public ICounter getInstructionCounter() {
diff --git a/org.jacoco.examples/src/org/jacoco/examples/CoreTutorial.java b/org.jacoco.examples/src/org/jacoco/examples/CoreTutorial.java
index 0930c738..450a20aa 100644
--- a/org.jacoco.examples/src/org/jacoco/examples/CoreTutorial.java
+++ b/org.jacoco.examples/src/org/jacoco/examples/CoreTutorial.java
@@ -19,7 +19,6 @@ import org.jacoco.core.analysis.Analyzer;
import org.jacoco.core.analysis.CoverageBuilder;
import org.jacoco.core.analysis.IClassCoverage;
import org.jacoco.core.analysis.ICounter;
-import org.jacoco.core.analysis.ILine;
import org.jacoco.core.data.ExecutionDataStore;
import org.jacoco.core.instr.Instrumenter;
import org.jacoco.core.runtime.IRuntime;
@@ -98,11 +97,11 @@ public class CoreTutorial {
private String getColor(final int status) {
switch (status) {
- case ILine.NOT_COVERED:
+ case ICounter.NOT_COVERED:
return "red";
- case ILine.PARTLY_COVERED:
+ case ICounter.PARTLY_COVERED:
return "yellow";
- case ILine.FULLY_COVERED:
+ case ICounter.FULLY_COVERED:
return "green";
}
return "";
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/html/SourceHighlighter.java b/org.jacoco.report/src/org/jacoco/report/internal/html/SourceHighlighter.java
index aad6c899..7002b7e7 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/html/SourceHighlighter.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/html/SourceHighlighter.java
@@ -17,6 +17,7 @@ import java.io.Reader;
import java.util.Arrays;
import java.util.Locale;
+import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.analysis.ILine;
import org.jacoco.core.analysis.ISourceNode;
import org.jacoco.report.internal.html.resources.Styles;
@@ -33,7 +34,7 @@ class SourceHighlighter {
private String tabReplacement;
- private String lang = "java";
+ private String lang;
/**
* Creates a new highlighter with default settings.
@@ -44,6 +45,7 @@ class SourceHighlighter {
public SourceHighlighter(final Locale locale) {
this.locale = locale;
setTabWidth(4);
+ lang = "java";
}
/**
@@ -115,42 +117,42 @@ class SourceHighlighter {
throws IOException {
final String style;
switch (line.getStatus()) {
- case ILine.NOT_COVERED:
+ case ICounter.NOT_COVERED:
style = Styles.NOT_COVERED;
break;
- case ILine.FULLY_COVERED:
+ case ICounter.FULLY_COVERED:
style = Styles.FULLY_COVERED;
break;
- case ILine.PARTLY_COVERED:
+ case ICounter.PARTLY_COVERED:
style = Styles.PARTLY_COVERED;
break;
default:
return pre;
}
- final int totalBranches = line.getBranchCounter().getTotalCount();
- if (totalBranches == 0) {
- return pre.span(style);
- }
- final int missedBranches = line.getBranchCounter().getMissedCount();
- final Integer t = Integer.valueOf(totalBranches);
- if (missedBranches == 0) {
- return span(pre, style, Styles.BRANCH_FULLY_COVERED,
- "All %d branches covered.", t);
- }
- if (missedBranches == totalBranches) {
+
+ final ICounter branches = line.getBranchCounter();
+ switch (branches.getStatus()) {
+ case ICounter.NOT_COVERED:
return span(pre, style, Styles.BRANCH_NOT_COVERED,
- "All %d branches missed.", t);
+ "All %2$d branches missed.", branches);
+ case ICounter.FULLY_COVERED:
+ return span(pre, style, Styles.BRANCH_FULLY_COVERED,
+ "All %2$d branches covered.", branches);
+ case ICounter.PARTLY_COVERED:
+ return span(pre, style, Styles.BRANCH_PARTLY_COVERED,
+ "%1$d of %2$d branches missed.", branches);
+ default:
+ return pre.span(style);
}
- final Integer m = Integer.valueOf(missedBranches);
- return span(pre, style, Styles.BRANCH_PARTLY_COVERED,
- "%d of %d branches missed.", m, t);
}
private HTMLElement span(final HTMLElement parent, final String style1,
- final String style2, final String title, final Object... params)
+ final String style2, final String title, final ICounter branches)
throws IOException {
final HTMLElement span = parent.span(style1 + " " + style2);
- span.attr("title", String.format(locale, title, params));
+ final Integer missed = Integer.valueOf(branches.getMissedCount());
+ final Integer total = Integer.valueOf(branches.getTotalCount());
+ span.attr("title", String.format(locale, title, missed, total));
return span;
}
diff --git a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLReportNodeHandler.java b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLReportNodeHandler.java
index da23e6fa..002fdb22 100644
--- a/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLReportNodeHandler.java
+++ b/org.jacoco.report/src/org/jacoco/report/internal/xml/XMLReportNodeHandler.java
@@ -132,7 +132,7 @@ public class XMLReportNodeHandler implements IReportVisitor {
final int last = source.getLastLine();
for (int nr = source.getFirstLine(); nr <= last; nr++) {
final ILine line = source.getLine(nr);
- if (line.getStatus() != ILine.NO_CODE) {
+ if (line.getStatus() != ICounter.EMPTY) {
final XMLElement element = parent.element("line");
element.attr("nr", nr);
final ICounter insn = line.getInstructionCounter();