-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #734 from arkivanov/fix-hash-string
Fixed "Key was used multiple times" crash with duplicateConfigurationsEnabled flag enabled
- Loading branch information
Showing
5 changed files
with
38 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
decompose/src/commonTest/kotlin/com/arkivanov/decompose/KeyHashStringTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.arkivanov.decompose | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class KeyHashStringTest { | ||
|
||
@Test | ||
fun keyed_keyHashString_returns_distinct_values() { | ||
val configs = listOf(Config.A(id = 1), Config.B(id = 1), Config.A(id = 1)) | ||
|
||
val keyStrings = | ||
configs | ||
.keyed { it } | ||
.map { (key, config) -> Child.Destroyed(configuration = config, key = key) } | ||
.map { it.keyHashString() } | ||
|
||
assertEquals(configs.size, keyStrings.distinct().size) | ||
} | ||
|
||
private sealed interface Config { | ||
data class A(val id: Int) : Config | ||
data class B(val id: Int) : Config | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters