@@ -469,6 +469,52 @@ func TestQuotedStrings(t *testing.T) {
469469 }
470470}
471471
472+ func TestBitFieldOfStringFailure (t * testing.T ) {
473+ input := `package test
474+ // This is a pre-enum comment that needs (to be handled properly)
475+ // ENUM(
476+ // abc
477+ // ghi
478+ //). This is an extra string comment (With parentheses of it's own)
479+ // And (another line) with Parentheses
480+ type Animal string
481+ `
482+ g := NewGenerator (WithBitfield ())
483+ f , err := parser .ParseFile (g .fileSet , "TestRequiredErrors" , input , parser .ParseComments )
484+ assert .Nil (t , err , "Error parsing input" )
485+
486+ enums := g .inspect (f )
487+ output , err := g .parseEnum (enums ["Animal" ])
488+ assert .ErrorContains (t , err , "bitfield option is not allowed on string types" )
489+ assert .Empty (t , output )
490+ if false { // Debugging statement
491+ fmt .Println (output )
492+ }
493+ }
494+
495+ func TestBitFieldManuallyValueFailure (t * testing.T ) {
496+ input := `package test
497+ // This is a pre-enum comment that needs (to be handled properly)
498+ // ENUM(
499+ // abc = 1
500+ // ghi
501+ //). This is an extra string comment (With parentheses of it's own)
502+ // And (another line) with Parentheses
503+ type Animal int
504+ `
505+ g := NewGenerator (WithBitfield ())
506+ f , err := parser .ParseFile (g .fileSet , "TestRequiredErrors" , input , parser .ParseComments )
507+ assert .Nil (t , err , "Error parsing input" )
508+
509+ enums := g .inspect (f )
510+ output , err := g .parseEnum (enums ["Animal" ])
511+ assert .ErrorContains (t , err , "manually setting values is not allowed with the bitfield option" )
512+ assert .Empty (t , output )
513+ if false { // Debugging statement
514+ fmt .Println (output )
515+ }
516+ }
517+
472518func TestStringWithSingleDoubleQuoteValue (t * testing.T ) {
473519 input := `package test
474520 // ENUM(DoubleQuote='"')
0 commit comments