summaryrefslogtreecommitdiff
path: root/runtime/commonTest/src/kotlinx/serialization/protobuf/SampleClasses.kt
blob: 1a8d83a22b3632406e1d3cfe96d5abb41cbbbb4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright 2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package kotlinx.serialization.protobuf

import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable
import kotlin.test.assertEquals

@Serializable
data class TestInt(@SerialId(1) @ProtoType(ProtoNumberType.SIGNED) val a: Int)

@Serializable
data class TestList(@SerialId(1) val a: List<Int> = emptyList())

@Serializable
data class TestString(@SerialId(2) val b: String)

@Serializable
data class TestInner(@SerialId(3) val a: TestInt)

@Serializable
data class TestComplex(@SerialId(42) val b: Int, @SerialId(2) val c: String)

@Serializable
data class TestNumbers(@SerialId(1) @ProtoType(ProtoNumberType.FIXED) val a: Int, @SerialId(2) val b: Long)

@Serializable
data class TestIntWithList(
        @SerialId(1) val s: Int,
        @SerialId(10) val l: List<Int>
)

val t1 = TestInt(-150)
val t1e = TestInt(0)
val t2 = TestList(listOf(150, 228, 1337))
val t2e = TestList(listOf())
val t3 = TestString("testing")
val t3e = TestString("")
val t4 = TestInner(t1)
val t5 = TestComplex(42, "testing")
val t6 = TestNumbers(100500, Long.MAX_VALUE)