@@ -488,7 +488,31 @@ public void testEnum() throws IOException {
488
488
String translation = translateSourceFile (
489
489
"public enum Color { RED, WHITE, BLUE }" ,
490
490
"Color" , "Color.h" );
491
- assertTranslatedLines (translation ,
491
+ assertTranslatedLines (
492
+ translation ,
493
+ "typedef NS_ENUM(jint, Color_Enum) {" ,
494
+ " Color_Enum_RED NS_SWIFT_NAME(red) = 0," ,
495
+ " Color_Enum_WHITE NS_SWIFT_NAME(white) = 1," ,
496
+ " Color_Enum_BLUE NS_SWIFT_NAME(blue) = 2," ,
497
+ "};" );
498
+ assertTranslation (translation , "@interface Color : JavaLangEnum" );
499
+ assertTranslation (translation , "+ (IOSObjectArray *)values;" );
500
+ assertTranslation (translation , "+ (Color *)valueOfWithNSString:(NSString *)name;" );
501
+ assertTranslation (translation , "FOUNDATION_EXPORT Color *Color_values_[];" );
502
+ assertTranslatedLines (
503
+ translation , "inline Color *Color_get_RED(void);" , "J2OBJC_ENUM_CONSTANT(Color, RED)" );
504
+ assertTranslatedLines (
505
+ translation , "inline Color *Color_get_WHITE(void);" , "J2OBJC_ENUM_CONSTANT(Color, WHITE)" );
506
+ assertTranslatedLines (
507
+ translation , "inline Color *Color_get_BLUE(void);" , "J2OBJC_ENUM_CONSTANT(Color, BLUE)" );
508
+ }
509
+
510
+ public void testEnumNoSwiftEnums () throws IOException {
511
+ options .setSwiftEnums (false );
512
+ String translation =
513
+ translateSourceFile ("public enum Color { RED, WHITE, BLUE }" , "Color" , "Color.h" );
514
+ assertTranslatedLines (
515
+ translation ,
492
516
"typedef NS_ENUM(jint, Color_Enum) {" ,
493
517
" Color_Enum_RED = 0," ,
494
518
" Color_Enum_WHITE = 1," ,
@@ -519,9 +543,9 @@ public void testEnumIsImplicitlyNonnullWhenNullMarked() throws IOException {
519
543
assertTranslatedLines (
520
544
translation ,
521
545
"typedef NS_ENUM(jint, Color_Enum) {" ,
522
- " Color_Enum_RED = 0," ,
523
- " Color_Enum_WHITE = 1," ,
524
- " Color_Enum_BLUE = 2," ,
546
+ " Color_Enum_RED NS_SWIFT_NAME(red) = 0," ,
547
+ " Color_Enum_WHITE NS_SWIFT_NAME(white) = 1," ,
548
+ " Color_Enum_BLUE NS_SWIFT_NAME(blue) = 2," ,
525
549
"};" );
526
550
assertTranslation (translation , "FOUNDATION_EXPORT Color *_Nonnull Color_values_[];" );
527
551
assertTranslatedLines (
0 commit comments