Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions testdata/java/light/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>eval.dev.quality</groupId>
<artifactId>test-java-light</artifactId>
<version>SNAPSHOT</version>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.openclover</groupId>
<artifactId>clover-maven-plugin</artifactId>
<version>4.5.2</version>
<configuration>
<generateHtml>false</generateHtml>
<generateJson>false</generateJson>
<generatePdf>false</generatePdf>
<generateXml>true</generateXml>
<includeFailedTestCoverage>true</includeFailedTestCoverage>
<showInnerFunctions>true</showInnerFunctions>
<showLambdaFunctions>true</showLambdaFunctions>
<singleCloverDatabase>true</singleCloverDatabase>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.eval;

class CallLoopConditionsOftenEnough {
static int callLoopConditionsOftenEnough(int x, int y) {
if (x < 10 || x > 20) {
return 0;
}

for (int i = 0; i < y; i++) {
if (i > 20) {
x++; // This needs to be executed more than 10 times
}
}

if (x > 20) { // This block needs to be reached for full coverage
x = x / 2;
}

return x;
}
}
13 changes: 13 additions & 0 deletions testdata/java/light/src/main/java/com/eval/CascadingIfElse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.eval;

class CascadingIfElse {
static int cascadingIfElse(int i) {
if (i == 1) {
return 2;
} else if (i == 3) {
return 4;
} else {
return 5;
}
}
}
11 changes: 11 additions & 0 deletions testdata/java/light/src/main/java/com/eval/ConditionsAnd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.eval;

class ConditionsAnd {
static boolean conditionsAnd(char x, char y) {
if (x == 'A' && y == 'B') {
return true;
}

return false;
}
}
15 changes: 15 additions & 0 deletions testdata/java/light/src/main/java/com/eval/ForLoop.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.eval;

class ForLoop {
static int forLoop(int s) {
int sum = 0;
for (int i = 0; i < s; i++) {
sum = sum + i;
}
for (int i = 0; i < s; i++) {
sum = sum + i;
}

return sum;
}
}
11 changes: 11 additions & 0 deletions testdata/java/light/src/main/java/com/eval/SimpleIfElse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.eval;

class SimpleIfElse {
static int simpleIfElse(int i) {
if (i == 1) {
return 0;
} else {
return 1;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.eval;

class SimpleSwitchWithReturn {
static int simpleSwitchWithReturn(int i) {
switch (i) {
case 1:
return 0;
default:
return 1;
}
}
}
12 changes: 12 additions & 0 deletions testdata/java/light/src/main/java/com/eval/Sort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.eval;

class Sort {
static boolean isSorted(int[] a) {
int i = 0;
while (i < a.length - 1 && a[i] <= a[i + 1]) {
i++;
}

return i == a.length - 1;
}
}
11 changes: 11 additions & 0 deletions testdata/java/light/src/main/java/com/eval/TypeArrayAccess.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.eval;

class TypeArrayAccess {
static int typeArrayAccess(int[] x) {
if (x[0] == 123) {
return x[0];
}

return 3;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.eval;

class TypeArrayConsecutiveAccess {
static int typeArrayConsecutiveAccess(int[] input) {
int cnt = 0;
if (input[0] == 0)
cnt++;
if (input[1] == 8)
cnt++;
return cnt;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.eval;

class TypeArrayMultidimensionalArrayLength {
static int typeArrayMultidimensionalArrayLength(int[][] x) {
if (x.length == 2) {
if (x[0].length == 2) {
return 2;
}

return 1;
}

return 0;
}
}
1 change: 1 addition & 0 deletions testdata/java/plain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<generateJson>false</generateJson>
<generatePdf>false</generatePdf>
<generateXml>true</generateXml>
<includeFailedTestCoverage>true</includeFailedTestCoverage>
<showInnerFunctions>true</showInnerFunctions>
<showLambdaFunctions>true</showLambdaFunctions>
<singleCloverDatabase>true</singleCloverDatabase>
Expand Down