Skip to content

Commit

Permalink
✅ Update tests of ZeroAsByteSerializer.hashCode() (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
LVMVRQUXL committed Aug 27, 2024
1 parent 7a5d556 commit d946c92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ internal class ZeroAsByteSerializerCommonSample {
val serializer = ZeroAsByteSerializer()
val other = ZeroAsByteSerializer()
val equality: Boolean = serializer.hashCode() == other.hashCode()
assertTrue(equality)
val message = "Hash codes of '$serializer' should be equal."
assertTrue(equality, message)
}

// ----------------------- Serialization operations ------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.kotools.types.kotlinx.serialization
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotools.types.experimental.ExperimentalKotoolsTypesApi
import kotools.types.internal.hashCodeOf
import org.kotools.types.internal.InvalidZero
import kotlin.test.Test
import kotlin.test.assertEquals
Expand All @@ -22,6 +23,16 @@ class ZeroAsByteSerializerTest {
assertFalse(actual, message)
}

@Test
fun hashCodeShouldUseToStringMethod() {
val serializer = ZeroAsByteSerializer()
val actual: Int = serializer.hashCode()
val expected: Int = hashCodeOf("$serializer")
val message = "Hash code of '$serializer' should be calculated from " +
"its string representation."
assertEquals(expected, actual, message)
}

// ----------------------- Serialization operations ------------------------

@Test
Expand Down

0 comments on commit d946c92

Please sign in to comment.