@@ -441,13 +441,13 @@ class ProtoParserTest {
441441 }
442442
443443 @Test
444- fun messageFieldTrailingComment () {
444+ fun messageFieldTrailingCommentWithCarriageReturn () {
445445 // Trailing message field comment.
446446 val proto = """
447447 |message Test {
448448 | optional string name = 1; // Test all the things!
449449 |}
450- """ .trimMargin()
450+ """ .trimMargin().replace( " \n " , " \r\n " )
451451 val parsed = ProtoParser .parse(location, proto)
452452 val message = parsed.types[0 ] as MessageElement
453453 val field = message.fields[0 ]
@@ -3204,6 +3204,51 @@ class ProtoParserTest {
32043204 assertThat(ProtoParser .parse(location, proto)).isEqualTo(expected)
32053205 }
32063206
3207+ @Test fun parsingTrailingComments () {
3208+ val proto = """
3209+ |enum ImageState {
3210+ | IMAGE_STATE_UNSPECIFIED = 0;
3211+ | IMAGE_STATE_READONLY = 1; /* unlocked */
3212+ | IMAGE_STATE_MUSTLOCK = 2; /* must be locked */
3213+ |}
3214+ """ .trimMargin()
3215+ val expected = ProtoFileElement (
3216+ location = location,
3217+ types = listOf (
3218+ EnumElement (
3219+ location = location.at(1 , 1 ),
3220+ name = " ImageState" ,
3221+ documentation = " " ,
3222+ options = listOf (),
3223+ constants = listOf (
3224+ EnumConstantElement (
3225+ location = location.at(2 , 5 ),
3226+ name = " IMAGE_STATE_UNSPECIFIED" ,
3227+ tag = 0 ,
3228+ documentation = " " ,
3229+ options = listOf (),
3230+ ),
3231+ EnumConstantElement (
3232+ location = location.at(3 , 5 ),
3233+ name = " IMAGE_STATE_READONLY" ,
3234+ tag = 1 ,
3235+ documentation = " unlocked" ,
3236+ options = listOf (),
3237+ ),
3238+ EnumConstantElement (
3239+ location = location.at(4 , 5 ),
3240+ name = " IMAGE_STATE_MUSTLOCK" ,
3241+ tag = 2 ,
3242+ documentation = " must be locked" ,
3243+ options = listOf (),
3244+ ),
3245+ ),
3246+ ),
3247+ ),
3248+ )
3249+ assertThat(ProtoParser .parse(location, proto)).isEqualTo(expected)
3250+ }
3251+
32073252 @Test fun forbidMultipleSyntaxDefinitions () {
32083253 val proto = """
32093254 | syntax = "proto2";
0 commit comments