From 9e53432aef08b9903e6bfc6b25e5eebbe8373f3d Mon Sep 17 00:00:00 2001 From: Jiulong Wang Date: Wed, 14 Sep 2016 22:41:02 -0700 Subject: [PATCH] Add more test case for char const expression in enum --- .../test-suite/csharp/enum_thorough_typesafe_runme.cs | 4 ++++ Examples/test-suite/enum_thorough.i | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs index a23d3b370..82c52a31f 100644 --- a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs @@ -405,6 +405,10 @@ public class runme { if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed"); if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed"); } + { + if (enum_thorough_typesafe.enumWithMacroTest(enumWithMacro.ABCD).swigValue != (('A' << 24) | ('B' << 16) | ('C' << 8) | 'D')) throw new Exception("enumWithMacroTest 1 failed"); + if (enum_thorough_typesafe.enumWithMacroTest(enumWithMacro.ABCD2).swigValue != enum_thorough_typesafe.enumWithMacroTest(enumWithMacro.ABCD).swigValue) throw new Exception("enumWithMacroTest 2 failed"); + } // different types { if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeint).swigValue != 10) throw new Exception("differentTypes 1 failed"); diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i index 9007a6957..3beefccc0 100644 --- a/Examples/test-suite/enum_thorough.i +++ b/Examples/test-suite/enum_thorough.i @@ -569,6 +569,17 @@ repeat repeatTest(repeat e) { return e; } } %} +%inline %{ +namespace EnumWithMacro { +#define PACK(C1,C2,C3,C4) ((C1<<24)|(C2<<16)|(C3<<8)|C4) +typedef enum { + ABCD = PACK('A','B','C','D'), + ABCD2 = ABCD +} enumWithMacro; +enumWithMacro enumWithMacroTest(enumWithMacro e) { return e; } +} +%} + %inline %{ namespace DifferentSpace { enum DifferentTypes {