diff options
| author | David Göransson <david.goransson@mullvad.net> | 2025-08-29 14:51:10 +0200 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2025-09-01 08:34:16 +0200 |
| commit | e02d460164fe09d5cf085cdcb3f40a9251bae633 (patch) | |
| tree | cbad368a9d30876f24631a6548e7d32e2e2c9524 /android/lib/model/src/test | |
| parent | 4f03db1de3224d666cf6fc5ab255f3629435a59a (diff) | |
| download | mullvadvpn-interactive-maps.tar.xz mullvadvpn-interactive-maps.zip | |
Add interactive mapsinteractive-maps
Diffstat (limited to 'android/lib/model/src/test')
| -rw-r--r-- | android/lib/model/src/test/kotlin/net/mullvad/mullvadvpn/lib/model/map/Vector3Test.kt | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/android/lib/model/src/test/kotlin/net/mullvad/mullvadvpn/lib/model/map/Vector3Test.kt b/android/lib/model/src/test/kotlin/net/mullvad/mullvadvpn/lib/model/map/Vector3Test.kt new file mode 100644 index 0000000000..c9f35692bf --- /dev/null +++ b/android/lib/model/src/test/kotlin/net/mullvad/mullvadvpn/lib/model/map/Vector3Test.kt @@ -0,0 +1,69 @@ +package net.mullvad.mullvadvpn.lib.model.map + +import kotlin.test.assertEquals +import net.mullvad.mullvadvpn.lib.model.LatLong +import net.mullvad.mullvadvpn.lib.model.Latitude +import net.mullvad.mullvadvpn.lib.model.Longitude +import org.junit.jupiter.api.Test + +class Vector3Test { + @Test + fun `Y-axis center test`() { + assertVector3Equals(Y_POSITIVE_CENTER.toVector3(), Vector3(0f, 1f, 0f)) + assertVector3Equals(Y_NEGATIVE_CENTER.toVector3(), Vector3(0f, -1f, 0f)) + } + + @Test + fun `Z-axis center test`() { + assertVector3Equals(Z_POSITIVE_CENTER.toVector3(), Vector3(0f, 0f, 1f)) + assertVector3Equals(Z_NEGATIVE_CENTER.toVector3(), Vector3(0f, 0f, -1f)) + } + + @Test + fun `X-axis center test`() { + assertVector3Equals(X_POSITIVE_CENTER.toVector3(), Vector3(-1f, 0f, 0f)) + assertVector3Equals(X_NEGATIVE_CENTER.toVector3(), Vector3(1f, 0f, 0f)) + } + + @Test + fun `Y-axis center to LatLng test`() { + assertLatLngEquals(Vector3(0f, 1f, 0f).toLatLng(), Y_POSITIVE_CENTER) + assertLatLngEquals(Vector3(0f, -1f, 0f).toLatLng(), Y_NEGATIVE_CENTER) + } + + @Test + fun `Z-axis center to LatLng test`() { + assertLatLngEquals(Vector3(0f, 0f, 1f).toLatLng(), Z_POSITIVE_CENTER) + assertLatLngEquals(Vector3(0f, 0f, -1f).toLatLng(), Z_NEGATIVE_CENTER) + } + + @Test + fun `X-axis center to LatLng test`() { + assertLatLngEquals(Vector3(-1f, 0f, 0f).toLatLng(), X_POSITIVE_CENTER) + assertLatLngEquals(Vector3(1f, 0f, 0f).toLatLng(), X_NEGATIVE_CENTER) + } + + companion object { + // NORTH POLE + val Y_POSITIVE_CENTER = LatLong(Latitude(90f), Longitude(0f)) + // SOUTH POLE + val Y_NEGATIVE_CENTER = LatLong(Latitude(-90f), Longitude(0f)) + + val Z_POSITIVE_CENTER = LatLong(Latitude(0f), Longitude(0f)) + val Z_NEGATIVE_CENTER = LatLong(Latitude(0f), Longitude.fromFloat(180f)) + + val X_NEGATIVE_CENTER = LatLong(Latitude(0f), Longitude.fromFloat(-90f)) + val X_POSITIVE_CENTER = LatLong(Latitude(0f), Longitude.fromFloat(90f)) + } + + fun assertVector3Equals(expected: Vector3, actual: Vector3) { + assertEquals(expected.x, actual.x, 0.0001f) + assertEquals(expected.y, actual.y, 0.0001f) + assertEquals(expected.z, actual.z, 0.0001f) + } + + fun assertLatLngEquals(expected: LatLong, actual: LatLong) { + assertEquals(expected.latitude.distanceTo(actual.latitude), 0f, 0.0001f) + assertEquals(expected.longitude.distanceTo(actual.longitude), 0f, 0.0001f) + } +} |
