Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,17 @@ private class TextControllerImpl(initialValue: String) : TextController {
set(value) {
_textValue.value = value
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as TextController

return textValue == other.textValue
}

override fun hashCode(): Int {
return textValue.hashCode()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.squareup.workflow1.ui

import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals

@OptIn(WorkflowUiExperimentalApi::class)
internal class TextControllerTest {

@Test fun `equals works with the same value`() {
val controller1 = TextController(initialValue = "apple")
val controller2 = TextController(initialValue = "apple")
assertEquals(controller1, controller2)
}

@Test fun `equals works with different values`() {
val controller1 = TextController(initialValue = "apple")
val controller2 = TextController(initialValue = "orange")
assertNotEquals(controller1, controller2)
}
}
Loading