All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonTest.kotlinx.serialization.json.JsonReifiedCollectionsTest.kt Maven / Gradle / Ivy

There is a newer version: 1.7.3
Show newest version
/*
 * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package kotlinx.serialization.json

import kotlinx.serialization.*
import kotlin.test.*

class JsonReifiedCollectionsTest : JsonTestBase() {
    @Serializable
    data class DataHolder(val data: String)

    @Test
    fun testReifiedList() = parametrizedTest { jsonTestingMode ->
        val data = listOf(DataHolder("data"), DataHolder("not data"))
        val json = default.encodeToString(data, jsonTestingMode)
        val data2 = default.decodeFromString>(json, jsonTestingMode)
        assertEquals(data, data2)
    }

    @Test
    fun testReifiedMap() = parametrizedTest { jsonTestingMode ->
        val data = mapOf("data" to DataHolder("data"), "smth" to DataHolder("not data"))
        val json = lenient.encodeToString(data, jsonTestingMode)
        val data2 = lenient.decodeFromString>(json, jsonTestingMode)
        assertEquals(data, data2)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy