roundTrip

inline fun <T, E> roundTrip(value: T, encode: (T) -> E, decode: (E) -> T): T(source)

Encodes and decodes value with the caller's serialization policy.

Compare the result with the original in the owning test:

val decoded = roundTrip(user, { json.encodeToString(it) }, { json.decodeFromString<User>(it) })
assertEquals(user, decoded)

Return

The decoded value.

Parameters

value

The fixture to round-trip.

encode

Serializes a value, including caller-specific formats and naming.

decode

The matching deserializer.