X Tutup
Skip to content

Commit 78c1ddc

Browse files
committed
Quality: add test case for issue #18 ("Boolean.FALSE fails to set Boolean value to false.")
1 parent 573f089 commit 78c1ddc

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2017 java2script.org and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Udo Borkowski - initial implementation
10+
*******************************************************************************/
11+
12+
package net.sf.j2s.test.junit.issue;
13+
14+
import junit.framework.TestCase;
15+
import net.sf.j2s.test.junit.sample.C;
16+
import net.sf.j2s.test.junit.sample.C2;
17+
import net.sf.j2s.test.junit.sample.CF;
18+
import net.sf.j2s.test.junit.sample.CF1;
19+
import net.sf.j2s.test.junit.util.Output;
20+
21+
public class Issue18Test extends TestCase {
22+
23+
/**
24+
* Boolean.FALSE must evaluate to <code>false</code> when used in a boolean expression,
25+
* e.g. as a literal in a ternary operation's condition.
26+
*/
27+
public void testFALSEInInTernaryCondition() {
28+
assertEquals("OK", Boolean.FALSE ? "FAILED" : "OK");
29+
}
30+
31+
/**
32+
* Boolean.FALSE must evaluate to <code>false</code> when used in a boolean expression,
33+
* e.g. as the value of a variable in a ternary operation's condition.
34+
*/
35+
public void testFALSEInInTernaryConditionViaVariable() {
36+
Boolean b = Boolean.FALSE;
37+
assertEquals("OK", b ? "FAILED" : "OK");
38+
}
39+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2017 java2script.org and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Udo Borkowski - initial implementation
10+
*******************************************************************************/
11+
12+
package net.sf.j2s.test.junit.java.lang;
13+
14+
import junit.framework.TestCase;
15+
import net.sf.j2s.test.junit.sample.C;
16+
import net.sf.j2s.test.junit.sample.C2;
17+
import net.sf.j2s.test.junit.sample.CF;
18+
import net.sf.j2s.test.junit.sample.CF1;
19+
import net.sf.j2s.test.junit.util.Output;
20+
21+
public class BooleanTest extends TestCase {
22+
23+
/**
24+
* Boolean.FALSE must evaluate to <code>false</code> when used in a boolean expression.
25+
*/
26+
public void testFALSEInInBooleanExpression() {
27+
assertFalse(Boolean.FALSE);
28+
}
29+
30+
/**
31+
* Boolean.FALSE must evaluate to <code>false</code> when used in a boolean expression,
32+
* e.g. as a literal in an if-statement's condition.
33+
*/
34+
public void testFALSEInIfCondition() {
35+
if (Boolean.FALSE) {
36+
fail("Boolean.FALSE does not evaluate to false");
37+
}
38+
}
39+
40+
/**
41+
* Boolean.TRUE must evaluate to <code>true</code> when used in a boolean expression,
42+
* e.g. as a literal in an if-statement's condition.
43+
*/
44+
public void testTRUEInIfCondition() {
45+
if (Boolean.TRUE) {
46+
// do nothing
47+
} else {
48+
fail("Boolean.TRUE does not evaluate to true");
49+
}
50+
}
51+
52+
}

0 commit comments

Comments
 (0)
X Tutup