mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 01:19:33 +00:00
Avoid hard-coded number and update the related test.
This commit is contained in:
committed by
Benoit Marty
parent
74fc570708
commit
ff77fca34d
+1
-1
@@ -42,6 +42,6 @@ fun avatarColors(userId: String): AvatarColors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun String.toHash(): Int {
|
internal fun String.toHash(): Int {
|
||||||
return toList().sumOf { it.code } % 8
|
return toList().sumOf { it.code } % avatarColorsLight.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-5
@@ -24,11 +24,8 @@ import org.junit.Test
|
|||||||
class AvatarColorsTest {
|
class AvatarColorsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `ensure list size`() {
|
fun `ensure the size of the avatar color are equal for light and dark theme`() {
|
||||||
// avatarColorsDark and avatarColorsLight size must not be modified.
|
assertThat(avatarColorsDark.size).isEqualTo(avatarColorsLight.size)
|
||||||
// 8 is used as a hard-coded modulo in `String.toHash()` extension.
|
|
||||||
assertThat(avatarColorsDark.size).isEqualTo(8)
|
|
||||||
assertThat(avatarColorsLight.size).isEqualTo(8)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user