summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/ColorUtilsTest.kt
blob: 530a08a4e57053291947ea450e2145ebdbfc471c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.mapbox.mapboxsdk.utils

import android.graphics.Color
import junit.framework.Assert
import org.junit.Test

class ColorUtilsTest {

  @Test
  fun rgbaToColor_decimalComponent() {
    val input = "rgba(255,128.0000952303,0,0.7)"
    val result = ColorUtils.rgbaToColor(input)
    Assert.assertEquals(Color.argb(255, 128, 0, (0.7 * 255).toInt()), result)
  }

  @Test
  fun rgbaToColor_decimalComponent_floor() {
    val input = "rgba(255,128.70123,0,0.7)"
    val result = ColorUtils.rgbaToColor(input)
    Assert.assertEquals(Color.argb(255, 128, 0, (0.7 * 255).toInt()), result)
  }
}