diff options
author | Sergey Shanshin <sergey.shanshin@jetbrains.com> | 2022-06-30 15:43:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-30 15:43:42 +0300 |
commit | 5e8ccad1f70a9457e0ffe6ae6b10a0bd0eaaa618 (patch) | |
tree | e522ba5e8da0cb4701f4a259d9f2ba5b43b42bf2 /formats/json/commonTest/src/kotlinx/serialization/json/JsonTransientTest.kt | |
parent | 605a35faa87534e24482aa00a52a2a71bebd51a3 (diff) | |
download | kotlinx.serialization-5e8ccad1f70a9457e0ffe6ae6b10a0bd0eaaa618.tar.gz |
Add Okio integration (#1901)
* Add okio integration as separate module json-okio
* Extract separate module json-tests that tests both Java streams and okio
* Rewrite Java stream writer so that it uses much faster in-place UTF8 encoder instead of java.io.Writer
* Add benchmarks for streams and okio
* Disable targets for tests that are not supported by okio (they can't be run on LinuxX64-86 hosts anyway)
Diffstat (limited to 'formats/json/commonTest/src/kotlinx/serialization/json/JsonTransientTest.kt')
-rw-r--r-- | formats/json/commonTest/src/kotlinx/serialization/json/JsonTransientTest.kt | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/formats/json/commonTest/src/kotlinx/serialization/json/JsonTransientTest.kt b/formats/json/commonTest/src/kotlinx/serialization/json/JsonTransientTest.kt deleted file mode 100644 index c46a11d5..00000000 --- a/formats/json/commonTest/src/kotlinx/serialization/json/JsonTransientTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ -@file:Suppress("EqualsOrHashCode") - -package kotlinx.serialization.json - -import kotlinx.serialization.Serializable -import kotlinx.serialization.Transient -import kotlinx.serialization.json.internal.* -import kotlin.test.* - -class JsonTransientTest : JsonTestBase() { - - @Serializable - class Data(val a: Int = 0, @Transient var b: Int = 42, val e: Boolean = false) { - var c = "Hello" - val d: String - get() = "hello" - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || this::class != other::class) return false - - other as Data - - if (a != other.a) return false - if (b != other.b) return false - if (c != other.c) return false - if (d != other.d) return false - - return true - } - - override fun toString(): String { - return "Data(a=$a, b=$b, e=$e, c='$c', d='$d')" - } - } - - @Test - fun testAll() = parametrizedTest { jsonTestingMode -> - assertEquals("""{"a":0,"e":false,"c":"Hello"}""", - default.encodeToString(Data.serializer(), Data(), jsonTestingMode)) - } - - @Test - fun testMissingOptionals() = parametrizedTest { jsonTestingMode -> - assertEquals(default.decodeFromString(Data.serializer(), """{"a":0,"c":"Hello"}""", jsonTestingMode), Data()) - assertEquals(default.decodeFromString(Data.serializer(), """{"a":0}""", jsonTestingMode), Data()) - } - - @Test - fun testThrowTransient() = parametrizedTest { jsonTestingMode -> - assertFailsWith(JsonDecodingException::class) { - default.decodeFromString(Data.serializer(), """{"a":0,"b":100500,"c":"Hello"}""", jsonTestingMode) - } - } -} |