Difference Between Boolean.TRUE and true in Java (#14253)
This commit is related to the article "Difference Between Boolean.TRUE and true in Java"
This commit is contained in:
parent
d55d260870
commit
e3afaf7996
@ -0,0 +1,34 @@
|
|||||||
|
package com.baeldung.booleans;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
public class BooleanTrueVsTrueUnitTest {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void given_BooleanValues_whenUsingBooleanTrue_thenTestBooleanEquality() {
|
||||||
|
assertEquals(Boolean.TRUE, Boolean.valueOf(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void given_BooleanValues_whenUsingBooleanTrue_thenTestBooleanIdentity() {
|
||||||
|
assertTrue(Boolean.TRUE == Boolean.valueOf(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void given_TrueValue_whenUsingTrue_thenTestPrimitiveEquality() {
|
||||||
|
assertTrue(true == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void given_TrueStringValue_whenUsingBooleanTrue_thenTestBooleanToString() {
|
||||||
|
assertEquals("true", Boolean.TRUE.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void given_PrimitiveValue_whenUsingStringValueOf_thenTestPrimitiveToString() {
|
||||||
|
assertEquals("true", String.valueOf(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user