diff --git a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoParserTest.kt b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoParserTest.kt index 4827397e42..0909efa6b2 100644 --- a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoParserTest.kt +++ b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoParserTest.kt @@ -3066,6 +3066,51 @@ class ProtoParserTest { assertThat(ProtoParser.parse(location, proto)).isEqualTo(expected) } + @Test fun parsingTrailingComments() { + val proto = """ + |enum ImageState { + | IMAGE_STATE_UNSPECIFIED = 0; + | IMAGE_STATE_READONLY = 1; /* unlocked */ + | IMAGE_STATE_MUSTLOCK = 2; /* must be locked */ + |} + """.trimMargin() + val expected = ProtoFileElement( + location = location, + types = listOf( + EnumElement( + location = location.at(1, 1), + name = "ImageState", + documentation = "", + options = listOf(), + constants = listOf( + EnumConstantElement( + location = location.at(2, 5), + name = "IMAGE_STATE_UNSPECIFIED", + tag = 0, + documentation = "", + options = listOf(), + ), + EnumConstantElement( + location = location.at(3, 5), + name = "IMAGE_STATE_READONLY", + tag = 1, + documentation = "unlocked", + options = listOf(), + ), + EnumConstantElement( + location = location.at(4, 5), + name = "IMAGE_STATE_MUSTLOCK", + tag = 2, + documentation = "must be locked", + options = listOf(), + ), + ), + ), + ), + ) + assertThat(ProtoParser.parse(location, proto)).isEqualTo(expected) + } + @Test fun forbidMultipleSyntaxDefinitions() { val proto = """ | syntax = "proto2";