|
| 1 | +package com.fewlaps.flone; |
| 2 | + |
| 3 | +import org.junit.Before; |
| 4 | +import org.junit.Test; |
| 5 | + |
| 6 | +import static junit.framework.Assert.assertEquals; |
| 7 | + |
| 8 | +/** |
| 9 | + * @author Roc Boronat ([email protected]) |
| 10 | + * @date 05/07/2015 |
| 11 | + */ |
| 12 | +public class DesiredYawTest { |
| 13 | + |
| 14 | + DesiredYawCalculator desiredYaw; |
| 15 | + |
| 16 | + @Before |
| 17 | + public void init(){ |
| 18 | + desiredYaw = new DesiredYawCalculator(); |
| 19 | + } |
| 20 | + |
| 21 | + @Test |
| 22 | + public void shouldReturn0ForSameValues() { |
| 23 | + double sameValue = 42; |
| 24 | + double yaw = desiredYaw.getYaw(sameValue, sameValue); |
| 25 | + |
| 26 | + assertEquals(0d, yaw); |
| 27 | + } |
| 28 | + |
| 29 | + @Test |
| 30 | + public void shouldReturn20ForDroneAt0AndPhoneAt20() { |
| 31 | + double yaw = desiredYaw.getYaw(0, 20); |
| 32 | + |
| 33 | + assertEquals(20d, yaw); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void shouldReturn30ForDroneAt50AndPhoneAt80() { |
| 38 | + double yaw = desiredYaw.getYaw(50, 80); |
| 39 | + |
| 40 | + assertEquals(30d, yaw); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void shouldReturn20ForDroneAtMinus10AndPhoneAt10() { |
| 45 | + double yaw = desiredYaw.getYaw(-10, 10); |
| 46 | + |
| 47 | + assertEquals(20d, yaw); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + public void shouldReturn20ForDroneAtMinus170AndPhoneAtMinus150() { |
| 52 | + double yaw = desiredYaw.getYaw(-170, -150); |
| 53 | + |
| 54 | + assertEquals(20d, yaw); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void shouldReturnMinus20ForDroneAtMinus170AndPhoneAt170() { |
| 59 | + double yaw = desiredYaw.getYaw(-170, 170); |
| 60 | + |
| 61 | + assertEquals(-20d, yaw); |
| 62 | + } |
| 63 | + |
| 64 | + @Test |
| 65 | + public void shouldReturn20ForDroneAt170AndPhoneAtMinus170() { |
| 66 | + double yaw = desiredYaw.getYaw(170, -170); |
| 67 | + |
| 68 | + assertEquals(20d, yaw); |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + public void shouldReturn170ForDroneAtMinus20AndPhoneAt150() { |
| 73 | + double yaw = desiredYaw.getYaw(-20, 150); |
| 74 | + |
| 75 | + assertEquals(170d, yaw); |
| 76 | + } |
| 77 | +} |
0 commit comments