@@ -437,13 +437,13 @@ class ProtoParserTest {
437437 }
438438
439439 @Test
440- fun messageFieldTrailingComment () {
440+ fun messageFieldTrailingCommentWithCarriageReturn () {
441441 // Trailing message field comment.
442442 val proto = """
443443 |message Test {
444444 | optional string name = 1; // Test all the things!
445445 |}
446- """ .trimMargin()
446+ """ .trimMargin().replace( " \n " , " \r\n " )
447447 val parsed = ProtoParser .parse(location, proto)
448448 val message = parsed.types[0 ] as MessageElement
449449 val field = message.fields[0 ]
@@ -3066,6 +3066,51 @@ class ProtoParserTest {
30663066 assertThat(ProtoParser .parse(location, proto)).isEqualTo(expected)
30673067 }
30683068
3069+ @Test fun parsingTrailingComments () {
3070+ val proto = """
3071+ |enum ImageState {
3072+ | IMAGE_STATE_UNSPECIFIED = 0;
3073+ | IMAGE_STATE_READONLY = 1; /* unlocked */
3074+ | IMAGE_STATE_MUSTLOCK = 2; /* must be locked */
3075+ |}
3076+ """ .trimMargin()
3077+ val expected = ProtoFileElement (
3078+ location = location,
3079+ types = listOf (
3080+ EnumElement (
3081+ location = location.at(1 , 1 ),
3082+ name = " ImageState" ,
3083+ documentation = " " ,
3084+ options = listOf (),
3085+ constants = listOf (
3086+ EnumConstantElement (
3087+ location = location.at(2 , 5 ),
3088+ name = " IMAGE_STATE_UNSPECIFIED" ,
3089+ tag = 0 ,
3090+ documentation = " " ,
3091+ options = listOf (),
3092+ ),
3093+ EnumConstantElement (
3094+ location = location.at(3 , 5 ),
3095+ name = " IMAGE_STATE_READONLY" ,
3096+ tag = 1 ,
3097+ documentation = " unlocked" ,
3098+ options = listOf (),
3099+ ),
3100+ EnumConstantElement (
3101+ location = location.at(4 , 5 ),
3102+ name = " IMAGE_STATE_MUSTLOCK" ,
3103+ tag = 2 ,
3104+ documentation = " must be locked" ,
3105+ options = listOf (),
3106+ ),
3107+ ),
3108+ ),
3109+ ),
3110+ )
3111+ assertThat(ProtoParser .parse(location, proto)).isEqualTo(expected)
3112+ }
3113+
30693114 @Test fun forbidMultipleSyntaxDefinitions () {
30703115 val proto = """
30713116 | syntax = "proto2";
0 commit comments