ADD: added new version of protobuf

This commit is contained in:
Henry Winkel
2022-12-20 10:09:28 +01:00
parent 4a79559129
commit 1e2b3dda7b
1513 changed files with 123720 additions and 83381 deletions

View File

@@ -33,6 +33,13 @@ package com.google.protobuf.kotlin
import com.google.common.truth.Truth.assertThat
import com.google.protobuf.TestUtil
import com.google.protobuf.TestUtil.toBytes
import com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.EvilNamesProto2
import com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.HardKeywordsAllTypesProto2
import com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.Interface
import com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2Kt
import com.google.protobuf.kotlin.generator.evilNamesProto2
import com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto2
import com.google.protobuf.kotlin.generator.interface_
import com.google.protobuf.test.UnittestImport.ImportEnum
import com.google.protobuf.test.UnittestImport.ImportMessage
import com.google.protobuf.test.UnittestImportPublic.PublicImportMessage
@@ -60,13 +67,6 @@ import protobuf_unittest.testEmptyMessageWithExtensions
import protobuf_unittest.testEnumMap
import protobuf_unittest.testIntIntMap
import protobuf_unittest.testMaps
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.EvilNamesProto2
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.HardKeywordsAllTypesProto2
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.Interface
import `in`.com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2Kt
import `in`.com.google.protobuf.kotlin.generator.evilNamesProto2
import `in`.com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto2
import `in`.com.google.protobuf.kotlin.generator.interface_
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -183,7 +183,6 @@ class Proto2Test {
.isEqualTo(TestUtil.getAllSetBuilder().build())
}
@Suppress("CheckResult")
@Test
fun testGetters() {
testAllTypes {
@@ -204,7 +203,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testDefaultGetters() {
testAllTypes {
@@ -215,7 +213,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testRepeatedGettersAndSetters() {
testAllTypes {
@@ -297,7 +294,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testHazzers() {
testAllTypes {
@@ -328,7 +324,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testClears() {
testAllTypes {
@@ -517,7 +512,6 @@ class Proto2Test {
.isEqualTo(TestUtil.getAllExtensionsSet())
}
@Suppress("CheckResult")
@Test
fun testExtensionGetters() {
testAllExtensions {
@@ -540,7 +534,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testRepeatedExtensionGettersAndSetters() {
testAllExtensions {
@@ -621,7 +614,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testExtensionContains() {
testAllExtensions {
@@ -652,7 +644,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testExtensionClears() {
testAllExtensions {
@@ -734,7 +725,6 @@ class Proto2Test {
)
}
@Suppress("CheckResult")
@Test
fun testMapGettersAndSetters() {
val intMap = testIntIntMap {
@@ -786,7 +776,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testMapRemove() {
val intMap = testIntIntMap {
@@ -814,7 +803,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testMapClear() {
val intMap = testIntIntMap {
@@ -863,6 +851,7 @@ class Proto2Test {
boolean = 1L
sealed = "foo"
interface_ = 1F
in_ = 1
object_ = "foo"
cachedSize_ = "foo"
serializedSize_ = true
@@ -888,6 +877,7 @@ class Proto2Test {
.setBoolean(1L)
.setSealed("foo")
.setInterface(1F)
.setIn(1)
.setObject("foo")
.setCachedSize_("foo")
.setSerializedSize_(true)
@@ -898,13 +888,15 @@ class Proto2Test {
assertThat(interface_ {}).isEqualTo(Interface.newBuilder().build())
}
@Suppress("CheckResult")
@Test
fun testHardKeywordGettersAndSetters() {
hardKeywordsAllTypesProto2 {
as_ = 1
assertThat(as_).isEqualTo(1)
in_ = "foo"
assertThat(in_).isEqualTo("foo")
break_ = HardKeywordsAllTypesProto2.NestedEnum.FOO
assertThat(break_).isEqualTo(HardKeywordsAllTypesProto2.NestedEnum.FOO)
@@ -928,13 +920,15 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testHardKeywordHazzers() {
hardKeywordsAllTypesProto2 {
as_ = 1
assertThat(hasAs_()).isTrue()
in_ = "foo"
assertThat(hasIn_()).isTrue()
break_ = HardKeywordsAllTypesProto2.NestedEnum.FOO
assertThat(hasBreak_()).isTrue()
@@ -943,7 +937,6 @@ class Proto2Test {
}
}
@Suppress("CheckResult")
@Test
fun testHardKeywordClears() {
hardKeywordsAllTypesProto2 {
@@ -951,6 +944,10 @@ class Proto2Test {
clearAs_()
assertThat(hasAs_()).isFalse()
in_ = "foo"
clearIn_()
assertThat(hasIn_()).isFalse()
break_ = HardKeywordsAllTypesProto2.NestedEnum.FOO
clearBreak_()
assertThat(hasBreak_()).isFalse()

View File

@@ -31,13 +31,13 @@
package com.google.protobuf.kotlin
import com.google.common.truth.Truth.assertThat
import com.google.protobuf.kotlin.generator.`in`.EvilNamesProto3OuterClass.Class
import com.google.protobuf.kotlin.generator.`in`.EvilNamesProto3OuterClass.EvilNamesProto3
import com.google.protobuf.kotlin.generator.`in`.EvilNamesProto3OuterClass.HardKeywordsAllTypesProto3
import com.google.protobuf.kotlin.generator.`in`.HardKeywordsAllTypesProto3Kt
import com.google.protobuf.kotlin.generator.`in`.class_
import com.google.protobuf.kotlin.generator.`in`.evilNamesProto3
import com.google.protobuf.kotlin.generator.`in`.hardKeywordsAllTypesProto3
import com.google.protobuf.kotlin.generator.EvilNamesProto3OuterClass.Class
import com.google.protobuf.kotlin.generator.EvilNamesProto3OuterClass.EvilNamesProto3
import com.google.protobuf.kotlin.generator.EvilNamesProto3OuterClass.HardKeywordsAllTypesProto3
import com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto3Kt
import com.google.protobuf.kotlin.generator.class_
import com.google.protobuf.kotlin.generator.evilNamesProto3
import com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto3
import proto3_unittest.TestAllTypesKt
import proto3_unittest.TestAllTypesKt.nestedMessage
import proto3_unittest.UnittestProto3.TestAllTypes
@@ -54,7 +54,6 @@ import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
class Proto3Test {
@Suppress("CheckResult")
@Test
fun testGettersAndSetters() {
testAllTypes {
@@ -66,17 +65,11 @@ class Proto3Test {
assertThat(optionalNestedMessage).isEqualTo(TestAllTypesKt.nestedMessage { bb = 118 })
optionalNestedEnum = NestedEnum.BAZ
assertThat(optionalNestedEnum).isEqualTo(NestedEnum.BAZ)
assertThat(optionalNestedEnumValue).isEqualTo(3)
optionalNestedEnumValue = 1
assertThat(optionalNestedEnumValue).isEqualTo(1)
assertThat(optionalNestedEnum).isEqualTo(NestedEnum.FOO)
oneofUint32 = 601
assertThat(oneofUint32).isEqualTo(601)
}
}
@Suppress("CheckResult")
@Test
fun testRepeatedGettersAndSetters() {
testAllTypes {
@@ -266,7 +259,6 @@ class Proto3Test {
assertThat(class_ {}).isEqualTo(Class.newBuilder().build())
}
@Suppress("CheckResult")
@Test
fun testHardKeywordGettersAndSetters() {
hardKeywordsAllTypesProto3 {
@@ -299,7 +291,6 @@ class Proto3Test {
}
}
@Suppress("CheckResult")
@Test
fun testHardKeywordHazzers() {
hardKeywordsAllTypesProto3 {
@@ -317,7 +308,6 @@ class Proto3Test {
}
}
@Suppress("CheckResult")
@Test
fun testHardKeywordClears() {
hardKeywordsAllTypesProto3 {

View File

@@ -33,7 +33,7 @@ syntax = "proto2";
package protobuf.kotlin.generator;
option java_package = "in.com.google.protobuf.kotlin.generator";
option java_package = "com.google.protobuf.kotlin.generator";
message EvilNamesProto2 {
optional bool initialized = 1;
@@ -61,6 +61,7 @@ message EvilNamesProto2 {
optional int64 boolean = 18;
optional string sealed = 19;
optional float interface = 20;
optional int32 in = 21;
optional string object = 22;
optional string cached_size = 23;
optional bool serialized_size = 24;
@@ -78,6 +79,7 @@ message HardKeywordsAllTypesProto2 {
}
optional int32 as = 1;
optional string in = 2;
optional NestedEnum break = 3;
map<int32, int32> continue = 4;
optional NestedMessage do = 5;

View File

@@ -33,7 +33,7 @@ syntax = "proto3";
package protobuf.kotlin.generator;
option java_package = "com.google.protobuf.kotlin.generator.in";
option java_package = "com.google.protobuf.kotlin.generator";
message EvilNamesProto3 {
bool initialized = 1;