From 7ff35f487afde9a93736f120d958810bf9e26883 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 26 Nov 2005 08:37:20 +0000 Subject: [PATCH] Java/C# - test extra constructor to handle enum items initialised by another enum item for %javaconst(1)/%csconst(1) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7868 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/csharp/enum_thorough_runme.cs | 8 +++++++ .../csharp/enum_thorough_simple_runme.cs | 8 +++++++ .../csharp/enum_thorough_typesafe_runme.cs | 8 +++++++ Examples/test-suite/enum_thorough.i | 23 +++++++++++++++++++ .../java/enum_thorough_proper_runme.java | 8 +++++++ .../test-suite/java/enum_thorough_runme.java | 8 +++++++ .../java/enum_thorough_simple_runme.java | 8 +++++++ .../java/enum_thorough_typeunsafe_runme.java | 8 +++++++ 8 files changed, 79 insertions(+) diff --git a/Examples/test-suite/csharp/enum_thorough_runme.cs b/Examples/test-suite/csharp/enum_thorough_runme.cs index 0101785d2..765347e4b 100755 --- a/Examples/test-suite/csharp/enum_thorough_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_runme.cs @@ -358,6 +358,14 @@ public class runme { i.MemberInstance = Instances.memberinstance3; if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed"); } + { + if ((int)enum_thorough.repeatTest(repeat.one) != 1) throw new Exception("repeatTest 1 failed"); + if ((int)enum_thorough.repeatTest(repeat.initial) != 1) throw new Exception("repeatTest 2 failed"); + if ((int)enum_thorough.repeatTest(repeat.two) != 2) throw new Exception("repeatTest 3 failed"); + if ((int)enum_thorough.repeatTest(repeat.three) != 3) throw new Exception("repeatTest 4 failed"); + if ((int)enum_thorough.repeatTest(repeat.last) != 3) throw new Exception("repeatTest 5 failed"); + if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed"); + } } } diff --git a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs index 5b6e13b32..f8556ff37 100644 --- a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs @@ -358,6 +358,14 @@ public class runme { i.MemberInstance = Instances.memberinstance3; if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed"); } + { + if (enum_thorough_simple.repeatTest(enum_thorough_simple.one) != 1) throw new Exception("repeatTest 1 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simple.initial) != 1) throw new Exception("repeatTest 2 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simple.two) != 2) throw new Exception("repeatTest 3 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simple.three) != 3) throw new Exception("repeatTest 4 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simple.last) != 3) throw new Exception("repeatTest 5 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed"); + } } } diff --git a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs index 9bfa7c2c6..dc2a981de 100644 --- a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs @@ -358,6 +358,14 @@ public class runme { i.MemberInstance = Instances.memberinstance3; if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed"); } + { + if (enum_thorough_typesafe.repeatTest(repeat.one).swigValue != 1) throw new Exception("repeatTest 1 failed"); + if (enum_thorough_typesafe.repeatTest(repeat.initial).swigValue != 1) throw new Exception("repeatTest 2 failed"); + if (enum_thorough_typesafe.repeatTest(repeat.two).swigValue != 2) throw new Exception("repeatTest 3 failed"); + if (enum_thorough_typesafe.repeatTest(repeat.three).swigValue != 3) throw new Exception("repeatTest 4 failed"); + if (enum_thorough_typesafe.repeatTest(repeat.last).swigValue != 3) throw new Exception("repeatTest 5 failed"); + if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed"); + } } } diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i index 3fe737d89..cf3472a64 100644 --- a/Examples/test-suite/enum_thorough.i +++ b/Examples/test-suite/enum_thorough.i @@ -474,4 +474,27 @@ struct Instances { %} +// Repeated values +#if defined(SWIGJAVA) +%javaconst(1); +#elif defined(SWIGCSHARP) +%csconst(1); +#endif + +%inline %{ +namespace RepeatSpace { +typedef enum +{ + one = 1, + initial = one, + two, + three, + last = three, + end = last +} repeat; +repeat repeatTest(repeat e) { return e; } +} + +%} + diff --git a/Examples/test-suite/java/enum_thorough_proper_runme.java b/Examples/test-suite/java/enum_thorough_proper_runme.java index 28431f21d..243d3bddd 100644 --- a/Examples/test-suite/java/enum_thorough_proper_runme.java +++ b/Examples/test-suite/java/enum_thorough_proper_runme.java @@ -369,6 +369,14 @@ public class enum_thorough_proper_runme { i.setMemberInstance(Instances.memberinstance3); if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed"); } + { + if (enum_thorough_proper.repeatTest(repeat.one).swigValue() != 1) throw new RuntimeException("repeatTest 1 failed"); + if (enum_thorough_proper.repeatTest(repeat.initial).swigValue() != 1) throw new RuntimeException("repeatTest 2 failed"); + if (enum_thorough_proper.repeatTest(repeat.two).swigValue() != 2) throw new RuntimeException("repeatTest 3 failed"); + if (enum_thorough_proper.repeatTest(repeat.three).swigValue() != 3) throw new RuntimeException("repeatTest 4 failed"); + if (enum_thorough_proper.repeatTest(repeat.last).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed"); + if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed"); + } } } diff --git a/Examples/test-suite/java/enum_thorough_runme.java b/Examples/test-suite/java/enum_thorough_runme.java index bf4ecd367..1cd02d38d 100644 --- a/Examples/test-suite/java/enum_thorough_runme.java +++ b/Examples/test-suite/java/enum_thorough_runme.java @@ -369,6 +369,14 @@ public class enum_thorough_runme { i.setMemberInstance(Instances.memberinstance3); if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed"); } + { + if (enum_thorough.repeatTest(repeat.one).swigValue() != 1) throw new RuntimeException("repeatTest 1 failed"); + if (enum_thorough.repeatTest(repeat.initial).swigValue() != 1) throw new RuntimeException("repeatTest 2 failed"); + if (enum_thorough.repeatTest(repeat.two).swigValue() != 2) throw new RuntimeException("repeatTest 3 failed"); + if (enum_thorough.repeatTest(repeat.three).swigValue() != 3) throw new RuntimeException("repeatTest 4 failed"); + if (enum_thorough.repeatTest(repeat.last).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed"); + if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed"); + } } } diff --git a/Examples/test-suite/java/enum_thorough_simple_runme.java b/Examples/test-suite/java/enum_thorough_simple_runme.java index d4c26207d..9bd56273e 100644 --- a/Examples/test-suite/java/enum_thorough_simple_runme.java +++ b/Examples/test-suite/java/enum_thorough_simple_runme.java @@ -369,6 +369,14 @@ public class enum_thorough_simple_runme { i.setMemberInstance(Instances.memberinstance3); if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed"); } + { + if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.one) != 1) throw new RuntimeException("repeatTest 1 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.initial) != 1) throw new RuntimeException("repeatTest 2 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.two) != 2) throw new RuntimeException("repeatTest 3 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.three) != 3) throw new RuntimeException("repeatTest 4 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.last) != 3) throw new RuntimeException("repeatTest 5 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed"); + } } } diff --git a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java index 3eb54b416..35d1a1937 100644 --- a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java +++ b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java @@ -369,6 +369,14 @@ public class enum_thorough_typeunsafe_runme { i.setMemberInstance(Instances.memberinstance3); if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed"); } + { + if (enum_thorough_typeunsafe.repeatTest(repeat.one) != 1) throw new RuntimeException("repeatTest 1 failed"); + if (enum_thorough_typeunsafe.repeatTest(repeat.initial) != 1) throw new RuntimeException("repeatTest 2 failed"); + if (enum_thorough_typeunsafe.repeatTest(repeat.two) != 2) throw new RuntimeException("repeatTest 3 failed"); + if (enum_thorough_typeunsafe.repeatTest(repeat.three) != 3) throw new RuntimeException("repeatTest 4 failed"); + if (enum_thorough_typeunsafe.repeatTest(repeat.last) != 3) throw new RuntimeException("repeatTest 5 failed"); + if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed"); + } } }