File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
workflow-ui/core-common/src
main/java/com/squareup/workflow1/ui
test/java/com/squareup/workflow1/ui Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -87,4 +87,17 @@ private class TextControllerImpl(initialValue: String) : TextController {
87
87
set(value) {
88
88
_textValue .value = value
89
89
}
90
+
91
+ override fun equals (other : Any? ): Boolean {
92
+ if (this == = other) return true
93
+ if (javaClass != other?.javaClass) return false
94
+
95
+ other as TextController
96
+
97
+ return textValue == other.textValue
98
+ }
99
+
100
+ override fun hashCode (): Int {
101
+ return textValue.hashCode()
102
+ }
90
103
}
Original file line number Diff line number Diff line change
1
+ package com.squareup.workflow1.ui
2
+
3
+ import org.junit.Test
4
+ import kotlin.test.assertEquals
5
+ import kotlin.test.assertNotEquals
6
+
7
+ @OptIn(WorkflowUiExperimentalApi ::class )
8
+ internal class TextControllerTest {
9
+
10
+ @Test fun `equals works with the same value` () {
11
+ val controller1 = TextController (initialValue = " apple" )
12
+ val controller2 = TextController (initialValue = " apple" )
13
+ assertEquals(controller1, controller2)
14
+ }
15
+
16
+ @Test fun `equals works with different values` () {
17
+ val controller1 = TextController (initialValue = " apple" )
18
+ val controller2 = TextController (initialValue = " orange" )
19
+ assertNotEquals(controller1, controller2)
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments