summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/plugins/locationlayer/UtilsTest.java
blob: 9caad6c6a1f5edfa55f30db6cc7c99d848a7e7ef (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
package com.mapbox.mapboxsdk.plugins.locationlayer;

import org.junit.Test;

import static junit.framework.Assert.assertEquals;

public final class UtilsTest {


  @Test
  public void shortestRotation_doesReturnValueDistanceQuickestToZero() throws Exception {
    float value = Utils.shortestRotation(0, 181);
    assertEquals(360f, value);
    value = Utils.shortestRotation(0, 179);
    assertEquals(0f, value);
    value = Utils.shortestRotation(0, 180);
    assertEquals(0f, value);
  }

  @Test
  public void shortestRotation_doesReturnValueDistanceQuickestToFifty() throws Exception {
    float value = Utils.shortestRotation(50, 231);
    assertEquals(410f, value);
    value = Utils.shortestRotation(50, 229);
    assertEquals(50f, value);
    value = Utils.shortestRotation(50, 180);
    assertEquals(50f, value);
  }
}