[BAEL-3117] Added integer xor

This commit is contained in:
dupirefr 2019-08-27 07:55:16 +02:00
parent d781011762
commit 1b0dea74f6
1 changed files with 13 additions and 8 deletions

View File

@ -7,58 +7,63 @@ import static org.assertj.core.api.Assertions.assertThat;
class XorUnitTest {
@Test
void givenDieselManualCar_whenXorOldSchool_ThenFalse() {
void givenDieselManualCar_whenXorOldSchool_thenFalse() {
Car car = Car.dieselAndManualCar();
boolean dieselXorManual = (car.isDiesel() && !car.isManual()) || (!car.isDiesel() && car.isManual());
assertThat(dieselXorManual).isFalse();
}
@Test
void givenDieselAutomaticCar_whenXorOldSchool_ThenTrue() {
void givenDieselAutomaticCar_whenXorOldSchool_thenTrue() {
Car car = Car.dieselAndAutomaticCar();
boolean dieselXorManual = (car.isDiesel() && !car.isManual()) || (!car.isDiesel() && car.isManual());
assertThat(dieselXorManual).isTrue();
}
@Test
void givenNonDieselManualCar_whenXorOldSchool_ThenTrue() {
void givenNonDieselManualCar_whenXorOldSchool_thenTrue() {
Car car = Car.oilAndManualCar();
boolean dieselXorManual = (car.isDiesel() && !car.isManual()) || (!car.isDiesel() && car.isManual());
assertThat(dieselXorManual).isTrue();
}
@Test
void givenNonDieselAutomaticCar_whenXorOldSchool_ThenFalse() {
void givenNonDieselAutomaticCar_whenXorOldSchool_thenFalse() {
Car car = Car.oilAndAutomaticCar();
boolean dieselXorManual = (car.isDiesel() && !car.isManual()) || (!car.isDiesel() && car.isManual());
assertThat(dieselXorManual).isFalse();
}
@Test
void givenDieselManualCar_whenXor_ThenFalse() {
void givenDieselManualCar_whenXor_thenFalse() {
Car car = Car.dieselAndManualCar();
boolean dieselXorManual = car.isDiesel() ^ car.isManual();
assertThat(dieselXorManual).isFalse();
}
@Test
void givenDieselAutomaticCar_whenXor_ThenTrue() {
void givenDieselAutomaticCar_whenXor_thenTrue() {
Car car = Car.dieselAndAutomaticCar();
boolean dieselXorManual = car.isDiesel() ^ car.isManual();
assertThat(dieselXorManual).isTrue();
}
@Test
void givenNonDieselManualCar_whenXor_ThenTrue() {
void givenNonDieselManualCar_whenXor_thenTrue() {
Car car = Car.oilAndManualCar();
boolean dieselXorManual = car.isDiesel() ^ car.isManual();
assertThat(dieselXorManual).isTrue();
}
@Test
void givenNonDieselAutomaticCar_whenXor_ThenFalse() {
void givenNonDieselAutomaticCar_whenXor_thenFalse() {
Car car = Car.oilAndAutomaticCar();
boolean dieselXorManual = car.isDiesel() ^ car.isManual();
assertThat(dieselXorManual).isFalse();
}
@Test
void givenNumbersOneAndThree_whenXor_thenTwo() {
assertThat(1 ^ 3).isEqualTo(2);
}
}