Created
March 31, 2020 15:45
-
-
Save ShikaSD/e3cf3a005fc09c13cea5a916926e5644 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private object TestObject : Serializable | |
@Test | |
fun `object instance is the same after deserialization`() { | |
assertEquals(TestObject, serializeDeserialize(TestObject)) | |
} | |
private fun serializeDeserialize(instance: Serializable): Serializable { | |
val out = ByteArrayOutputStream() | |
ObjectOutputStream(out).use { | |
it.writeObject(instance) | |
} | |
return ObjectInputStream(ByteArrayInputStream(out.toByteArray())).use { | |
it.readObject() as TestObject | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment