Skip to content

Commit 1cd7e17

Browse files
committed
functional: adjust kotlin tests with collection fields in struct
This commit adjusts the tests and the usage of collection fields of structures. Instead of calling 'add()' / 'put()' we override the field with new collection. Signed-off-by: Patryk Wrobel <[email protected]>
1 parent aa2e984 commit 1cd7e17

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

functional-tests/functional/android-kotlin/src/test/kotlin/com/here/android/test/EquatableNullableTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class EquatableNullableTest {
106106
@org.junit.Test
107107
fun equatableNullableStructNotEqualsMapField() {
108108
val otherStruct: Equatable.EquatableNullableStruct = createEquatableNullableStruct()
109-
otherStruct.mapField!!.put(2, "foo")
109+
otherStruct.mapField = otherStruct.mapField!! + mapOf(2 to "foo")
110110

111111
assertNotEquals(mainStruct, otherStruct)
112112
assertNotEquals(mainStruct.hashCode(), otherStruct.hashCode())
@@ -115,7 +115,7 @@ class EquatableNullableTest {
115115
@org.junit.Test
116116
fun equatableNullableStructNotEqualsArrayField() {
117117
val otherStruct: Equatable.EquatableNullableStruct = createEquatableNullableStruct()
118-
otherStruct.arrayField!!.add("foo")
118+
otherStruct.arrayField = otherStruct.arrayField!! + listOf("foo")
119119

120120
assertNotEquals(mainStruct, otherStruct)
121121
assertNotEquals(mainStruct.hashCode(), otherStruct.hashCode())
@@ -135,15 +135,15 @@ class EquatableNullableTest {
135135
@org.junit.Test
136136
fun equatableNullableStructNotEqualsCpp() {
137137
val otherStruct: Equatable.EquatableNullableStruct = createEquatableNullableStruct()
138-
otherStruct.arrayField!!.add("foo")
138+
otherStruct.arrayField = otherStruct.arrayField!! + listOf("foo")
139139

140140
assertFalse(EquatableClass.areEqual(mainStruct, otherStruct))
141141
}
142142

143143
private fun createEquatableNullableStruct(): Equatable.EquatableNullableStruct {
144144
return Equatable.EquatableNullableStruct(
145145
true, -42, 6542, 3.14f, "nonsense", Equatable.NestedEquatableStruct("foo"),
146-
Equatable.SomeSomeEnum.BAR, mutableMapOf(0 to "one", 1 to "two"), mutableListOf("one", "two")
146+
Equatable.SomeSomeEnum.BAR, mapOf(0 to "one", 1 to "two"), listOf("one", "two")
147147
)
148148
}
149149
}

functional-tests/functional/android-kotlin/src/test/kotlin/com/here/android/test/EquatableTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class EquatableTest {
115115
@org.junit.Test
116116
fun equatableStructNotEqualsMapField() {
117117
val otherStruct: Equatable.EquatableStruct = createEquatableStruct()
118-
otherStruct.mapField.put(2, "foo")
118+
otherStruct.mapField = otherStruct.mapField + mapOf(2 to "foo")
119119

120120
assertNotEquals(mainStruct, otherStruct)
121121
assertNotEquals(mainStruct.hashCode(), otherStruct.hashCode())
@@ -124,7 +124,7 @@ class EquatableTest {
124124
@org.junit.Test
125125
fun equatableStructNotEqualsArrayField() {
126126
val otherStruct: Equatable.EquatableStruct = createEquatableStruct()
127-
otherStruct.arrayField.add("foo")
127+
otherStruct.arrayField = otherStruct.arrayField + listOf("foo")
128128

129129
assertNotEquals(mainStruct, otherStruct)
130130
assertNotEquals(mainStruct.hashCode(), otherStruct.hashCode())
@@ -163,7 +163,7 @@ class EquatableTest {
163163
@org.junit.Test
164164
fun equatableStructNotEqualsCpp() {
165165
val otherStruct: Equatable.EquatableStruct = createEquatableStruct()
166-
otherStruct.arrayField.add("foo")
166+
otherStruct.arrayField = otherStruct.arrayField + listOf("foo")
167167

168168
assertFalse(EquatableClass.areEqual(mainStruct, otherStruct))
169169
}
@@ -387,7 +387,7 @@ class EquatableTest {
387387
private fun createEquatableStruct(): Equatable.EquatableStruct {
388388
return Equatable.EquatableStruct(
389389
true, 65542, 2147484000L, 1.0f, 2.0, "nonsense", Equatable.NestedEquatableStruct("foo"),
390-
Equatable.SomeSomeEnum.BAR, mutableMapOf(0 to "one", 1 to "two"), mutableListOf("one", "two")
390+
Equatable.SomeSomeEnum.BAR, mapOf(0 to "one", 1 to "two"), listOf("one", "two")
391391
)
392392
}
393393
}

0 commit comments

Comments
 (0)