@@ -30,6 +30,7 @@ import com.squareup.wire.schema.internal.MAX_TAG_VALUE
3030import com.squareup.wire.schema.internal.parser.OptionElement.Kind
3131import kotlin.test.Test
3232import kotlin.test.fail
33+ import kotlinx.datetime.Clock
3334
3435class ProtoParserTest {
3536 internal var location = Location .get(" file.proto" )
@@ -437,13 +438,13 @@ class ProtoParserTest {
437438 }
438439
439440 @Test
440- fun messageFieldTrailingComment () {
441+ fun messageFieldTrailingCommentWithCarriageReturn () {
441442 // Trailing message field comment.
442443 val proto = """
443444 |message Test {
444445 | optional string name = 1; // Test all the things!
445446 |}
446- """ .trimMargin()
447+ """ .trimMargin().replace( " \n " , " \r\n " )
447448 val parsed = ProtoParser .parse(location, proto)
448449 val message = parsed.types[0 ] as MessageElement
449450 val field = message.fields[0 ]
@@ -3066,6 +3067,51 @@ class ProtoParserTest {
30663067 assertThat(ProtoParser .parse(location, proto)).isEqualTo(expected)
30673068 }
30683069
3070+ @Test fun parsingTrailingComments () {
3071+ val proto = """
3072+ |enum ImageState {
3073+ | IMAGE_STATE_UNSPECIFIED = 0;
3074+ | IMAGE_STATE_READONLY = 1; /* unlocked */
3075+ | IMAGE_STATE_MUSTLOCK = 2; /* must be locked */
3076+ |}
3077+ """ .trimMargin()
3078+ val expected = ProtoFileElement (
3079+ location = location,
3080+ types = listOf (
3081+ EnumElement (
3082+ location = location.at(1 , 1 ),
3083+ name = " ImageState" ,
3084+ documentation = " " ,
3085+ options = listOf (),
3086+ constants = listOf (
3087+ EnumConstantElement (
3088+ location = location.at(2 , 5 ),
3089+ name = " IMAGE_STATE_UNSPECIFIED" ,
3090+ tag = 0 ,
3091+ documentation = " " ,
3092+ options = listOf (),
3093+ ),
3094+ EnumConstantElement (
3095+ location = location.at(3 , 5 ),
3096+ name = " IMAGE_STATE_READONLY" ,
3097+ tag = 1 ,
3098+ documentation = " unlocked" ,
3099+ options = listOf (),
3100+ ),
3101+ EnumConstantElement (
3102+ location = location.at(4 , 5 ),
3103+ name = " IMAGE_STATE_MUSTLOCK" ,
3104+ tag = 2 ,
3105+ documentation = " must be locked" ,
3106+ options = listOf (),
3107+ ),
3108+ ),
3109+ ),
3110+ ),
3111+ )
3112+ assertThat(ProtoParser .parse(location, proto)).isEqualTo(expected)
3113+ }
3114+
30693115 @Test fun forbidMultipleSyntaxDefinitions () {
30703116 val proto = """
30713117 | syntax = "proto2";
0 commit comments