Skip to content

Commit

Permalink
upload test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dogacel committed Aug 10, 2024
1 parent 885aeab commit cc61b61
Show file tree
Hide file tree
Showing 17 changed files with 1,097 additions and 0 deletions.
57 changes: 57 additions & 0 deletions generated-code-tests/src/main/kotlin/testgen/enums/enums.proto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package testgen.enums

import kotlin.Int
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber

@Serializable
public data class MessageWithEnum(
@ProtoNumber(number = 1)
public val id: Int = 0,
@ProtoNumber(number = 2)
public val testEnum: TestEnum = testgen.enums.TestEnum.FOO,
@ProtoNumber(number = 3)
public val aliasedEnum: AliasedEnum = testgen.enums.AliasedEnum.ALIAS_FOO,
@ProtoNumber(number = 4)
public val nestedEnum: NestedEnum = testgen.enums.MessageWithEnum.NestedEnum.NESTED_FOO,
) {
@Serializable
public enum class NestedEnum {
@ProtoNumber(number = 0)
NESTED_FOO,
@ProtoNumber(number = 1)
NESTED_BAR,
@ProtoNumber(number = 2)
NESTED_BAZ,
}
}

@Serializable
public enum class TestEnum {
@ProtoNumber(number = 0)
FOO,
@ProtoNumber(number = 1)
BAR,
@ProtoNumber(number = 2)
BAZ,
@ProtoNumber(number = 100)
TOP,
@ProtoNumber(number = -1)
NEG,
}

