aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org/jacoco/core/test/validation/BooleanExpressionsTest.java
blob: 64dee474ad5efcbfc8d9feec5b766675db628919 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*******************************************************************************
 * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Marc R. Hoffmann - initial API and implementation
 *    
 *******************************************************************************/
package org.jacoco.core.test.validation;

import org.jacoco.core.analysis.ICounter;
import org.jacoco.core.test.validation.targets.Target02;
import org.junit.Test;

/**
 * Tests of basic Java boolean expressions.
 */
public class BooleanExpressionsTest extends ValidationTestBase {

	public BooleanExpressionsTest() {
		super(Target02.class);
	}

	@Test
	public void testCoverageResult() {

		// 1. Boolean comparison result (one case)
		assertLine("booleancmp1", ICounter.PARTLY_COVERED, 1, 1);

		// 2. Boolean comparison result (both cases)
		assertLine("booleancmp2", ICounter.FULLY_COVERED, 0, 2);

		// 3. And
		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", 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", 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", 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", 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", ICounter.PARTLY_COVERED, 1, 1);
		assertLine("condF", ICounter.PARTLY_COVERED, 1, 1);

		// 9. Not (one case)
		assertLine("notT", ICounter.PARTLY_COVERED, 1, 1);
		assertLine("notF", ICounter.PARTLY_COVERED, 1, 1);

		// 10. Not (both cases)
		assertLine("notTF", ICounter.FULLY_COVERED, 0, 2);

	}

}