@Serializable
public enum class AliasedEnum {
@ProtoNumber(number = 0)
ALIAS_FOO,
@ProtoNumber(number = 1)
ALIAS_BAR,
@ProtoNumber(number = 2)
ALIAS_BAZ,
@ProtoNumber(number = 2)
QUX,
@ProtoNumber(number = 2)
qux,
@ProtoNumber(number = 2)
bAz,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package testgen.google.protobuf

import kotlin.ByteArray
import kotlin.String
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber

@Serializable
public data class Any(
@ProtoNumber(number = 1)
public val typeUrl: String = "",
@ProtoNumber(number = 2)
public val `value`: ByteArray = byteArrayOf(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package testgen.google.protobuf

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package testgen.google.protobuf

import kotlin.String
import kotlin.collections.List
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber

@Serializable
public data class FieldMask(
@ProtoNumber(number = 1)
public val paths: List<String> = emptyList(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package testgen.google.protobuf

import kotlin.Boolean
import kotlin.Double
import kotlin.String
import kotlin.collections.List
import kotlin.collections.Map
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber

@Serializable
public data class Struct(
@ProtoNumber(number = 1)
public val fields: Map<String, Value?> = emptyMap(),
)

@Serializable
public data class Value(
@ProtoNumber(number = 1)
public val nullValue: NullValue? = null,
@ProtoNumber(number = 2)
public val numberValue: Double? = null,
@ProtoNumber(number = 3)
public val stringValue: String? = null,
@ProtoNumber(number = 4)
public val boolValue: Boolean? = null,
@ProtoNumber(number = 5)
public val structValue: Struct? = null,
@ProtoNumber(number = 6)
public val listValue: ListValue? = null,
) {
init {
require(
listOfNotNull(
nullValue,
numberValue,
stringValue,
boolValue,
structValue,
listValue,
).size <= 1
) { "Should only contain one of kind." }
}
}

@Serializable
public data class ListValue(
@ProtoNumber(number = 1)
public val values: List<Value?> = emptyList(),
)

@Serializable
public enum class NullValue {
@ProtoNumber(number = 0)
NULL_VALUE,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package testgen.google.protobuf

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package testgen.google.protobuf

92 changes: 92 additions & 0 deletions generated-code-tests/src/main/kotlin/testgen/maps/maps.proto.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package testgen.maps

import kotlin.Boolean
import kotlin.ByteArray
import kotlin.Double
import kotlin.Float
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.UInt
import kotlin.ULong
import kotlin.collections.Map
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber

@Serializable
public data class MapsMessage(
@ProtoNumber(number = 1)
public val mapInt32Int32: Map<Int, Int> = emptyMap(),
@ProtoNumber(number = 2)
public val mapInt64Int64: Map<Long, Long> = emptyMap(),
@ProtoNumber(number = 3)
public val mapUint32Uint32: Map<UInt, UInt> = emptyMap(),
@ProtoNumber(number = 4)
public val mapUint64Uint64: Map<ULong, ULong> = emptyMap(),
@ProtoNumber(number = 5)
public val mapSint32Sint32: Map<Int, Int> = emptyMap(),
@ProtoNumber(number = 6)
public val mapSint64Sint64: Map<Long, Long> = emptyMap(),
@ProtoNumber(number = 7)
public val mapFixed32Fixed32: Map<Int, Int> = emptyMap(),
@ProtoNumber(number = 8)
public val mapFixed64Fixed64: Map<Long, Long> = emptyMap(),
@ProtoNumber(number = 9)
public val mapSfixed32Sfixed32: Map<Int, Int> = emptyMap(),
@ProtoNumber(number = 10)
public val mapSfixed64Sfixed64: Map<Long, Long> = emptyMap(),
@ProtoNumber(number = 11)
public val mapInt32Float: Map<Int, Float> = emptyMap(),
@ProtoNumber(number = 12)
public val mapInt32Double: Map<Int, Double> = emptyMap(),
@ProtoNumber(number = 13)
public val mapBoolBool: Map<Boolean, Boolean> = emptyMap(),
@ProtoNumber(number = 14)
public val mapStringString: Map<String, String> = emptyMap(),
@ProtoNumber(number = 15)
public val mapStringBytes: Map<String, ByteArray> = emptyMap(),
@ProtoNumber(number = 16)
public val mapStringNestedMessage: Map<String, NestedMessage?> = emptyMap(),
@ProtoNumber(number = 17)
public val mapStringForeignMessage: Map<String, ForeignMessage?> = emptyMap(),
@ProtoNumber(number = 18)
public val mapStringNestedEnum: Map<String, NestedEnum> = emptyMap(),
@ProtoNumber(number = 19)
public val mapStringForeignEnum: Map<String, ForeignEnum> = emptyMap(),
) {
@Serializable
public data class NestedMessage(
@ProtoNumber(number = 1)
public val a: Int = 0,
@ProtoNumber(number = 2)
public val corecursive: MapsMessage? = null,
)

@Serializable
public enum class NestedEnum {
@ProtoNumber(number = 0)
FOO,
@ProtoNumber(number = 1)
BAR,
@ProtoNumber(number = 2)
BAZ,
@ProtoNumber(number = -1)
NEG,
}
}

@Serializable
public data class ForeignMessage(
@ProtoNumber(number = 1)
public val c: Int = 0,
)

@Serializable
public enum class ForeignEnum {
@ProtoNumber(number = 0)
FOREIGN_FOO,
@ProtoNumber(number = 1)
FOREIGN_BAR,
@ProtoNumber(number = 2)
FOREIGN_BAZ,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package testgen.messages

import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber

@Serializable
public class MessageNoFields() {
override fun toString(): String = "MessageNoFields"

override fun hashCode(): Int = 70_682_849

override fun equals(other: Any?): Boolean = other is MessageNoFields

@Serializable
public data class SubMessageNoFields(
@ProtoNumber(number = 1)
public val subHello: SubMessageNoFields? = null,
) {
@Serializable
public data class SubMessageNoFieldsExtend(
@ProtoNumber(number = 1)
public val type: Type = testgen.messages.MessageNoFields.Type.UNKNOWN,
)
}

@Serializable
public data class SubMessageOneofFields(
@ProtoNumber(number = 1)
public val someValue: Int? = null,
) {
init {
require(
listOfNotNull(
someValue,
).size <= 1
) { "Should only contain one of some_oneof." }
}
}

@Serializable
public enum class Type {
@ProtoNumber(number = 0)
UNKNOWN,
@ProtoNumber(number = 1)
KNOWN,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package testgen.messages

import kotlin.Int
import kotlin.String
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber

@Serializable
public data class MessagesMessage(
@ProtoNumber(number = 1)
public val id: String = "",
@ProtoNumber(number = 2)
public val optionalNestedMessage: NestedMessage? = null,
@ProtoNumber(number = 3)
public val optionalForeignMessage: ForeignMessage? = null,
) {
@Serializable
public data class NestedMessage(
@ProtoNumber(number = 1)
public val a: Int = 0,
@ProtoNumber(number = 2)
public val corecursive: MessagesMessage? = null,
)
}

@Serializable
public data class ForeignMessage(
@ProtoNumber(number = 1)
public val c: Int = 0,
)
Loading

0 comments on commit cc61b61

Please sign in to comment.