Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
#######################################################################
# Makefile for C# test-suite
#######################################################################
LANGUAGE = csharp
SCRIPTSUFFIX = _runme.cs
CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@
CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
CSHARPCONVERTPATH = @top_srcdir@/@CSHARPCONVERTPATH@
srcdir = @srcdir@
top_srcdir = ../@top_srcdir@
top_builddir = ../@top_builddir@
CPP_TEST_CASES = \
csharp_attributes \
csharp_swig2_compatibility \
csharp_exceptions \
csharp_features \
csharp_lib_arrays \
csharp_namespace_system_collision \
csharp_prepost \
csharp_typemaps \
enum_thorough_simple \
enum_thorough_typesafe \
exception_partial_info \
intermediary_classname \
li_boost_intrusive_ptr
CPP11_TEST_CASES = \
cpp11_strongly_typed_enumerations_simple \
include $(srcdir)/../common.mk
# Overridden variables here
SRCDIR = ../$(srcdir)/
SWIGOPT += -namespace $*Namespace
CSHARPFLAGSSPECIAL =
# Custom tests - tests with additional commandline options
intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname
csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe
csharp_swig2_compatibility.cpptest: SWIGOPT += -DSWIG2_CSHARP
# Rules for the different types of tests
%.cpptest:
$(setup)
+(cd $* && $(swig_and_compile_cpp))
+$(run_testcase)
%.ctest:
$(setup)
+(cd $* && $(swig_and_compile_c))
+$(run_testcase)
%.multicpptest:
$(setup)
+(cd $* && $(swig_and_compile_multi_cpp))
+$(run_testcase)
# Makes a directory for the testcase if it does not exist
setup = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
else \
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
fi; \
if [ ! -d $* ]; then \
mkdir $*; \
fi
# Compiles C# files then runs the testcase. A testcase is only run if
# a file is found which has _runme.cs appended after the testcase name.
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
# DYLD_FALLBACK_LIBRARY_PATH is cleared for Mac OS X.
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCONVERTPATH) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCONVERTPATH) "{}" \+`' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$*_runme.exe; \
else \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
CSHARPSRCS='`find . -name "*.cs" -exec ../$(CSHARPCONVERTPATH) "{}" \+`' csharp_compile; \
fi
# Clean: remove testcase directories
%.clean:
@if [ -d $* ]; then \
rm -rf $*; \
fi
clean:
@rm -f *.exe *.exe.mdb

View File

@@ -0,0 +1,42 @@
SWIG testsuite README file
--------------------------
This testsuite is here to ensure SWIG can handle a wide range of c/c++
syntax. The testsuite comprises many testcases in this directory. Each
test case is tested under each of the language modules thereby
thoroughly testing all of SWIG. It ensures that each of the language
modules are at a similar standard.
Those modules that support shadow classes run the tests producing
shadow classes to test the full language module functionality.
Some test cases need a runtime test. These need implementing in each
of the language modules. The language modules look for a file in the
language specific test-suite directory which has _runme appended after
the testcase name. If one is found it will be run as part of the test.
Some language modules add to this common set of test cases for
language specific tests. These can be found in the appropriate
language test-suite directory. There is also a README in each of the
language module directories.
For each testcase a message showing which testcase is being tested is
displayed. Nothing else is printed unless the test fails.
Some Developer Guidelines
-------------------------
Note that the whole test suite need not be run each time a testcase is
modified. An individual testcase may be run by going to the language
module test-suite directory and using make testcasename.xxx where xxx
is the type of test (eg cpptest). See common.mk. make -s doesn't print
any junk on the screen and is useful for emulating the way make check
works from the SWIG root directory.
If there are runtime tests needed, don't print anything unless there
is an error in which case stderr is suggested.
Please set the name of the module to the same name as the testcase,
otherwise modules will not be found.

View File

@@ -0,0 +1,28 @@
using System;
using aggregateNamespace;
public class runme {
static void Main() {
// Confirm that move() returns correct results under normal use
int result = aggregate.move(aggregate.UP);
if (result != aggregate.UP) throw new Exception("UP failed");
result = aggregate.move(aggregate.DOWN);
if (result != aggregate.DOWN) throw new Exception("DOWN failed");
result = aggregate.move(aggregate.LEFT);
if (result != aggregate.LEFT) throw new Exception("LEFT failed");
result = aggregate.move(aggregate.RIGHT);
if (result != aggregate.RIGHT) throw new Exception("RIGHT failed");
// Confirm that move() raises an exception when the contract is violated
try {
aggregate.move(0);
throw new Exception("0 test failed");
}
catch (ArgumentOutOfRangeException) {
}
}
}

View File

@@ -0,0 +1,71 @@
using System;
using allprotectedNamespace;
public class runme
{
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
MyProtectedBase mpb = new MyProtectedBase("MyProtectedBase");
mpb.accessProtected();
}
}
class MyProtectedBase : ProtectedBase
{
public MyProtectedBase(string name) : base(name) {
}
public void accessProtected() {
string s = virtualMethod();
if (s != "ProtectedBase")
throw new Exception("Failed");
Klass k = instanceMethod(new Klass("xyz"));
if (k.getName() != "xyz")
throw new Exception("Failed");
k = instanceOverloaded(new Klass("xyz"));
if (k.getName() != "xyz")
throw new Exception("Failed");
k = instanceOverloaded(new Klass("xyz"), "abc");
if (k.getName() != "abc")
throw new Exception("Failed");
k = ProtectedBase.staticMethod(new Klass("abc"));
if (k.getName() != "abc")
throw new Exception("Failed");
k = ProtectedBase.staticOverloaded(new Klass("xyz"));
if (k.getName() != "xyz")
throw new Exception("Failed");
k = ProtectedBase.staticOverloaded(new Klass("xyz"), "abc");
if (k.getName() != "abc")
throw new Exception("Failed");
instanceMemberVariable = 30;
int i = instanceMemberVariable;
if (i != 30)
throw new Exception("Failed");
staticMemberVariable = 40;
i = staticMemberVariable;
if (i != 40)
throw new Exception("Failed");
i = staticConstMemberVariable;
if (i != 20)
throw new Exception("Failed");
anEnum = ProtectedBase.AnEnum.EnumVal1;
ProtectedBase.AnEnum ae = anEnum;
if (ae != ProtectedBase.AnEnum.EnumVal1)
throw new Exception("Failed");
}
}

View File

@@ -0,0 +1,16 @@
using System;
using apply_stringsNamespace;
public class apply_strings_runme {
private static string TEST_MESSAGE = "A message from target language to the C++ world and back again.";
public static void Main() {
if (apply_strings.UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed");
if (apply_strings.SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed");
SWIGTYPE_p_char pChar = apply_strings.CharFunction(null);
if (pChar != null) throw new Exception("CharFunction failed");
}
}

View File

@@ -0,0 +1,29 @@
// This is the bool runtime testcase. It checks that the C++ bool type works.
using System;
using boolsNamespace;
public class bools_runme {
public static void Main() {
bool t = true;
bool f = false;
check_bo(f);
check_bo(t);
}
public static void check_bo(bool input) {
for( int i=0; i<1000; i++ ) {
if( bools.bo(input) != input ) {
string ErrorMessage = "Runtime test check_bo failed.";
throw new Exception(ErrorMessage);
}
}
}
}

View File

@@ -0,0 +1,66 @@
using System;
using catchesNamespace;
public class runme {
static void Main() {
// test_catches()
try {
catches.test_catches(1);
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "C++ int exception thrown, value: 1")
throw new ApplicationException("bad exception order: " + e.Message);
}
try {
catches.test_catches(2);
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "two")
throw new ApplicationException("bad exception order: " + e.Message);
}
try {
catches.test_catches(3);
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "C++ ThreeException const & exception thrown")
throw new ApplicationException("bad exception order: " + e.Message);
}
// test_exception_specification()
try {
catches.test_exception_specification(1);
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "C++ int exception thrown, value: 1")
throw new ApplicationException("bad exception order: " + e.Message);
}
try {
catches.test_exception_specification(2);
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "unknown exception")
throw new ApplicationException("bad exception order: " + e.Message);
}
try {
catches.test_exception_specification(3);
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "unknown exception")
throw new ApplicationException("bad exception order: " + e.Message);
}
// test_catches_all()
try {
catches.test_catches_all(1);
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "unknown exception")
throw new ApplicationException("bad exception order: " + e.Message);
}
}
}

View File

@@ -0,0 +1,155 @@
using System;
using char_stringsNamespace;
public class char_strings_runme {
private static string CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
private static string OTHERLAND_MSG = "Little message from the safe world.";
public static void Main() {
uint count = 10000;
uint i = 0;
// get functions
for (i=0; i<count; i++) {
string str = char_strings.GetCharHeapString();
if (str != CPLUSPLUS_MSG)
throw new Exception("Test char get 1 failed, iteration " + i);
char_strings.DeleteCharHeapString();
}
for (i=0; i<count; i++) {
string str = char_strings.GetConstCharProgramCodeString();
if (str != CPLUSPLUS_MSG)
throw new Exception("Test char get 2 failed, iteration " + i);
char_strings.DeleteCharHeapString();
}
for (i=0; i<count; i++) {
string str = char_strings.GetCharStaticString();
if (str != CPLUSPLUS_MSG)
throw new Exception("Test char get 3 failed, iteration " + i);
}
for (i=0; i<count; i++) {
string str = char_strings.GetCharStaticStringFixed();
if (str != CPLUSPLUS_MSG)
throw new Exception("Test char get 4 failed, iteration " + i);
}
for (i=0; i<count; i++) {
string str = char_strings.GetConstCharStaticStringFixed();
if (str != CPLUSPLUS_MSG)
throw new Exception("Test char get 5 failed, iteration " + i);
}
// set functions
for (i=0; i<count; i++) {
if (!char_strings.SetCharHeapString(OTHERLAND_MSG + i, i))
throw new Exception("Test char set 1 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (!char_strings.SetCharStaticString(OTHERLAND_MSG + i, i))
throw new Exception("Test char set 2 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (!char_strings.SetCharArrayStaticString(OTHERLAND_MSG + i, i))
throw new Exception("Test char set 3 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (!char_strings.SetConstCharHeapString(OTHERLAND_MSG + i, i))
throw new Exception("Test char set 4 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (!char_strings.SetConstCharStaticString(OTHERLAND_MSG + i, i))
throw new Exception("Test char set 5 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (!char_strings.SetConstCharArrayStaticString(OTHERLAND_MSG + i, i))
throw new Exception("Test char set 6 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (!char_strings.SetCharConstStaticString(OTHERLAND_MSG + i, i))
throw new Exception("Test char set 7 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (!char_strings.SetConstCharConstStaticString(OTHERLAND_MSG + i, i))
throw new Exception("Test char set 8 failed, iteration " + i);
}
// get set function
for (i=0; i<count*10; i++) {
string ping = OTHERLAND_MSG + i;
string pong = char_strings.CharPingPong(ping);
if (ping != pong)
throw new Exception("Test PingPong 1 failed.\nExpected:" + ping + "\nReceived:" + pong);
}
// variables
for (i=0; i<count; i++) {
char_strings.global_char = OTHERLAND_MSG + i;
if (char_strings.global_char != OTHERLAND_MSG + i)
throw new Exception("Test variables 1 failed, iteration " + i);
}
for (i=0; i<count; i++) {
char_strings.global_char_array1 = OTHERLAND_MSG + i;
if (char_strings.global_char_array1 != OTHERLAND_MSG + i)
throw new Exception("Test variables 2 failed, iteration " + i);
}
for (i=0; i<count; i++) {
char_strings.global_char_array2 = OTHERLAND_MSG + i;
if (char_strings.global_char_array2 != OTHERLAND_MSG + i)
throw new Exception("Test variables 3 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (char_strings.global_const_char != CPLUSPLUS_MSG)
throw new Exception("Test variables 4 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (char_strings.global_const_char_array1 != CPLUSPLUS_MSG)
throw new Exception("Test variables 5 failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (char_strings.global_const_char_array2 != CPLUSPLUS_MSG)
throw new Exception("Test variables 6 failed, iteration " + i);
}
// char *& tests
for (i=0; i<count; i++) {
String str = char_strings.GetCharPointerRef();
if (str != CPLUSPLUS_MSG)
throw new Exception("Test char pointer ref get failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (!char_strings.SetCharPointerRef(OTHERLAND_MSG + i, i))
throw new Exception("Test char pointer ref set failed, iteration " + i);
}
for (i=0; i<count; i++) {
String str = char_strings.GetConstCharPointerRef();
if (str != CPLUSPLUS_MSG)
throw new Exception("Test const char pointer ref get failed, iteration " + i);
}
for (i=0; i<count; i++) {
if (!char_strings.SetConstCharPointerRef(OTHERLAND_MSG + i, i))
throw new Exception("Test const char pointer ref set failed, iteration " + i);
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using constoverNamespace;
public class runme
{
static void Main()
{
string p = constover.test("test");
if ( p != "test" )
throw new Exception( "test failed!" );
p = constover.test_pconst("test");
if ( p != "test_pconst" )
throw new Exception( "test_pconst failed!" );
Foo f = new Foo();
p = f.test("test");
if ( p != "test" )
throw new Exception( "member-test failed!" );
p = f.test_pconst("test");
if ( p != "test_pconst" )
throw new Exception( "member-test_pconst failed!" );
p = f.test_constm("test");
if ( p != "test_constmethod" )
throw new Exception( "member-test_constm failed!" );
p = f.test_pconstm("test");
if ( p != "test_pconstmethod" )
throw new Exception( "member-test_pconstm failed!" );
}
}

View File

@@ -0,0 +1,82 @@
// This test tests all the methods in the C# collection wrapper
using System;
using cpp11_li_std_arrayNamespace;
public class cpp11_li_std_array_runme
{
private static ArrayInt6 ToArray6(int[] a)
{
if (a.Length != 6)
throw new Exception("a is incorrect size");
return new ArrayInt6(a);
}
private static void compareContainers(ArrayInt6 actual, int[] expected)
{
if (actual.Count != expected.Length)
throw new Exception("Sizes are different: " + actual.Count + " " + expected.Length);
for (int i=0; i<actual.Count; ++i)
{
int actualValue = actual[i];
int expectedValue = expected[i];
if (actualValue != expectedValue)
throw new Exception("Value is wrong for element " + i + ". Expected " + expectedValue + " got: " + actualValue);
}
if (actual.IsEmpty)
throw new Exception("ai should not be empty");
}
static void Main()
{
ArrayInt6 ai = new ArrayInt6();
compareContainers(ai, new int[] { 0, 0, 0, 0, 0, 0 });
int[] vals = { 10, 20, 30, 40, 50, 60 };
for (int i = 0; i < ai.Count; ++i)
ai[i] = vals[i];
compareContainers(ai, vals);
// Check return
compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] { -2, -1, 0, 0, 1, 2 });
compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] { -2, -1, 0, 0, 1, 2 });
// Check passing arguments
ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
cpp11_li_std_array.arrayInRef(ai);
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 }));
cpp11_li_std_array.arrayInPtr(ai);
compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 });
// fill
ai.Fill(111);
compareContainers(ai, new int[] { 111, 111, 111, 111, 111, 111 });
// out of range errors
try
{
ai[ai.Count] = 0;
throw new Exception("Out of range exception not caught");
}
catch (ArgumentOutOfRangeException)
{
}
try
{
ai[-1] = 0;
throw new Exception("Out of range exception not caught");
}
catch (ArgumentOutOfRangeException)
{
}
}
}

View File

@@ -0,0 +1,169 @@
using System;
using cpp11_strongly_typed_enumerationsNamespace;
public class cpp11_strongly_typed_enumerations_runme {
public static int enumCheck(int actual, int expected) {
if (actual != expected)
throw new ApplicationException("Enum value mismatch. Expected " + expected + " Actual: " + actual);
return expected + 1;
}
public static void Main() {
int val = 0;
val = enumCheck((int)Enum1.Val1, val);
val = enumCheck((int)Enum1.Val2, val);
val = enumCheck((int)Enum1.Val3, 13);
val = enumCheck((int)Enum1.Val4, val);
val = enumCheck((int)Enum1.Val5a, 13);
val = enumCheck((int)Enum1.Val6a, val);
val = 0;
val = enumCheck((int)Enum2.Val1, val);
val = enumCheck((int)Enum2.Val2, val);
val = enumCheck((int)Enum2.Val3, 23);
val = enumCheck((int)Enum2.Val4, val);
val = enumCheck((int)Enum2.Val5b, 23);
val = enumCheck((int)Enum2.Val6b, val);
val = 0;
val = enumCheck((int)Enum4.Val1, val);
val = enumCheck((int)Enum4.Val2, val);
val = enumCheck((int)Enum4.Val3, 43);
val = enumCheck((int)Enum4.Val4, val);
val = 0;
val = enumCheck((int)Enum5.Val1, val);
val = enumCheck((int)Enum5.Val2, val);
val = enumCheck((int)Enum5.Val3, 53);
val = enumCheck((int)Enum5.Val4, val);
val = 0;
val = enumCheck((int)Enum6.Val1, val);
val = enumCheck((int)Enum6.Val2, val);
val = enumCheck((int)Enum6.Val3, 63);
val = enumCheck((int)Enum6.Val4, val);
val = 0;
val = enumCheck((int)Enum7td.Val1, val);
val = enumCheck((int)Enum7td.Val2, val);
val = enumCheck((int)Enum7td.Val3, 73);
val = enumCheck((int)Enum7td.Val4, val);
val = 0;
val = enumCheck((int)Enum8.Val1, val);
val = enumCheck((int)Enum8.Val2, val);
val = enumCheck((int)Enum8.Val3, 83);
val = enumCheck((int)Enum8.Val4, val);
val = 0;
val = enumCheck((int)Enum10.Val1, val);
val = enumCheck((int)Enum10.Val2, val);
val = enumCheck((int)Enum10.Val3, 103);
val = enumCheck((int)Enum10.Val4, val);
val = 0;
val = enumCheck((int)Class1.Enum12.Val1, 1121);
val = enumCheck((int)Class1.Enum12.Val2, 1122);
val = enumCheck((int)Class1.Enum12.Val3, val);
val = enumCheck((int)Class1.Enum12.Val4, val);
val = enumCheck((int)Class1.Enum12.Val5c, 1121);
val = enumCheck((int)Class1.Enum12.Val6c, val);
val = 0;
val = enumCheck((int)Class1.Enum13.Val1, 1131);
val = enumCheck((int)Class1.Enum13.Val2, 1132);
val = enumCheck((int)Class1.Enum13.Val3, val);
val = enumCheck((int)Class1.Enum13.Val4, val);
val = enumCheck((int)Class1.Enum13.Val5d, 1131);
val = enumCheck((int)Class1.Enum13.Val6d, val);
val = 0;
val = enumCheck((int)Class1.Enum14.Val1, 1141);
val = enumCheck((int)Class1.Enum14.Val2, 1142);
val = enumCheck((int)Class1.Enum14.Val3, val);
val = enumCheck((int)Class1.Enum14.Val4, val);
val = enumCheck((int)Class1.Enum14.Val5e, 1141);
val = enumCheck((int)Class1.Enum14.Val6e, val);
val = 0;
val = enumCheck((int)Class1.Struct1.Enum12.Val1, 3121);
val = enumCheck((int)Class1.Struct1.Enum12.Val2, 3122);
val = enumCheck((int)Class1.Struct1.Enum12.Val3, val);
val = enumCheck((int)Class1.Struct1.Enum12.Val4, val);
val = enumCheck((int)Class1.Struct1.Enum12.Val5f, 3121);
val = enumCheck((int)Class1.Struct1.Enum12.Val6f, val);
val = 0;
val = enumCheck((int)Class1.Struct1.Enum13.Val1, 3131);
val = enumCheck((int)Class1.Struct1.Enum13.Val2, 3132);
val = enumCheck((int)Class1.Struct1.Enum13.Val3, val);
val = enumCheck((int)Class1.Struct1.Enum13.Val4, val);
val = 0;
val = enumCheck((int)Class1.Struct1.Enum14.Val1, 3141);
val = enumCheck((int)Class1.Struct1.Enum14.Val2, 3142);
val = enumCheck((int)Class1.Struct1.Enum14.Val3, val);
val = enumCheck((int)Class1.Struct1.Enum14.Val4, val);
val = enumCheck((int)Class1.Struct1.Enum14.Val5g, 3141);
val = enumCheck((int)Class1.Struct1.Enum14.Val6g, val);
val = 0;
val = enumCheck((int)Class2.Enum12.Val1, 2121);
val = enumCheck((int)Class2.Enum12.Val2, 2122);
val = enumCheck((int)Class2.Enum12.Val3, val);
val = enumCheck((int)Class2.Enum12.Val4, val);
val = enumCheck((int)Class2.Enum12.Val5h, 2121);
val = enumCheck((int)Class2.Enum12.Val6h, val);
val = 0;
val = enumCheck((int)Class2.Enum13.Val1, 2131);
val = enumCheck((int)Class2.Enum13.Val2, 2132);
val = enumCheck((int)Class2.Enum13.Val3, val);
val = enumCheck((int)Class2.Enum13.Val4, val);
val = enumCheck((int)Class2.Enum13.Val5i, 2131);
val = enumCheck((int)Class2.Enum13.Val6i, val);
val = 0;
val = enumCheck((int)Class2.Enum14.Val1, 2141);
val = enumCheck((int)Class2.Enum14.Val2, 2142);
val = enumCheck((int)Class2.Enum14.Val3, val);
val = enumCheck((int)Class2.Enum14.Val4, val);
val = enumCheck((int)Class2.Enum14.Val5j, 2141);
val = enumCheck((int)Class2.Enum14.Val6j, val);
val = 0;
val = enumCheck((int)Class2.Struct1.Enum12.Val1, 4121);
val = enumCheck((int)Class2.Struct1.Enum12.Val2, 4122);
val = enumCheck((int)Class2.Struct1.Enum12.Val3, val);
val = enumCheck((int)Class2.Struct1.Enum12.Val4, val);
val = enumCheck((int)Class2.Struct1.Enum12.Val5k, 4121);
val = enumCheck((int)Class2.Struct1.Enum12.Val6k, val);
val = 0;
val = enumCheck((int)Class2.Struct1.Enum13.Val1, 4131);
val = enumCheck((int)Class2.Struct1.Enum13.Val2, 4132);
val = enumCheck((int)Class2.Struct1.Enum13.Val3, val);
val = enumCheck((int)Class2.Struct1.Enum13.Val4, val);
val = enumCheck((int)Class2.Struct1.Enum13.Val5l, 4131);
val = enumCheck((int)Class2.Struct1.Enum13.Val6l, val);
val = 0;
val = enumCheck((int)Class2.Struct1.Enum14.Val1, 4141);
val = enumCheck((int)Class2.Struct1.Enum14.Val2, 4142);
val = enumCheck((int)Class2.Struct1.Enum14.Val3, val);
val = enumCheck((int)Class2.Struct1.Enum14.Val4, val);
val = enumCheck((int)Class2.Struct1.Enum14.Val5m, 4141);
val = enumCheck((int)Class2.Struct1.Enum14.Val6m, val);
Class1 class1 = new Class1();
enumCheck((int)class1.class1Test1(Enum1.Val5a), 13);
enumCheck((int)class1.class1Test2(Class1.Enum12.Val5c), 1121);
enumCheck((int)class1.class1Test3(Class1.Struct1.Enum12.Val5f), 3121);
enumCheck((int)cpp11_strongly_typed_enumerations.globalTest1(Enum1.Val5a), 13);
enumCheck((int)cpp11_strongly_typed_enumerations.globalTest2(Class1.Enum12.Val5c), 1121);
enumCheck((int)cpp11_strongly_typed_enumerations.globalTest3(Class1.Struct1.Enum12.Val5f), 3121);
}
}

View File

@@ -0,0 +1,266 @@
using System;
using System.Reflection;
using System.ComponentModel;
using csharp_attributesNamespace;
public class runme
{
static void Main()
{
// Custom attributes typemap tests
//
// cstype typemap attributechecks
//
// Global function cstype typemap attributes check
Type globaltype = typeof(csharp_attributes);
{
MethodInfo member = (MethodInfo)globaltype.GetMember("GlobalFunction")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
throw new Exception("No IntOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
if (parameter.Name != "myInt")
throw new Exception("Incorrect parameter name");
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntInAttribute))
throw new Exception("Expecting IntIn attribute");
}
// Constant - cstype typemap attributes check
{
MemberInfo member = (MemberInfo)globaltype.GetMember("TESTMACRO")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
throw new Exception("No IntOut attribute for " + member.Name);
}
// Non-static method cstype typemap attributes check
Type type = typeof(Stations);
{
MethodInfo member = (MethodInfo)type.GetMember("Reading")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
throw new Exception("No IntOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
if (parameter.Name != "myInt")
throw new Exception("Incorrect parameter name");
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntInAttribute))
throw new Exception("Expecting IntIn attribute");
}
// Static method cstype typemap attributes check
{
MethodInfo member = (MethodInfo)type.GetMember("Swindon")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
throw new Exception("No IntOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
if (parameter.Name != "myInt")
throw new Exception("Incorrect parameter name");
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntInAttribute))
throw new Exception("Expecting IntIn attribute");
}
// Constructor cstype typemap attributes check
{
ConstructorInfo member = (ConstructorInfo)type.GetConstructors()[0];
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
if (parameter.Name != "myInt")
throw new Exception("Incorrect parameter name");
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntInAttribute))
throw new Exception("Expecting IntIn attribute");
}
//
// imtype typemap attributechecks
//
// Global function imtype typemap attributes check
Type imclasstype = typeof(csharp_attributesPINVOKE);
{
MethodInfo member = (MethodInfo)imclasstype.GetMember("GlobalFunction")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
throw new Exception("No IntegerOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // checking 1st parameter
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntegerInAttribute))
throw new Exception("Expecting IntegerIn attribute");
}
// Constant - imtype typemap attributes check
{
MethodInfo member = (MethodInfo)imclasstype.GetMember("TESTMACRO_get")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
throw new Exception("No IntegerOut attribute for " + member.Name);
}
// Non-static method imtype typemap attributes check
{
MethodInfo member = (MethodInfo)imclasstype.GetMember("Stations_Reading")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
throw new Exception("No IntegerOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[1]; // checking 2nd parameter
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntegerInAttribute))
throw new Exception("Expecting IntegerIn attribute");
}
// Static method imtype typemap attributes check
{
MethodInfo member = (MethodInfo)imclasstype.GetMember("Stations_Swindon")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
throw new Exception("No IntegerOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // checking 1st parameter
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntegerInAttribute))
throw new Exception("Expecting IntegerIn attribute");
}
//
// attributes feature
//
Type moretype = typeof(MoreStations);
// Constructor attributes feature check
{
ConstructorInfo member = (ConstructorInfo)moretype.GetConstructors()[0];
if (Attribute.GetCustomAttribute(member, typeof(InterCity1Attribute)) == null)
throw new Exception("MoreStations::MoreStations attribute failed");
}
// Non-static method attributes feature check
{
MethodInfo member = (MethodInfo)moretype.GetMember("Chippenham")[0];
if (Attribute.GetCustomAttribute(member, typeof(InterCity2Attribute)) == null)
throw new Exception("MoreStations::Chippenham attribute failed");
}
// Static method attributes feature check
{
MethodInfo member = (MethodInfo)moretype.GetMember("Bath")[0];
if (Attribute.GetCustomAttribute(member, typeof(InterCity3Attribute)) == null)
throw new Exception("MoreStations::Bath attribute failed");
}
// Non-static member variable attributes feature check
{
PropertyInfo member = (PropertyInfo)moretype.GetProperty("Bristol");
if (Attribute.GetCustomAttribute(member, typeof(InterCity4Attribute)) == null)
throw new Exception("MoreStations::Bristol attribute failed");
}
// Static member variable attributes feature check
{
PropertyInfo member = (PropertyInfo)moretype.GetProperty("WestonSuperMare");
if (Attribute.GetCustomAttribute(member, typeof(InterCity5Attribute)) == null)
throw new Exception("MoreStations::Bristol attribute failed");
}
// Global function attributes feature check
{
MethodInfo member = (MethodInfo)globaltype.GetMember("Paddington")[0];
if (Attribute.GetCustomAttribute(member, typeof(InterCity7Attribute)) == null)
throw new Exception("MoreStations::Paddington attribute failed");
}
// Global variables attributes feature check
{
PropertyInfo member = (PropertyInfo)globaltype.GetProperty("DidcotParkway");
if (Attribute.GetCustomAttribute(member, typeof(InterCity8Attribute)) == null)
throw new Exception("MoreStations::Paddington attribute failed");
}
//
// csattribute typemaps
//
// Class csattribute typemap
{
Object[] attribs = moretype.GetCustomAttributes(true);
Eurostar1Attribute tgv = (Eurostar1Attribute)attribs[0];
if (tgv == null)
throw new Exception("No attribute for MoreStations");
}
// Nested enum csattribute typemap
{
MemberInfo member = (MemberInfo)moretype.GetMember("Wales")[0];
if (Attribute.GetCustomAttribute(member, typeof(Eurostar2Attribute)) == null)
throw new Exception("No attribute for " + member.Name);
}
// Enum value attributes
Type walesType = typeof(MoreStations.Wales);
{
MemberInfo member = (MemberInfo)walesType.GetMember("Cardiff")[0];
DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute));
if (attribute == null)
throw new Exception("No attribute for " + member.Name);
if (attribute.Description != "Cardiff city station")
throw new Exception("Incorrect attribute value for " + member.Name);
}
{
MemberInfo member = (MemberInfo)walesType.GetMember("Swansea")[0];
DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute));
if (attribute == null)
throw new Exception("No attribute for " + member.Name);
if (attribute.Description != "Swansea city station")
throw new Exception("Incorrect attribute value for " + member.Name);
}
// Enum csattribute typemap
{
Type cymrutype = typeof(Cymru);
Object[] attribs = cymrutype.GetCustomAttributes(true);
Eurostar3Attribute tgv = (Eurostar3Attribute)attribs[0];
if (tgv == null)
throw new Exception("No attribute for Cymru");
}
// No runtime test for directorinattributes and directoroutattributes
}
}
// Custom attribute classes
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class IntInAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class IntOutAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class IntegerInAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class IntegerOutAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity1Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity2Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity3Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity4Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity5Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity6Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity7Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity8Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class Eurostar1Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class Eurostar2Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class Eurostar3Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class ThreadSafeAttribute : Attribute {
public ThreadSafeAttribute(bool safe) {}
public ThreadSafeAttribute() {}
}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class DirectorIntegerOutAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class DirectorIntegerInAttribute : Attribute {}

View File

@@ -0,0 +1,344 @@
using System;
using System.Threading;
using csharp_exceptionsNamespace;
public class runme
{
static void Main()
{
// %exception tests
try {
csharp_exceptions.ThrowByValue();
throw new Exception("ThrowByValue not working");
} catch (DivideByZeroException) {
}
try {
csharp_exceptions.ThrowByReference();
throw new Exception("ThrowByReference not working");
} catch (DivideByZeroException) {
}
// %csnothrowexception
csharp_exceptions.NoThrowException();
csharp_exceptions.NullReference(new Ex("should not throw"));
// exception specifications
bool testFailed = false;
try {
csharp_exceptions.ExceptionSpecificationValue();
testFailed = true;
} catch (ApplicationException) {
}
if (testFailed) throw new Exception("ExceptionSpecificationValue not working");
try {
csharp_exceptions.ExceptionSpecificationReference();
testFailed = true;
} catch (ApplicationException) {
}
if (testFailed) throw new Exception("ExceptionSpecificationReference not working");
try {
csharp_exceptions.ExceptionSpecificationString();
testFailed = true;
} catch (ApplicationException e) {
if (e.Message != "ExceptionSpecificationString") throw new Exception("ExceptionSpecificationString unexpected message: " + e.Message);
}
if (testFailed) throw new Exception("ExceptionSpecificationString not working");
try {
csharp_exceptions.ExceptionSpecificationInteger();
testFailed = true;
} catch (ApplicationException) {
}
if (testFailed) throw new Exception("ExceptionSpecificationInteger not working");
// null reference exceptions
try {
csharp_exceptions.NullReference(null);
throw new Exception("NullReference not working");
} catch (ArgumentNullException) {
}
try {
csharp_exceptions.NullValue(null);
throw new Exception("NullValue not working");
} catch (ArgumentNullException) {
}
// enums
try {
csharp_exceptions.ExceptionSpecificationEnumValue();
testFailed = true;
} catch (ApplicationException) {
}
if (testFailed) throw new Exception("ExceptionSpecificationEnumValue not working");
try {
csharp_exceptions.ExceptionSpecificationEnumReference();
testFailed = true;
} catch (ApplicationException) {
}
if (testFailed) throw new Exception("ExceptionSpecificationEnumReference not working");
// std::string
try {
csharp_exceptions.NullStdStringValue(null);
throw new Exception("NullStdStringValue not working");
} catch (ArgumentNullException) {
}
try {
csharp_exceptions.NullStdStringReference(null);
throw new Exception("NullStdStringReference not working");
} catch (ArgumentNullException) {
}
try {
csharp_exceptions.ExceptionSpecificationStdStringValue();
testFailed = true;
} catch (ApplicationException e) {
if (e.Message != "ExceptionSpecificationStdStringValue") throw new Exception("ExceptionSpecificationStdStringValue unexpected message: " + e.Message);
}
if (testFailed) throw new Exception("ExceptionSpecificationStdStringValue not working");
try {
csharp_exceptions.ExceptionSpecificationStdStringReference();
testFailed = true;
} catch (ApplicationException e) {
if (e.Message != "ExceptionSpecificationStdStringReference") throw new Exception("ExceptionSpecificationStdStringReference unexpected message: " + e.Message);
}
if (testFailed) throw new Exception("ExceptionSpecificationStdStringReference not working");
// Memory leak check (The C++ exception stack was never unwound in the original approach to throwing exceptions from unmanaged code)
try {
csharp_exceptions.MemoryLeakCheck();
throw new Exception("MemoryLeakCheck not working");
} catch (DivideByZeroException) {
}
if (Counter.count != 0) throw new Exception("Memory leaks when throwing exception. count: " + Counter.count);
// test exception pending in the csconstruct typemap
try {
new constructor(null);
throw new Exception("constructor 1 not working");
} catch (ArgumentNullException) {
}
try {
new constructor();
throw new Exception("constructor 2 not working");
} catch (ApplicationException) {
}
// test exception pending in the csout typemaps
try {
csharp_exceptions.ushorttest();
throw new Exception("csout not working");
} catch (IndexOutOfRangeException) {
}
// test exception pending in the csvarout/csvarin typemaps and canthrow attribute in unmanaged code typemaps (1) global variables
// 1) global variables
int numberout = 0;
try {
csharp_exceptions.numberin = -1;
throw new Exception("global csvarin not working");
} catch (IndexOutOfRangeException) {
}
csharp_exceptions.numberin = 5;
if (csharp_exceptions.numberin != 5)
throw new Exception("global numberin not 5");
csharp_exceptions.numberout = 20;
try {
numberout += csharp_exceptions.numberout;
throw new Exception("global csvarout not working");
} catch (IndexOutOfRangeException) {
}
// 2) static member variables
try {
InOutStruct.staticnumberin = -1;
throw new Exception("static csvarin not working");
} catch (IndexOutOfRangeException) {
}
InOutStruct.staticnumberin = 5;
if (InOutStruct.staticnumberin != 5)
throw new Exception("static staticnumberin not 5");
InOutStruct.staticnumberout = 20;
try {
numberout += InOutStruct.staticnumberout;
throw new Exception("static csvarout not working");
} catch (IndexOutOfRangeException) {
}
// 3) member variables
InOutStruct io = new InOutStruct();
try {
io.numberin = -1;
throw new Exception("member csvarin not working");
} catch (IndexOutOfRangeException) {
}
io.numberin = 5;
if (io.numberin != 5)
throw new Exception("member numberin not 5");
io.numberout = 20;
try {
numberout += io.numberout;
throw new Exception("member csvarout not working");
} catch (IndexOutOfRangeException) {
}
// test SWIG_exception macro - it must return from unmanaged code without executing any further unmanaged code
try {
csharp_exceptions.exceptionmacrotest(-1);
throw new Exception("exception macro not working");
} catch (IndexOutOfRangeException) {
}
if (csharp_exceptions.exception_macro_run_flag)
throw new Exception("exceptionmacrotest was executed");
// test all the types of exceptions
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedApplicationException);
throw new Exception("ApplicationException not caught");
} catch (ApplicationException e) {
if (e.Message != "msg") throw new Exception("ApplicationException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArithmeticException);
throw new Exception("ArithmeticException not caught");
} catch (ArithmeticException e) {
if (e.Message != "msg") throw new Exception("ArithmeticException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedDivideByZeroException);
throw new Exception("DivideByZeroException not caught");
} catch (DivideByZeroException e) {
if (e.Message != "msg") throw new Exception("DivideByZeroException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedIndexOutOfRangeException);
throw new Exception("IndexOutOfRangeException not caught");
} catch (IndexOutOfRangeException e) {
if (e.Message != "msg") throw new Exception("IndexOutOfRangeException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedInvalidOperationException);
throw new Exception("InvalidOperationException not caught");
} catch (InvalidOperationException e) {
if (e.Message != "msg") throw new Exception("InvalidOperationException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedIOException);
throw new Exception("IOException not caught");
} catch (System.IO.IOException e) {
if (e.Message != "msg") throw new Exception("IOException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedNullReferenceException);
throw new Exception("NullReferenceException not caught");
} catch (NullReferenceException e) {
if (e.Message != "msg") throw new Exception("NullReferenceException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedOutOfMemoryException);
throw new Exception("OutOfMemoryException not caught");
} catch (OutOfMemoryException e) {
if (e.Message != "msg") throw new Exception("OutOfMemoryException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedOverflowException);
throw new Exception("OverflowException not caught");
} catch (OverflowException e) {
if (e.Message != "msg") throw new Exception("OverflowException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedSystemException);
throw new Exception("SystemException not caught");
} catch (SystemException e) {
if (e.Message != "msg") throw new Exception("SystemException msg incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentException);
throw new Exception("ArgumentException not caught");
} catch (ArgumentException e) {
if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentException msg incorrect");
if (e.ParamName != "parm") throw new Exception("ArgumentException parm incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentNullException);
throw new Exception("ArgumentNullException not caught");
} catch (ArgumentNullException e) {
if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentNullException msg incorrect");
if (e.ParamName != "parm") throw new Exception("ArgumentNullException parm incorrect");
}
try {
csharp_exceptions.check_exception(UnmanagedExceptions.UnmanagedArgumentOutOfRangeException);
throw new Exception("ArgumentOutOfRangeException not caught");
} catch (ArgumentOutOfRangeException e) {
if (e.Message.Replace(CRLF,"\n") != "msg\nParameter name: parm") throw new Exception("ArgumentOutOfRangeException msg incorrect");
if (e.ParamName != "parm") throw new Exception("ArgumentOutOfRangeException parm incorrect");
}
// exceptions in multiple threads test
{
ThrowsClass throwsClass = new ThrowsClass(1234.5678);
const int NUM_THREADS = 8;
Thread[] threads = new Thread[NUM_THREADS];
TestThread[] testThreads = new TestThread[NUM_THREADS];
// invoke the threads
for (int i=0; i<NUM_THREADS; i++) {
testThreads[i] = new TestThread(throwsClass, i);
threads[i] = new Thread(new ThreadStart(testThreads[i].Run));
threads[i].Start();
}
// wait for the threads to finish
for (int i=0; i<NUM_THREADS; i++) {
threads[i].Join();
}
for (int i=0; i<NUM_THREADS; i++) {
if (testThreads[i].Failed) throw new Exception("Test Failed");
}
}
// test inner exceptions
try {
csharp_exceptions.InnerExceptionTest();
throw new Exception("InnerExceptionTest exception not caught");
} catch (InvalidOperationException e) {
if (e.Message != "My OuterException message") throw new Exception("OuterException msg incorrect");
if (e.InnerException.Message != "My InnerException message") throw new Exception("InnerException msg incorrect");
}
}
public static string CRLF = "\r\n"; // Some CLR implementations use a CRLF instead of just CR
}
public class TestThread {
private int threadId;
private ThrowsClass throwsClass;
public bool Failed;
public TestThread(ThrowsClass t, int id) {
throwsClass = t;
threadId = id;
}
public void Run() {
Failed = false;
try {
for (int i=0; i<6000; i++) { // run test for about 10 seconds on a 1GHz machine (Mono)
try {
throwsClass.ThrowException(i);
throw new Exception("No exception thrown");
} catch (ArgumentOutOfRangeException e) {
String expectedMessage = "caught:" + i + "\n" + "Parameter name: input";
if (e.Message.Replace(runme.CRLF,"\n") != expectedMessage)
throw new Exception("Exception message incorrect. Expected:\n[" +
expectedMessage + "]\n" + "Received:\n[" +
e.Message + "]");
if (e.ParamName != "input")
throw new Exception("Exception ParamName incorrect. Expected:\n[input]\n" + "Received:\n[" + e.ParamName + "]");
if (e.InnerException != null)
throw new Exception("Unexpected inner exception");
}
if (throwsClass.dub != 1234.5678) // simple check which attempts to catch memory corruption
throw new Exception("throwsException.dub = " + throwsClass.dub + " expected: 1234.5678");
}
} catch (Exception e) {
Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message + "\n TestThread Inner stack trace: " + e.StackTrace);
Failed = true;
}
}
}

View File

@@ -0,0 +1,70 @@
using System;
using csharp_lib_arraysNamespace;
public class runme
{
static void Main()
{
{
int[] source = { 1, 2, 3, 4, 5 };
int[] target = new int[ source.Length ];
csharp_lib_arrays.myArrayCopy( source, target, target.Length );
CompareArrays(source, target);
}
{
int[] source = { 1, 2, 3, 4, 5 };
int[] target = new int[ source.Length ];
csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length );
CompareArrays(source, target);
}
{
int[] source = { 1, 2, 3, 4, 5 };
int[] target = new int[] { 6, 7, 8, 9, 10 };
csharp_lib_arrays.myArraySwap( source, target, target.Length );
for (int i=0; i<target.Length; ++i)
target[i] += 5;
CompareArrays(source, target);
}
{
int[] source = { 1, 2, 3, 4, 5 };
int[] target = new int[] { 6, 7, 8, 9, 10 };
csharp_lib_arrays.myArraySwapUsingFixedArrays( source, target, target.Length );
for (int i=0; i<target.Length; ++i)
target[i] += 5;
CompareArrays(source, target);
}
}
static void CompareArrays( int[] a, int[] b )
{
if (a.Length != b.Length)
throw new Exception("size mismatch");
for(int i=0; i<a.Length; ++i) {
if (a[i] != b[i]) {
Console.Error.WriteLine("a:");
PrintArray(a);
Console.Error.WriteLine("b:");
PrintArray(b);
throw new Exception("element mismatch");
}
}
}
static void PrintArray( int[] a )
{
foreach ( int i in a )
Console.Error.Write( "{0} ", i );
Console.Error.WriteLine();
}
}

View File

@@ -0,0 +1,145 @@
using System;
using System.Reflection;
using csharp_prepostNamespace;
public class csharp_prepost_runme {
class PrePost3_Derived : PrePost3
{
public PrePost3_Derived(){}
public override void method(ref double[] vpre, DoubleVector vpost)
{
Assert(vpre[0], 1.0);
vpre[0] = 2.0;
Assert(vpost.Count, 2);
vpost.Add(1.0);
}
public override int methodint(ref double[] vpre, DoubleVector vpost)
{
method(ref vpre, vpost);
return vpost.Count;
}
}
public static void Main() {
{
double[] v;
csharp_prepost.globalfunction(out v);
Assert(v.Length, 3);
Assert(v[0], 0.0);
Assert(v[1], 1.1);
Assert(v[2], 2.2);
}
{
double[] v;
new PrePostTest(out v);
Assert(v.Length, 2);
Assert(v[0], 3.3);
Assert(v[1], 4.4);
}
{
double[] v;
PrePostTest p = new PrePostTest();
p.method(out v);
Assert(v.Length, 2);
Assert(v[0], 5.5);
Assert(v[1], 6.6);
}
{
double[] v;
PrePostTest.staticmethod(out v);
Assert(v.Length, 2);
Assert(v[0], 7.7);
Assert(v[1], 8.8);
}
{
PrePost3_Derived p = new PrePost3_Derived();
double[] vpre = new double[] { 1.0 };
DoubleVector vpost = new DoubleVector();
vpost.Add(3.0);
vpost.Add(4.0);
p.method(ref vpre, vpost);
Assert(vpre[0], 2.0);
Assert(vpost.Count, 3);
}
{
PrePost3_Derived p = new PrePost3_Derived();
double[] vpre = new double[] { 1.0 };
DoubleVector vpost = new DoubleVector();
vpost.Add(3.0);
vpost.Add(4.0);
int size = p.methodint(ref vpre, vpost);
Assert(vpre[0], 2.0);
Assert(vpost.Count, 3);
Assert(size, 3);
}
// Check attributes are generated for the constructor helper function
{
CsinAttributes c = new CsinAttributes(5);
Assert(c.getVal(), 500);
Type type = typeof(CsinAttributes);
{
MethodInfo member = (MethodInfo)type.GetMember("SwigConstructCsinAttributes", BindingFlags.NonPublic | BindingFlags.Static)[0];
if (Attribute.GetCustomAttribute(member, typeof(CustomIntPtrAttribute)) == null)
throw new Exception("No CustomIntPtr attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
if (parameter.Name != "val")
throw new Exception("Incorrect parameter name");
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(CustomIntAttribute))
throw new Exception("Expecting CustomInt attribute");
}
}
// Dates
{
// pre post typemap attributes example
System.DateTime dateIn = new System.DateTime(2011, 4, 13);
System.DateTime dateOut = new System.DateTime();
// Note in calls below, dateIn remains unchanged and dateOut
// is set to a new value by the C++ call
csharp_prepostNamespace.Action action = new csharp_prepostNamespace.Action(dateIn, out dateOut);
if (dateOut != dateIn)
throw new Exception("dates wrong");
dateIn = new System.DateTime(2012, 7, 14);
action.doSomething(dateIn, out dateOut);
if (dateOut != dateIn)
throw new Exception("dates wrong");
System.DateTime refDate = new System.DateTime(1999, 12, 31);
if (csharp_prepost.ImportantDate != refDate)
throw new Exception("dates wrong");
refDate = new System.DateTime(1999, 12, 31);
csharp_prepost.ImportantDate = refDate;
System.DateTime importantDate = csharp_prepost.ImportantDate;
if (importantDate != refDate)
throw new Exception("dates wrong");
System.DateTime christmasEve = new System.DateTime(2000, 12, 24);
csharp_prepost.addYears(ref christmasEve, 10);
if (christmasEve != new System.DateTime(2010, 12, 24))
throw new Exception("dates wrong");
Person person = new Person();
person.Birthday = christmasEve;
if (person.Birthday != christmasEve)
throw new Exception("dates wrong");
}
}
private static void Assert(double d1, double d2) {
if (d1 != d2)
throw new Exception("assertion failure. " + d1 + " != " + d2);
}
}
// Custom attribute classes
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class CustomIntAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class CustomIntPtrAttribute : Attribute {}

View File

@@ -0,0 +1,113 @@
using System;
using System.Threading;
using csharp_typemapsNamespace;
public class runme
{
static void Main()
{
// Test the C# types customisation by modifying the default char * typemaps to return a single char
Things things = new Things();
System.Text.StringBuilder initialLetters = new System.Text.StringBuilder();
char myChar = things.start("boo");
initialLetters.Append(myChar);
myChar = Things.stop("hiss");
initialLetters.Append(myChar);
myChar = csharp_typemaps.partyon("off");
initialLetters.Append(myChar);
if (initialLetters.ToString() != "bho")
throw new Exception("initial letters failed");
// $csinput expansion
csharp_typemaps.myInt = 1;
try {
csharp_typemaps.myInt = -1;
throw new Exception("oops");
} catch (ApplicationException) {
}
// Eager garbage collector test
{
const int NUM_THREADS = 8;
Thread[] threads = new Thread[NUM_THREADS];
TestThread[] testThreads = new TestThread[NUM_THREADS];
// invoke the threads
for (int i=0; i<NUM_THREADS; i++) {
testThreads[i] = new TestThread(i);
threads[i] = new Thread(new ThreadStart(testThreads[i].Run));
threads[i].Start();
}
// wait for the threads to finish
for (int i=0; i<NUM_THREADS; i++) {
threads[i].Join();
}
for (int i=0; i<NUM_THREADS; i++) {
if (testThreads[i].Failed) throw new Exception("Test Failed");
}
}
}
}
public class TestThread {
private int threadId;
public bool Failed;
public TestThread(int id) {
threadId = id;
}
public void Run() {
Failed = false;
try {
// Older versions of SWIG used IntPtr instead of HandleRef to hold the underlying
// C++ pointer, so this test would (usually) fail as the garbage collector would
// sometimes collect the Number class while it was being used in unmanaged code
for (int i=0; i<5000; i++) { // run test for a few seconds
{
Obj obj = new Obj();
Number n = new Number(i);
Number triple = obj.triple(n);
if (triple.Value != i*3)
throw new ApplicationException("triple failed: " + triple.Value);
}
{
Obj obj = new Obj();
Number n = new Number(i);
Number times6 = obj.times6(n);
if (times6.Value != i*6)
throw new ApplicationException("times6 failed: " + times6.Value);
}
{
Obj obj = new Obj();
Number n = new Number(i);
Number times9 = obj.times9(n);
if (times9.Value != i*9)
throw new ApplicationException("times9 failed: " + times9.Value);
}
{
Number n = new Number(i);
Number quadruple = csharp_typemaps.quadruple(n);
if (quadruple.Value != i*4)
throw new ApplicationException("quadruple failed: " + quadruple.Value);
}
{
Number n = new Number(i);
Number times8 = csharp_typemaps.times8(n);
if (times8.Value != i*8)
throw new ApplicationException("times8 failed: " + times8.Value);
}
{
Number n = new Number(i);
Number times12 = csharp_typemaps.times12(n);
if (times12.Value != i*12)
throw new ApplicationException("times12 failed: " + times12.Value);
}
}
} catch (Exception e) {
Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message);
Failed = true;
}
}
}

View File

@@ -0,0 +1,143 @@
using System;
using default_argsNamespace;
public class runme
{
static void Main()
{
if (default_args.anonymous() != 7771)
throw new Exception("anonymous (1) failed");
if (default_args.anonymous(1234) != 1234)
throw new Exception("anonymous (2) failed");
if (default_args.booltest() != true)
throw new Exception("booltest (1) failed");
if (default_args.booltest(true) != true)
throw new Exception("booltest (2) failed");
if (default_args.booltest(false) != false)
throw new Exception("booltest (3) failed");
EnumClass ec = new EnumClass();
if (ec.blah() != true)
throw new Exception("EnumClass failed");
if (default_args.casts1() != null)
throw new Exception("casts1 failed");
if (default_args.casts2() != "Hello")
throw new Exception("casts2 failed");
if (default_args.casts1("Ciao") != "Ciao")
throw new Exception("casts1 not default failed");
if (default_args.chartest1() != 'x')
throw new Exception("chartest1 failed");
if (default_args.chartest2() != '\0')
throw new Exception("chartest2 failed");
if (default_args.chartest1('y') != 'y')
throw new Exception("chartest1 not default failed");
if (default_args.chartest1('y') != 'y')
throw new Exception("chartest1 not default failed");
if (default_args.reftest1() != 42)
throw new Exception("reftest1 failed");
if (default_args.reftest1(400) != 400)
throw new Exception("reftest1 not default failed");
if (default_args.reftest2() != "hello")
throw new Exception("reftest2 failed");
// rename
Foo foo = new Foo();
foo.newname();
foo.newname(10);
foo.renamed3arg(10, 10.0);
foo.renamed2arg(10);
foo.renamed1arg();
// exception specifications
try {
default_args.exceptionspec();
throw new Exception("exceptionspec 1 failed");
} catch (Exception) {
}
try {
default_args.exceptionspec(-1);
throw new Exception("exceptionspec 2 failed");
} catch (Exception) {
}
try {
default_args.exceptionspec(100);
throw new Exception("exceptionspec 3 failed");
} catch (Exception) {
}
Except ex = new Except(false);
try {
ex.exspec();
throw new Exception("exspec 1 failed");
} catch (Exception) {
}
try {
ex.exspec(-1);
throw new Exception("exspec 2 failed");
} catch (Exception) {
}
try {
ex.exspec(100);
throw new Exception("exspec 3 failed");
} catch (Exception) {
}
try {
ex = new Except(true);
throw new Exception("Except constructor 1 failed");
} catch (Exception) {
}
try {
ex = new Except(true, -2);
throw new Exception("Except constructor 2 failed");
} catch (Exception) {
}
// Default parameters in static class methods
if (Statics.staticmethod() != 10+20+30)
throw new Exception("staticmethod 1 failed");
if (Statics.staticmethod(100) != 100+20+30)
throw new Exception("staticmethod 2 failed");
if (Statics.staticmethod(100,200,300) != 100+200+300)
throw new Exception("staticmethod 3 failed");
Tricky tricky = new Tricky();
if (tricky.privatedefault() != 200)
throw new Exception("privatedefault failed");
if (tricky.protectedint() != 2000)
throw new Exception("protectedint failed");
if (tricky.protecteddouble() != 987.654)
throw new Exception("protecteddouble failed");
if (tricky.functiondefault() != 500)
throw new Exception("functiondefault failed");
if (tricky.contrived() != 'X')
throw new Exception("contrived failed");
if (default_args.constructorcall().val != -1)
throw new Exception("constructorcall test 1 failed");
if (default_args.constructorcall(new Klass(2222)).val != 2222)
throw new Exception("constructorcall test 2 failed");
if (default_args.constructorcall(new Klass()).val != -1)
throw new Exception("constructorcall test 3 failed");
// const methods
ConstMethods cm = new ConstMethods();
if (cm.coo() != 20)
throw new Exception("coo test 1 failed");
if (cm.coo(1.0) != 20)
throw new Exception("coo test 2 failed");
}
}

View File

@@ -0,0 +1,16 @@
using System;
using default_constructorNamespace;
public class runme
{
static void Main()
{
// calling protected destructor test
try {
using (G g = new G()) {
}
throw new Exception("Protected destructor exception should have been thrown");
} catch (MethodAccessException) {
}
}
}

View File

@@ -0,0 +1,11 @@
using System;
using director_alternatingNamespace;
public class director_alternating_runme {
public static void Main() {
if (director_alternating.getBar().id() != director_alternating.idFromGetBar())
throw new Exception("idFromGetBar failed");
}
}

View File

@@ -0,0 +1,74 @@
using System;
namespace director_basicNamespace {
public class runme
{
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
director_basic_MyFoo a = new director_basic_MyFoo();
if (a.ping() != "director_basic_MyFoo::ping()") {
throw new Exception ( "a.ping()" );
}
if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") {
throw new Exception ( "a.pong()" );
}
Foo b = new Foo();
if (b.ping() != "Foo::ping()") {
throw new Exception ( "b.ping()" );
}
if (b.pong() != "Foo::pong();Foo::ping()") {
throw new Exception ( "b.pong()" );
}
A1 a1 = new A1(1, false);
a1.Dispose();
{
MyOverriddenClass my = new MyOverriddenClass();
my.expectNull = true;
if (MyClass.call_pmethod(my, null) != null)
throw new Exception("null pointer marshalling problem");
Bar myBar = new Bar();
my.expectNull = false;
Bar myNewBar = MyClass.call_pmethod(my, myBar);
if (myNewBar == null)
throw new Exception("non-null pointer marshalling problem");
myNewBar.x = 10;
}
}
}
class director_basic_MyFoo : Foo {
public director_basic_MyFoo() : base() {
}
public override string ping() {
return "director_basic_MyFoo::ping()";
}
}
class MyOverriddenClass : MyClass {
public bool expectNull = false;
public bool nonNullReceived = false;
public override Bar pmethod(Bar b) {
if ( expectNull && (b != null) )
throw new Exception("null not received as expected");
return b;
}
}
}

View File

@@ -0,0 +1,180 @@
/*
This test demonstrates director classes when the types are classes.
Shown are virtual function calls which use classes passed by:
- Value
- Reference
- Pointer
as both parameters and return values.
The test also demonstrates directors used with:
- method overloading
- default parameters
Note: Methods with default parameters that call up from C++ cannot call
the overloaded C# methods, see DefaultParms method.
Expected output if PrintDebug enabled:
------------ Start ------------
Base - Val(444.555)
Base - Ref(444.555)
Base - Ptr(444.555)
Base - FullyOverloaded(int 10)
Base - FullyOverloaded(bool 1)
Base - SemiOverloaded(int -678)
Base - SemiOverloaded(bool 1)
Base - DefaultParms(10, 2.2)
Base - DefaultParms(10, 1.1)
--------------------------------
Derived - Val(444.555)
Derived - Ref(444.555)
Derived - Ptr(444.555)
Derived - FullyOverloaded(int 10)
Derived - FullyOverloaded(bool 1)
Derived - SemiOverloaded(int -678)
Base - SemiOverloaded(bool 1)
Derived - DefaultParms(10, 2.2)
Derived - DefaultParms(10, 1.1)
--------------------------------
CSharpDerived - Val(444.555)
CSharpDerived - Ref(444.555)
CSharpDerived - Ptr(444.555)
CSharpDerived - FullyOverloaded(int 10)
CSharpDerived - FullyOverloaded(bool True)
CSharpDerived - SemiOverloaded(-678)
Base - SemiOverloaded(bool 1)
CSharpDerived - DefaultParms(10, 2.2)
CSharpDerived - DefaultParms(10, 1.1)
------------ Finish ------------
*/
using System;
namespace director_classesNamespace {
public class runme
{
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
if (director_classes.PrintDebug) Console.WriteLine("------------ Start ------------ ");
Caller myCaller = new Caller();
// test C++ base class
using (Base myBase = new Base(100.0))
{
makeCalls(myCaller, myBase);
}
if (director_classes.PrintDebug) Console.WriteLine("--------------------------------");
// test vanilla C++ wrapped derived class
using (Base myBase = new Derived(200.0))
{
makeCalls(myCaller, myBase);
}
if (director_classes.PrintDebug) Console.WriteLine("--------------------------------");
// test director / C# derived class
using (Base myBase = new CSharpDerived(300.0))
{
makeCalls(myCaller, myBase);
}
if (director_classes.PrintDebug) Console.WriteLine("------------ Finish ------------ ");
}
void makeCalls(Caller myCaller, Base myBase)
{
string NAMESPACE = "director_classesNamespace.";
myCaller.set(myBase);
DoubleHolder dh = new DoubleHolder(444.555);
// Class pointer, reference and pass by value tests
if (myCaller.ValCall(dh).val != dh.val) throw new Exception("failed");
if (myCaller.RefCall(dh).val != dh.val) throw new Exception("failed");
if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("failed");
// Fully overloaded method test (all methods in base class are overloaded)
if (NAMESPACE + myCaller.FullyOverloadedCall(10) != myBase.GetType() + "::FullyOverloaded(int)") throw new Exception("failed");
if (NAMESPACE + myCaller.FullyOverloadedCall(true) != myBase.GetType() + "::FullyOverloaded(bool)") throw new Exception("failed");
// Semi overloaded method test (some methods in base class are overloaded)
if (NAMESPACE + myCaller.SemiOverloadedCall(-678) != myBase.GetType() + "::SemiOverloaded(int)") throw new Exception("failed");
if (myCaller.SemiOverloadedCall(true) != "Base" + "::SemiOverloaded(bool)") throw new Exception("failed");
// Default parameters methods test
if (NAMESPACE + myCaller.DefaultParmsCall(10, 2.2) != myBase.GetType() + "::DefaultParms(int, double)") throw new Exception("failed");
if (myBase.GetType() == typeof(CSharpDerived)) { // special handling for C# derived classes, there is no way to do this any other way
if (NAMESPACE + myCaller.DefaultParmsCall(10) != myBase.GetType() + "::DefaultParms(int, double)") throw new Exception("failed");
} else {
if (NAMESPACE + myCaller.DefaultParmsCall(10) != myBase.GetType() + "::DefaultParms(int)") throw new Exception("failed");
}
myCaller.reset();
}
}
public class CSharpDerived : Base
{
public CSharpDerived(double dd)
: base(dd)
{
}
public override DoubleHolder Val(DoubleHolder x)
{
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - Val({0})", x.val);
return x;
}
public override DoubleHolder Ref(DoubleHolder x)
{
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - Ref({0})", x.val);
return x;
}
public override DoubleHolder Ptr(DoubleHolder x)
{
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - Ptr({0})", x.val);
return x;
}
public override String FullyOverloaded(int x)
{
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - FullyOverloaded(int {0})", x);
return "CSharpDerived::FullyOverloaded(int)";
}
public override String FullyOverloaded(bool x)
{
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - FullyOverloaded(bool {0})", x);
return "CSharpDerived::FullyOverloaded(bool)";
}
// Note no SemiOverloaded(bool x) method
public override String SemiOverloaded(int x)
{
String ret = "CSharpDerived::SemiOverloaded(int)";
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - SemiOverloaded({0})", x);
return ret;
}
public override String DefaultParms(int x, double y)
{
String ret = "CSharpDerived::DefaultParms(int, double)";
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - DefaultParms({0}, {1})", x, y);
return ret;
}
// Note the following method can never be called from unmanaged code.
// It is here only for code that calls it directly from managed code.
// But should always be defined to ensure behaviour is consistent
// independent of where DefaultParsms is called from (managed or unmanaged code).
// Note this method can never be called from unmanaged code
public override String DefaultParms(int x)
{
if (director_classes.PrintDebug) Console.WriteLine("CSharpDerived - DefaultParms({0})", x);
return DefaultParms(x, 1.1/*use C++ default here*/);
}
}
}

View File

@@ -0,0 +1,314 @@
using System;
namespace director_classicNamespace {
public class runme
{
static void Main()
{
{
Person person = new Person();
check(person, "Person");
person.Dispose();
}
{
Person person = new Child();
check(person, "Child");
person.Dispose();
}
{
Person person = new GrandChild();
check(person, "GrandChild");
person.Dispose();
}
{
Person person = new TargetLangPerson();
check(person, "TargetLangPerson");
person.Dispose();
}
{
Person person = new TargetLangChild();
check(person, "TargetLangChild");
person.Dispose();
}
{
Person person = new TargetLangGrandChild();
check(person, "TargetLangGrandChild");
person.Dispose();
}
// Semis - don't override id() in target language
{
Person person = new TargetLangSemiPerson();
check(person, "Person");
person.Dispose();
}
{
Person person = new TargetLangSemiChild();
check(person, "Child");
person.Dispose();
}
{
Person person = new TargetLangSemiGrandChild();
check(person, "GrandChild");
person.Dispose();
}
// Orphans - don't override id() in C++
{
Person person = new OrphanPerson();
check(person, "Person");
person.Dispose();
}
{
Person person = new OrphanChild();
check(person, "Child");
person.Dispose();
}
{
Person person = new TargetLangOrphanPerson();
check(person, "TargetLangOrphanPerson");
person.Dispose();
}
{
Person person = new TargetLangOrphanChild();
check(person, "TargetLangOrphanChild");
person.Dispose();
}
// Duals - id() makes an upcall to the base id()
{
Person person = new TargetLangDualPerson();
check(person, "TargetLangDualPerson + Person");
person.Dispose();
}
{
Person person = new TargetLangDualChild();
check(person, "TargetLangDualChild + Child");
person.Dispose();
}
{
Person person = new TargetLangDualGrandChild();
check(person, "TargetLangDualGrandChild + GrandChild");
person.Dispose();
}
// Mix Orphans and Duals
{
Person person = new TargetLangDualOrphanPerson();
check(person, "TargetLangDualOrphanPerson + Person");
person.Dispose();
}
{
Person person = new TargetLangDualOrphanChild();
check(person, "TargetLangDualOrphanChild + Child");
person.Dispose();
}
}
static void check(Person person, String expected) {
String ret;
// Normal target language polymorphic call
ret = person.id();
if (debug)
Console.WriteLine(ret);
if (ret != expected)
throw new Exception("Failed. Received: " + ret + " Expected: " + expected);
// Polymorphic call from C++
Caller caller = new Caller();
caller.setCallback(person);
ret = caller.call();
if (debug)
Console.WriteLine(ret);
if (ret != expected)
throw new Exception("Failed. Received: " + ret + " Expected: " + expected);
// Polymorphic call of object created in target language and passed to C++ and back again
Person baseclass = caller.baseClass();
ret = baseclass.id();
if (debug)
Console.WriteLine(ret);
if (ret != expected)
throw new Exception("Failed. Received: " + ret + " Expected: " + expected);
caller.resetCallback();
if (debug)
Console.WriteLine("----------------------------------------");
}
static bool debug = false;
}
public class TargetLangPerson : Person
{
public TargetLangPerson()
: base()
{
}
public override String id()
{
String identifier = "TargetLangPerson";
return identifier;
}
}
public class TargetLangChild : Child
{
public TargetLangChild()
: base()
{
}
public override String id()
{
String identifier = "TargetLangChild";
return identifier;
}
}
public class TargetLangGrandChild : GrandChild
{
public TargetLangGrandChild()
: base()
{
}
public override String id()
{
String identifier = "TargetLangGrandChild";
return identifier;
}
}
// Semis - don't override id() in target language
public class TargetLangSemiPerson : Person
{
public TargetLangSemiPerson()
: base()
{
}
// No id() override
}
public class TargetLangSemiChild : Child
{
public TargetLangSemiChild()
: base()
{
}
// No id() override
}
public class TargetLangSemiGrandChild : GrandChild
{
public TargetLangSemiGrandChild()
: base()
{
}
// No id() override
}
// Orphans - don't override id() in C++
class TargetLangOrphanPerson : OrphanPerson
{
public TargetLangOrphanPerson()
: base()
{
}
public override String id()
{
String identifier = "TargetLangOrphanPerson";
return identifier;
}
}
class TargetLangOrphanChild : OrphanChild
{
public TargetLangOrphanChild()
: base()
{
}
public override String id()
{
String identifier = "TargetLangOrphanChild";
return identifier;
}
}
// Duals - id() makes an upcall to the base id()
class TargetLangDualPerson : Person
{
public TargetLangDualPerson()
: base()
{
}
public override String id()
{
String identifier = "TargetLangDualPerson + " + base.id();
return identifier;
}
}
class TargetLangDualChild : Child
{
public TargetLangDualChild()
: base()
{
}
public override String id()
{
String identifier = "TargetLangDualChild + " + base.id();
return identifier;
}
}
class TargetLangDualGrandChild : GrandChild
{
public TargetLangDualGrandChild()
: base()
{
}
public override String id()
{
String identifier = "TargetLangDualGrandChild + " + base.id();
return identifier;
}
}
// Mix Orphans and Duals
class TargetLangDualOrphanPerson : OrphanPerson
{
public TargetLangDualOrphanPerson()
: base()
{
}
public override String id()
{
String identifier = "TargetLangDualOrphanPerson + " + base.id();
return identifier;
}
}
class TargetLangDualOrphanChild : OrphanChild
{
public TargetLangDualOrphanChild()
: base()
{
}
public override String id()
{
String identifier = "TargetLangDualOrphanChild + " + base.id();
return identifier;
}
}
}

View File

@@ -0,0 +1,57 @@
using System;
namespace director_ignoreNamespace {
public class runme
{
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
// Just check the classes can be instantiated and other methods work as expected
DIgnoresDerived a = new DIgnoresDerived();
if (a.Triple(5) != 15)
throw new Exception("Triple failed");
DAbstractIgnoresDerived b = new DAbstractIgnoresDerived();
if (b.Quadruple(5) != 20)
throw new Exception("Quadruple failed");
}
}
class DIgnoresDerived : DIgnores
{
public DIgnoresDerived() : base()
{
}
// These will give a warning if the %ignore is not working
public virtual int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
public virtual int OverloadedMethod(int n, int xoffset) { return 0; }
public virtual int OverloadedMethod(int n) { return 0; }
public virtual int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
public virtual int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
public virtual int OverloadedProtectedMethod(int n) { return 0; }
}
class DAbstractIgnoresDerived : DAbstractIgnores
{
public DAbstractIgnoresDerived() : base()
{
}
// These will give a warning if the %ignore is not working
public virtual int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
public virtual int OverloadedMethod(int n, int xoffset) { return 0; }
public virtual int OverloadedMethod(int n) { return 0; }
public virtual int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
public virtual int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
public virtual int OverloadedProtectedMethod(int n) { return 0; }
}
}

View File

@@ -0,0 +1,32 @@
using System;
using director_nspaceNamespace;
public class bools_runme {
public static void Main() {
}
}
class director_nspace_MyBarFoo : director_nspaceNamespace.TopLevel.Bar.Foo {
public override String ping() {
return "director_nspace_MyBarFoo.ping();";
}
public override String pong() {
return "director_nspace_MyBarFoo.pong();" + ping();
}
public override String fooBar(director_nspaceNamespace.TopLevel.Bar.FooBar fooBar) {
return fooBar.FooBarDo();
}
public override director_nspaceNamespace.TopLevel.Bar.Foo makeFoo() {
return new director_nspaceNamespace.TopLevel.Bar.Foo();
}
public override director_nspaceNamespace.TopLevel.Bar.FooBar makeFooBar() {
return new director_nspaceNamespace.TopLevel.Bar.FooBar();
}
}

View File

@@ -0,0 +1,43 @@
using System;
using director_pass_by_valueNamespace;
public class runme
{
private static void WaitForGC()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
System.Threading.Thread.Sleep(10);
}
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
Caller caller = new Caller();
caller.call_virtualMethod(new director_pass_by_value_Derived());
{
int countdown = 5;
while (true) {
WaitForGC();
if (--countdown == 0)
break;
};
}
// bug was the passByVal 'global' object was destroyed after the call to virtualMethod had finished.
int ret = runme.passByVal.getVal();
if (ret != 0x12345678)
throw new Exception("Bad return value, got " + ret.ToString("x"));
}
public static PassedByValue passByVal;
}
class director_pass_by_value_Derived : DirectorPassByValueAbstractBase {
public override void virtualMethod(PassedByValue pbv) {
runme.passByVal = pbv;
}
}

View File

@@ -0,0 +1,127 @@
/*
This test program shows a C# class CSharpDerived inheriting from Base. Three types of classes are created
and the virtual methods called to demonstrate:
1) Wide variety of primitive types
2) Calling methods with zero, one or more parameters
3) Director methods that are not overridden in C#
4) Director classes that are not overridden at all in C#, ie non-director behaviour is as expected for director classes
5) Inheritance hierarchy using director methods
6) Return types working as well as parameters
The Caller class is a tester class, which calls the virtual functions from C++.
*/
using System;
using director_primitivesNamespace;
public class runme
{
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
if (director_primitives.PrintDebug) Console.WriteLine("------------ Start ------------ ");
Caller myCaller = new Caller();
// test C++ base class
using (Base myBase = new Base(100.0))
{
makeCalls(myCaller, myBase);
}
if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");
// test vanilla C++ wrapped derived class
using (Base myBase = new Derived(200.0))
{
makeCalls(myCaller, myBase);
}
if (director_primitives.PrintDebug) Console.WriteLine("--------------------------------");
// test director / C# derived class
using (Base myBase = new CSharpDerived(300.0))
{
makeCalls(myCaller, myBase);
}
if (director_primitives.PrintDebug) Console.WriteLine("------------ Finish ------------ ");
}
void makeCalls(Caller myCaller, Base myBase)
{
myCaller.set(myBase);
myCaller.NoParmsMethodCall();
if (myCaller.BoolMethodCall(true) != true) throw new Exception("failed");
if (myCaller.BoolMethodCall(false) != false) throw new Exception("failed");
if (myCaller.IntMethodCall(-123) != -123) throw new Exception("failed");
if (myCaller.UIntMethodCall(123) != 123) throw new Exception("failed");
if (myCaller.FloatMethodCall((float)-123.456) != (float)-123.456) throw new Exception("failed");
if (myCaller.CharPtrMethodCall("test string") != "test string") throw new Exception("failed");
if (myCaller.ConstCharPtrMethodCall("another string") != "another string") throw new Exception("failed");
if (myCaller.EnumMethodCall(HShadowMode.HShadowHard) != HShadowMode.HShadowHard) throw new Exception("failed");
myCaller.ManyParmsMethodCall(true, -123, 123, (float)123.456, "test string", "another string", HShadowMode.HShadowHard);
myCaller.NotOverriddenMethodCall();
myCaller.reset();
}
}
public class CSharpDerived : Base
{
public CSharpDerived(double dd)
: base(dd)
{
}
public override void NoParmsMethod()
{
if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - NoParmsMethod()");
}
public override bool BoolMethod(bool x)
{
if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - BoolMethod({0})", x);
return x;
}
public override int IntMethod(int x)
{
if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - IntMethod({0})", x);
return x;
}
public override uint UIntMethod(uint x)
{
if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - UIntMethod({0})", x);
return x;
}
public override float FloatMethod(float x)
{
if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - FloatMethod({0})", x);
return x;
}
public override string CharPtrMethod(string x)
{
if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - CharPtrMethod({0})", x);
return x;
}
public override string ConstCharPtrMethod(string x)
{
if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - ConstCharPtrMethod({0})", x);
return x;
}
public override HShadowMode EnumMethod(HShadowMode x)
{
if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - EnumMethod({0})", x);
return x;
}
public override void ManyParmsMethod(bool b, int i, uint u, float f, string c, string cc, HShadowMode h)
{
if (director_primitives.PrintDebug) Console.WriteLine("CSharpDerived - ManyParmsMethod({0}, {1}, {2}, {3}, {4}, {5}, {6})", b, i, u, f, c, cc, h);
}
}

View File

@@ -0,0 +1,100 @@
using System;
namespace director_protectedNamespace {
public class runme
{
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
Bar b = new Bar();
Foo f = b.create();
FooBar fb = new FooBar();
FooBar2 fb2 = new FooBar2();
FooBar3 fb3 = new FooBar3();
String s;
s = fb.used();
if ( s != ("Foo::pang();Bar::pong();Foo::pong();FooBar::ping();"))
throw new Exception("bad FooBar::used" + " - " + s);
s = fb2.used();
if ( s != ("FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();"))
throw new Exception("bad FooBar2::used");
s = b.pong();
if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
throw new Exception("bad Bar::pong");
s = f.pong();
if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
throw new Exception("bad Foo::pong");
s = fb.pong();
if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
throw new Exception("bad FooBar::pong");
// if (fb3.cheer() != "FooBar3::cheer();")
// throw new Exception("bad fb3::cheer");
if (fb2.callping() != "FooBar2::ping();")
throw new Exception("bad fb2.callping");
if (fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();")
throw new Exception("bad fb2.callcheer");
if (fb3.callping() != "Bar::ping();")
throw new Exception("bad fb3.callping");
if (fb3.callcheer() != "FooBar3::cheer();")
throw new Exception("bad fb3.callcheer");
}
}
class FooBar : Bar
{
public FooBar() : base()
{
}
protected override String ping()
{
return "FooBar::ping();";
}
}
class FooBar2 : Bar
{
public FooBar2() : base()
{
}
protected override String ping()
{
return "FooBar2::ping();";
}
protected override String pang()
{
return "FooBar2::pang();";
}
}
class FooBar3 : Bar
{
public FooBar3() : base()
{
}
protected override String cheer()
{
return "FooBar3::cheer();";
}
}
}

View File

@@ -0,0 +1,53 @@
using director_smartptrNamespace;
using System;
public class runme
{
private class director_smartptr_MyBarFoo : Foo
{
public override string ping()
{
return "director_smartptr_MyBarFoo.ping()";
}
public override string pong()
{
return "director_smartptr_MyBarFoo.pong();" + ping();
}
public override string upcall(FooBar fooBarPtr)
{
return "override;" + fooBarPtr.FooBarDo();
}
public override Foo makeFoo()
{
return new Foo();
}
}
private static void check(string got, string expected)
{
if (got != expected)
throw new ApplicationException("Failed, got: " + got + " expected: " + expected);
}
static void Main()
{
FooBar fooBar = new FooBar();
Foo myBarFoo = new director_smartptr_MyBarFoo();
check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()");
check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()");
check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()");
Foo myFoo = myBarFoo.makeFoo();
check(myFoo.pong(), "Foo::pong();Foo::ping()");
check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()");
check(myFoo.upcall(new FooBar()), "Bar::Foo2::Foo2Bar()");
Foo myFoo2 = new Foo().makeFoo();
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
}
}

View File

@@ -0,0 +1,53 @@
using System;
using director_stringNamespace;
public class runme
{
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
String s;
director_string_A c = new director_string_A("hi");
for (int i=0; i<3; i++) {
s = c.call_get(i);
Object ii = i;
if (s != ii.ToString()) throw new Exception("director_string_A.get(" + i + ") failed. Got:" + s);
}
director_string_B b = new director_string_B("hello");
s = b.call_get_first();
if (s != "director_string_B.get_first") throw new Exception("call_get_first() failed");
s = b.call_get(0);
if (s != "director_string_B.get: hello") throw new Exception("get(0) failed");
}
}
class director_string_B : A {
public director_string_B(String first) : base(first) {
}
public override String get_first() {
return "director_string_B.get_first";
}
public override String get(int n) {
return "director_string_B.get: " + base.get(n);
}
}
class director_string_A : A {
public director_string_A(String first) : base(first) {
}
public override String get(int n) {
Object nn = n;
return nn.ToString();
}
}

View File

@@ -0,0 +1,83 @@
using System;
using director_voidNamespace;
public class runme
{
private static void WaitForGC()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
System.Threading.Thread.Sleep(10);
}
static void Main()
{
runme r = new runme();
r.run();
}
void run()
{
Caller caller = new Caller();
{
DirectorVoidPointer dvp = new DirectorVoidPointer(5);
int x = caller.callVirtualIn(dvp, 6);
if (x != 106)
throw new Exception("Fail1 should be 106, got " + x);
global::System.IntPtr ptr = dvp.nonVirtualVoidPtrOut();
x = Caller.VoidToInt(ptr);
if (x != 106)
throw new Exception("Fail2 should be 106, got " + x);
x = Caller.VoidToInt(dvp.voidPtrOut());
if (x != 106)
throw new Exception("Fail3 should be 106, got " + x);
}
{
DirectorVoidPointer dvp = new director_void_VoidPointer(5);
int x = caller.callVirtualIn(dvp, 6);
if (x != 12)
throw new Exception("Fail1 should be 12, got " + x);
global::System.IntPtr ptr = dvp.nonVirtualVoidPtrOut();
x = Caller.VoidToInt(ptr);
if (x != 25)
throw new Exception("Fail2 should be 25, got " + x);
x = Caller.VoidToInt(dvp.voidPtrOut());
if (x != 1234)
throw new Exception("Fail3 should be 1234, got " + x);
}
{
DirectorVoidPointer dvp = new DirectorVoidPointer(10);
int x = caller.callVirtualOut(dvp);
if (x != 10)
throw new Exception("Bad1 should be 10, got " + x);
global::System.IntPtr ptr = dvp.nonVirtualVoidPtrOut();
x = dvp.nonVirtualVoidPtrIn(ptr);
if (x != 110)
throw new Exception("Bad2 should be 110, got " + x);
}
{
DirectorVoidPointer dvp = new director_void_VoidPointer(10);
int x = caller.callVirtualOut(dvp);
if (x != 1234)
throw new Exception("Bad3 should be 1234, got " + x);
global::System.IntPtr ptr = dvp.nonVirtualVoidPtrOut();
x = dvp.nonVirtualVoidPtrIn(ptr);
if (x != 1334)
throw new Exception("Bad4 should be 1334, got " + x);
}
}
}
class director_void_VoidPointer : DirectorVoidPointer {
public director_void_VoidPointer(int num) : base(num*num) {
}
public override int voidPtrIn(global::System.IntPtr p) {
return Caller.VoidToInt(p) * 2;
}
public override global::System.IntPtr voidPtrOut() {
setNewValue(1234);
return nonVirtualVoidPtrOut();
}
}

View File

@@ -0,0 +1,16 @@
using System;
using enum_forwardNamespace;
public class runme {
static void Main() {
ForwardEnum1 f1 = enum_forward.get_enum1();
f1 = enum_forward.test_function1(f1);
ForwardEnum2 f2 = enum_forward.get_enum2();
f2 = enum_forward.test_function2(f2);
ForwardEnum3 f3 = enum_forward.get_enum3();
f3 = enum_forward.test_function3(f3);
}
}

View File

@@ -0,0 +1,432 @@
using System;
using enum_thoroughNamespace;
public class runme {
static void Main() {
{
// Anonymous enums
int i = enum_thorough.AnonEnum1;
if (enum_thorough.ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed");
i += enum_thorough.AnonSpaceEnum1;
i += AnonStruct.AnonStructEnum1;
}
{
colour red = colour.red;
enum_thorough.colourTest1(red);
enum_thorough.colourTest2(red);
enum_thorough.colourTest3(red);
enum_thorough.colourTest4(red);
enum_thorough.myColour = red;
}
{
SpeedClass s = new SpeedClass();
SpeedClass.speed speed = SpeedClass.speed.slow;
if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed");
if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed");
if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed");
if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed");
if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed");
if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed");
if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed");
if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed");
if (enum_thorough.speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed");
if (enum_thorough.speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed");
if (enum_thorough.speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed");
if (enum_thorough.speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed");
if (enum_thorough.speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed");
}
{
SpeedClass s = new SpeedClass();
SpeedClass.speed slow = SpeedClass.speed.slow;
SpeedClass.speed lightning = SpeedClass.speed.lightning;
if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed");
if ((int)s.mySpeedtd1 != 10) throw new Exception("mySpeedtd1 2 failed");
s.mySpeedtd1 = lightning;
if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed");
if ((int)s.mySpeedtd1 != 31) throw new Exception("mySpeedtd1 4 failed");
}
{
if (enum_thorough.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest 1 failed");
}
{
twonames val = twonames.TwoNames2;
if (enum_thorough.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
if (enum_thorough.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
if (enum_thorough.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
}
{
TwoNamesStruct t = new TwoNamesStruct();
TwoNamesStruct.twonames val = TwoNamesStruct.twonames.TwoNamesStruct1;
if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
}
{
namedanonspace val = namedanonspace.NamedAnonSpace2;
if (enum_thorough.namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed");
if (enum_thorough.namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed");
if (enum_thorough.namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed");
if (enum_thorough.namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed");
}
{
TemplateClassInt t = new TemplateClassInt();
TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed");
if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed");
if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed");
if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed");
if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed");
if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed");
if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed");
if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed");
if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed");
// if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed");
if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed");
// if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed");
if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed");
if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed");
if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed");
if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed");
if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed");
if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed");
if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed");
if (enum_thorough.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed");
if (enum_thorough.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed");
if (enum_thorough.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed");
if (enum_thorough.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed");
if (enum_thorough.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed");
if (enum_thorough.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed");
if (enum_thorough.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed");
if (enum_thorough.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed");
}
{
TClassInt t = new TClassInt();
TClassInt.scientists bell = TClassInt.scientists.bell;
TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed");
if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed");
if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed");
if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed");
if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed");
if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed");
if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed");
if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed");
if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed");
// if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed");
if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed");
// if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed");
if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed");
if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed");
if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed");
if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed");
if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed");
if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed");
if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed");
if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed");
if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed");
if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed");
if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed");
if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed");
if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed");
if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed");
if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed");
if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed");
if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed");
if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed");
if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed");
if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed");
if (enum_thorough.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed");
if (enum_thorough.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed");
if (enum_thorough.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed");
if (enum_thorough.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed");
if (enum_thorough.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed");
if (enum_thorough.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed");
if (enum_thorough.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed");
if (enum_thorough.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed");
if (enum_thorough.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed");
if (enum_thorough.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed");
if (enum_thorough.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed");
if (enum_thorough.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed");
if (enum_thorough.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed");
if (enum_thorough.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed");
if (enum_thorough.scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed");
if (enum_thorough.scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed");
if (enum_thorough.scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed");
if (enum_thorough.scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed");
if (enum_thorough.scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed");
if (enum_thorough.scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed");
if (enum_thorough.scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed");
if (enum_thorough.scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed");
if (enum_thorough.scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed");
if (enum_thorough.scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed");
if (enum_thorough.scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed");
if (enum_thorough.scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed");
if (enum_thorough.scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed");
if (enum_thorough.scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed");
}
{
newname val = newname.argh;
if (enum_thorough.renameTest1(val) != val) throw new Exception("renameTest Global 1 failed");
if (enum_thorough.renameTest2(val) != val) throw new Exception("renameTest Global 2 failed");
}
{
NewNameStruct n = new NewNameStruct();
if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 1 failed");
if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 2 failed");
if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest 3 failed");
if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 4 failed");
if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 5 failed");
if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest 6 failed");
}
{
if (enum_thorough.renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest Global 3 failed");
if (enum_thorough.renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest Global 4 failed");
if (enum_thorough.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 5 failed");
if (enum_thorough.renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 6 failed");
if (enum_thorough.renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest Global 7 failed");
}
{
TreesClass t = new TreesClass();
TreesClass.trees pine = TreesClass.trees.pine;
if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed");
if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed");
if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed");
if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed");
if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed");
if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed");
if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed");
if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed");
if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed");
if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed");
if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed");
if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed");
if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed");
if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed");
if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed");
if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed");
if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed");
if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed");
if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed");
if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed");
if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed");
if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed");
if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed");
if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed");
if (enum_thorough.treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed");
if (enum_thorough.treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed");
if (enum_thorough.treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed");
if (enum_thorough.treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed");
if (enum_thorough.treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed");
if (enum_thorough.treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed");
if (enum_thorough.treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed");
if (enum_thorough.treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed");
if (enum_thorough.treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed");
if (enum_thorough.treesTestA(pine) != pine) throw new Exception("treesTest Global A failed");
if (enum_thorough.treesTestB(pine) != pine) throw new Exception("treesTest Global B failed");
if (enum_thorough.treesTestC(pine) != pine) throw new Exception("treesTest Global C failed");
if (enum_thorough.treesTestD(pine) != pine) throw new Exception("treesTest Global D failed");
if (enum_thorough.treesTestE(pine) != pine) throw new Exception("treesTest Global E failed");
if (enum_thorough.treesTestF(pine) != pine) throw new Exception("treesTest Global F failed");
if (enum_thorough.treesTestG(pine) != pine) throw new Exception("treesTest Global G failed");
if (enum_thorough.treesTestH(pine) != pine) throw new Exception("treesTest Global H failed");
if (enum_thorough.treesTestI(pine) != pine) throw new Exception("treesTest Global I failed");
if (enum_thorough.treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed");
if (enum_thorough.treesTestK(pine) != pine) throw new Exception("treesTest Global K failed");
if (enum_thorough.treesTestL(pine) != pine) throw new Exception("treesTest Global L failed");
if (enum_thorough.treesTestM(pine) != pine) throw new Exception("treesTest Global M failed");
// if (enum_thorough.treesTestN(pine) != pine) throw new Exception("treesTest Global N failed");
if (enum_thorough.treesTestO(pine) != pine) throw new Exception("treesTest Global O failed");
if (enum_thorough.treesTestP(pine) != pine) throw new Exception("treesTest Global P failed");
if (enum_thorough.treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed");
if (enum_thorough.treesTestR(pine) != pine) throw new Exception("treesTest Global R failed");
}
{
HairStruct h = new HairStruct();
HairStruct.hair ginger = HairStruct.hair.ginger;
if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed");
if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed");
if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed");
if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed");
if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed");
if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed");
if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed");
if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed");
if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed");
if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed");
if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed");
colour red = colour.red;
if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed");
if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed");
if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed");
if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed");
TreesClass.trees fir = TreesClass.trees.fir;
if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed");
if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed");
if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed");
if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed");
}
{
HairStruct.hair blonde = HairStruct.hair.blonde;
if (enum_thorough.hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed");
if (enum_thorough.hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed");
if (enum_thorough.hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed");
if (enum_thorough.hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed");
if (enum_thorough.hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed");
if (enum_thorough.hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed");
if (enum_thorough.hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed");
if (enum_thorough.hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed");
if (enum_thorough.hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed");
if (enum_thorough.hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed");
if (enum_thorough.hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed");
if (enum_thorough.hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed");
if (enum_thorough.hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed");
if (enum_thorough.hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed");
if (enum_thorough.hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed");
if (enum_thorough.hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed");
if (enum_thorough.hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed");
if (enum_thorough.hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed");
if (enum_thorough.hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed");
if (enum_thorough.hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed");
if (enum_thorough.hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed");
if (enum_thorough.hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed");
if (enum_thorough.hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed");
if (enum_thorough.hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed");
if (enum_thorough.hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed");
if (enum_thorough.hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed");
if (enum_thorough.hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed");
if (enum_thorough.hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed");
if (enum_thorough.hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed");
if (enum_thorough.hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed");
if (enum_thorough.hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed");
if (enum_thorough.hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed");
if (enum_thorough.hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed");
if (enum_thorough.hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed");
if (enum_thorough.hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed");
if (enum_thorough.hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed");
if (enum_thorough.hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed");
if (enum_thorough.hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed");
if (enum_thorough.hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed");
if (enum_thorough.hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed");
if (enum_thorough.hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed");
if (enum_thorough.hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed");
if (enum_thorough.hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed");
if (enum_thorough.hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed");
if (enum_thorough.hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed");
if (enum_thorough.hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed");
if (enum_thorough.hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed");
if (enum_thorough.hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed");
}
{
FirStruct f = new FirStruct();
HairStruct.hair blonde = HairStruct.hair.blonde;
if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed");
if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed");
if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed");
if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed");
if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed");
if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed");
if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed");
if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed");
if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed");
if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed");
}
{
enum_thorough.GlobalInstance = enum_thorough.globalinstance2;
if (enum_thorough.GlobalInstance != enum_thorough.globalinstance2) throw new Exception("GlobalInstance 1 failed");
Instances i = new Instances();
i.MemberInstance = Instances.memberinstance3;
if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
}
// ignore enum item tests start
{
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed");
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed");
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed");
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed");
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed");
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed");
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed");
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed");
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed");
if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed");
}
{
if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed");
if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed");
if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed");
if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed");
if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed");
if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed");
}
{
if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed");
if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed");
if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed");
if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed");
if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed");
if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed");
}
{
if ((int)enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed");
if ((int)enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed");
}
{
if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed");
if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed");
if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed");
}
// ignore enum item tests end
{
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.llast) != 3) throw new Exception("repeatTest 5 failed");
if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
}
// different types
{
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeint) != 10) throw new Exception("differentTypes 1 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typechar) != 'C') throw new Exception("differentTypes 5 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
int global_enum = enum_thorough.global_typeint;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
global_enum = enum_thorough.global_typeboolfalse;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
global_enum = enum_thorough.global_typebooltrue;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
global_enum = enum_thorough.global_typebooltwo;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
global_enum = enum_thorough.global_typechar;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
global_enum = enum_thorough.global_typedefaultint;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
}
}
}

View File

@@ -0,0 +1,432 @@
using System;
using enum_thorough_simpleNamespace;
public class runme {
static void Main() {
{
// Anonymous enums
int i = enum_thorough_simple.AnonEnum1;
if (enum_thorough_simple.ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed");
i += enum_thorough_simple.AnonSpaceEnum1;
i += AnonStruct.AnonStructEnum1;
}
{
int red = enum_thorough_simple.red;
enum_thorough_simple.colourTest1(red);
enum_thorough_simple.colourTest2(red);
enum_thorough_simple.colourTest3(red);
enum_thorough_simple.colourTest4(red);
enum_thorough_simple.myColour = red;
}
{
SpeedClass s = new SpeedClass();
int speed = SpeedClass.slow;
if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed");
if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed");
if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed");
if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed");
if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed");
if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed");
if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed");
if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed");
if (enum_thorough_simple.speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed");
if (enum_thorough_simple.speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed");
if (enum_thorough_simple.speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed");
if (enum_thorough_simple.speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed");
if (enum_thorough_simple.speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed");
}
{
SpeedClass s = new SpeedClass();
int slow = SpeedClass.slow;
int lightning = SpeedClass.lightning;
if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed");
if (s.mySpeedtd1 != 10) throw new Exception("mySpeedtd1 2 failed");
s.mySpeedtd1 = lightning;
if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed");
if (s.mySpeedtd1 != 31) throw new Exception("mySpeedtd1 4 failed");
}
{
if (enum_thorough_simple.namedanonTest1(enum_thorough_simple.NamedAnon2) != enum_thorough_simple.NamedAnon2) throw new Exception("namedanonTest 1 failed");
}
{
int val = enum_thorough_simple.TwoNames2;
if (enum_thorough_simple.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
if (enum_thorough_simple.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
if (enum_thorough_simple.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
}
{
TwoNamesStruct t = new TwoNamesStruct();
int val = TwoNamesStruct.TwoNamesStruct1;
if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
}
{
int val = enum_thorough_simple.NamedAnonSpace2;
if (enum_thorough_simple.namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed");
if (enum_thorough_simple.namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed");
if (enum_thorough_simple.namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed");
if (enum_thorough_simple.namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed");
}
{
TemplateClassInt t = new TemplateClassInt();
int galileo = TemplateClassInt.galileo;
if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed");
if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed");
if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed");
if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed");
if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed");
if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed");
if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed");
if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed");
if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed");
// if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed");
if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed");
// if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed");
if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed");
if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed");
if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed");
if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed");
if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed");
if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed");
if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed");
if (enum_thorough_simple.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed");
if (enum_thorough_simple.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed");
if (enum_thorough_simple.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed");
if (enum_thorough_simple.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed");
if (enum_thorough_simple.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed");
if (enum_thorough_simple.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed");
if (enum_thorough_simple.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed");
if (enum_thorough_simple.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed");
}
{
TClassInt t = new TClassInt();
int bell = TClassInt.bell;
int galileo = TemplateClassInt.galileo;
if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed");
if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed");
if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed");
if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed");
if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed");
if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed");
if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed");
if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed");
if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed");
// if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed");
if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed");
// if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed");
if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed");
if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed");
if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed");
if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed");
if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed");
if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed");
if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed");
if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed");
if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed");
if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed");
if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed");
if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed");
if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed");
if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed");
if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed");
if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed");
if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed");
if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed");
if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed");
if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed");
if (enum_thorough_simple.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed");
if (enum_thorough_simple.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed");
if (enum_thorough_simple.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed");
if (enum_thorough_simple.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed");
if (enum_thorough_simple.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed");
if (enum_thorough_simple.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed");
if (enum_thorough_simple.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed");
if (enum_thorough_simple.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed");
if (enum_thorough_simple.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed");
if (enum_thorough_simple.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed");
if (enum_thorough_simple.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed");
if (enum_thorough_simple.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed");
if (enum_thorough_simple.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed");
if (enum_thorough_simple.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed");
if (enum_thorough_simple.scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed");
if (enum_thorough_simple.scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed");
if (enum_thorough_simple.scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed");
if (enum_thorough_simple.scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed");
if (enum_thorough_simple.scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed");
if (enum_thorough_simple.scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed");
if (enum_thorough_simple.scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed");
if (enum_thorough_simple.scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed");
if (enum_thorough_simple.scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed");
if (enum_thorough_simple.scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed");
if (enum_thorough_simple.scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed");
if (enum_thorough_simple.scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed");
if (enum_thorough_simple.scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed");
if (enum_thorough_simple.scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed");
}
{
int val = enum_thorough_simple.argh;
if (enum_thorough_simple.renameTest1(val) != val) throw new Exception("renameTest Global 1 failed");
if (enum_thorough_simple.renameTest2(val) != val) throw new Exception("renameTest Global 2 failed");
}
{
NewNameStruct n = new NewNameStruct();
if (n.renameTest1(NewNameStruct.bang) != NewNameStruct.bang) throw new Exception("renameTest 1 failed");
if (n.renameTest2(NewNameStruct.bang) != NewNameStruct.bang) throw new Exception("renameTest 2 failed");
if (n.renameTest3(NewNameStruct.simple1) != NewNameStruct.simple1) throw new Exception("renameTest 3 failed");
if (n.renameTest4(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest 4 failed");
if (n.renameTest5(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest 5 failed");
if (n.renameTest6(NewNameStruct.singlename1) != NewNameStruct.singlename1) throw new Exception("renameTest 6 failed");
}
{
if (enum_thorough_simple.renameTest3(NewNameStruct.bang) != NewNameStruct.bang) throw new Exception("renameTest Global 3 failed");
if (enum_thorough_simple.renameTest4(NewNameStruct.simple1) != NewNameStruct.simple1) throw new Exception("renameTest Global 4 failed");
if (enum_thorough_simple.renameTest5(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest Global 5 failed");
if (enum_thorough_simple.renameTest6(NewNameStruct.doublename1) != NewNameStruct.doublename1) throw new Exception("renameTest Global 6 failed");
if (enum_thorough_simple.renameTest7(NewNameStruct.singlename1) != NewNameStruct.singlename1) throw new Exception("renameTest Global 7 failed");
}
{
TreesClass t = new TreesClass();
int pine = TreesClass.pine;
if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed");
if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed");
if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed");
if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed");
if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed");
if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed");
if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed");
if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed");
if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed");
if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed");
if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed");
if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed");
if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed");
if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed");
if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed");
if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed");
if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed");
if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed");
if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed");
if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed");
if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed");
if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed");
if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed");
if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed");
if (enum_thorough_simple.treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed");
if (enum_thorough_simple.treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed");
if (enum_thorough_simple.treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed");
if (enum_thorough_simple.treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed");
if (enum_thorough_simple.treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed");
if (enum_thorough_simple.treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed");
if (enum_thorough_simple.treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed");
if (enum_thorough_simple.treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed");
if (enum_thorough_simple.treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed");
if (enum_thorough_simple.treesTestA(pine) != pine) throw new Exception("treesTest Global A failed");
if (enum_thorough_simple.treesTestB(pine) != pine) throw new Exception("treesTest Global B failed");
if (enum_thorough_simple.treesTestC(pine) != pine) throw new Exception("treesTest Global C failed");
if (enum_thorough_simple.treesTestD(pine) != pine) throw new Exception("treesTest Global D failed");
if (enum_thorough_simple.treesTestE(pine) != pine) throw new Exception("treesTest Global E failed");
if (enum_thorough_simple.treesTestF(pine) != pine) throw new Exception("treesTest Global F failed");
if (enum_thorough_simple.treesTestG(pine) != pine) throw new Exception("treesTest Global G failed");
if (enum_thorough_simple.treesTestH(pine) != pine) throw new Exception("treesTest Global H failed");
if (enum_thorough_simple.treesTestI(pine) != pine) throw new Exception("treesTest Global I failed");
if (enum_thorough_simple.treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed");
if (enum_thorough_simple.treesTestK(pine) != pine) throw new Exception("treesTest Global K failed");
if (enum_thorough_simple.treesTestL(pine) != pine) throw new Exception("treesTest Global L failed");
if (enum_thorough_simple.treesTestM(pine) != pine) throw new Exception("treesTest Global M failed");
// if (enum_thorough_simple.treesTestN(pine) != pine) throw new Exception("treesTest Global N failed");
if (enum_thorough_simple.treesTestO(pine) != pine) throw new Exception("treesTest Global O failed");
if (enum_thorough_simple.treesTestP(pine) != pine) throw new Exception("treesTest Global P failed");
if (enum_thorough_simple.treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed");
if (enum_thorough_simple.treesTestR(pine) != pine) throw new Exception("treesTest Global R failed");
}
{
HairStruct h = new HairStruct();
int ginger = HairStruct.ginger;
if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed");
if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed");
if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed");
if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed");
if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed");
if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed");
if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed");
if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed");
if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed");
if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed");
if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed");
int red = enum_thorough_simple.red;
if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed");
if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed");
if (h.namedanonTest1(enum_thorough_simple.NamedAnon2) != enum_thorough_simple.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed");
if (h.namedanonspaceTest1(enum_thorough_simple.NamedAnonSpace2) != enum_thorough_simple.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed");
int fir = TreesClass.fir;
if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed");
if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed");
if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed");
if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed");
}
{
int blonde = HairStruct.blonde;
if (enum_thorough_simple.hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed");
if (enum_thorough_simple.hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed");
if (enum_thorough_simple.hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed");
if (enum_thorough_simple.hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed");
if (enum_thorough_simple.hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed");
if (enum_thorough_simple.hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed");
if (enum_thorough_simple.hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed");
if (enum_thorough_simple.hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed");
if (enum_thorough_simple.hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed");
if (enum_thorough_simple.hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed");
if (enum_thorough_simple.hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed");
if (enum_thorough_simple.hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed");
if (enum_thorough_simple.hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed");
if (enum_thorough_simple.hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed");
if (enum_thorough_simple.hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed");
if (enum_thorough_simple.hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed");
if (enum_thorough_simple.hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed");
if (enum_thorough_simple.hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed");
if (enum_thorough_simple.hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed");
if (enum_thorough_simple.hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed");
if (enum_thorough_simple.hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed");
if (enum_thorough_simple.hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed");
if (enum_thorough_simple.hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed");
if (enum_thorough_simple.hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed");
if (enum_thorough_simple.hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed");
if (enum_thorough_simple.hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed");
if (enum_thorough_simple.hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed");
if (enum_thorough_simple.hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed");
if (enum_thorough_simple.hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed");
if (enum_thorough_simple.hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed");
if (enum_thorough_simple.hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed");
if (enum_thorough_simple.hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed");
if (enum_thorough_simple.hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed");
if (enum_thorough_simple.hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed");
if (enum_thorough_simple.hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed");
if (enum_thorough_simple.hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed");
if (enum_thorough_simple.hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed");
if (enum_thorough_simple.hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed");
if (enum_thorough_simple.hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed");
if (enum_thorough_simple.hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed");
if (enum_thorough_simple.hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed");
if (enum_thorough_simple.hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed");
if (enum_thorough_simple.hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed");
if (enum_thorough_simple.hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed");
if (enum_thorough_simple.hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed");
if (enum_thorough_simple.hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed");
if (enum_thorough_simple.hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed");
if (enum_thorough_simple.hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed");
}
{
FirStruct f = new FirStruct();
int blonde = HairStruct.blonde;
if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed");
if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed");
if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed");
if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed");
if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed");
if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed");
if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed");
if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed");
if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed");
if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed");
}
{
enum_thorough_simple.GlobalInstance = enum_thorough_simple.globalinstance2;
if (enum_thorough_simple.GlobalInstance != enum_thorough_simple.globalinstance2) throw new Exception("GlobalInstance 1 failed");
Instances i = new Instances();
i.MemberInstance = Instances.memberinstance3;
if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
}
// ignore enum item tests start
{
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed");
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed");
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed");
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed");
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed");
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed");
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed");
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed");
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed");
if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed");
}
{
if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed");
if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed");
if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed");
if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed");
if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed");
if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed");
}
{
if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed");
if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed");
if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed");
if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed");
if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed");
if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed");
}
{
if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed");
if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed");
}
{
if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed");
if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed");
if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed");
}
// ignore enum item tests end
{
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.llast) != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed");
}
// different types
{
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeint) != 10) throw new Exception("differentTypes 1 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typechar) != 'C') throw new Exception("differentTypes 5 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
int global_enum = enum_thorough_simple.global_typeint;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
global_enum = enum_thorough_simple.global_typeboolfalse;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
global_enum = enum_thorough_simple.global_typebooltrue;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
global_enum = enum_thorough_simple.global_typebooltwo;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
global_enum = enum_thorough_simple.global_typechar;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
global_enum = enum_thorough_simple.global_typedefaultint;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
}
}
}

View File

@@ -0,0 +1,442 @@
using System;
using enum_thorough_typesafeNamespace;
public class runme {
static void Main() {
{
// Anonymous enums
int i = enum_thorough_typesafe.AnonEnum1;
if (enum_thorough_typesafe.ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed");
i += enum_thorough_typesafe.AnonSpaceEnum1;
i += AnonStruct.AnonStructEnum1;
}
{
colour red = colour.red;
enum_thorough_typesafe.colourTest1(red);
enum_thorough_typesafe.colourTest2(red);
enum_thorough_typesafe.colourTest3(red);
enum_thorough_typesafe.colourTest4(red);
enum_thorough_typesafe.myColour = red;
}
{
SpeedClass s = new SpeedClass();
SpeedClass.speed speed = SpeedClass.speed.slow;
if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed");
if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed");
if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed");
if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed");
if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed");
if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed");
if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed");
if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed");
if (enum_thorough_typesafe.speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed");
if (enum_thorough_typesafe.speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed");
if (enum_thorough_typesafe.speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed");
if (enum_thorough_typesafe.speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed");
if (enum_thorough_typesafe.speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed");
}
{
SpeedClass s = new SpeedClass();
SpeedClass.speed slow = SpeedClass.speed.slow;
SpeedClass.speed lightning = SpeedClass.speed.lightning;
if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed");
if (s.mySpeedtd1.swigValue != 10) throw new Exception("mySpeedtd1 2 failed");
s.mySpeedtd1 = lightning;
if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed");
if (s.mySpeedtd1.swigValue != 31) throw new Exception("mySpeedtd1 4 failed");
}
{
if (enum_thorough_typesafe.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest 1 failed");
}
{
twonames val = twonames.TwoNames2;
if (enum_thorough_typesafe.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
if (enum_thorough_typesafe.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
if (enum_thorough_typesafe.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
}
{
TwoNamesStruct t = new TwoNamesStruct();
TwoNamesStruct.twonames val = TwoNamesStruct.twonames.TwoNamesStruct1;
if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
}
{
namedanonspace val = namedanonspace.NamedAnonSpace2;
if (enum_thorough_typesafe.namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed");
if (enum_thorough_typesafe.namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed");
if (enum_thorough_typesafe.namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed");
if (enum_thorough_typesafe.namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed");
}
{
TemplateClassInt t = new TemplateClassInt();
TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed");
if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed");
if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed");
if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed");
if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed");
if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed");
if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed");
if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed");
if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed");
// if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed");
if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed");
// if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed");
if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed");
if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed");
if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed");
if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed");
if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed");
if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed");
if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed");
if (enum_thorough_typesafe.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed");
if (enum_thorough_typesafe.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed");
if (enum_thorough_typesafe.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed");
if (enum_thorough_typesafe.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed");
if (enum_thorough_typesafe.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed");
if (enum_thorough_typesafe.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed");
if (enum_thorough_typesafe.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed");
if (enum_thorough_typesafe.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed");
}
{
TClassInt t = new TClassInt();
TClassInt.scientists bell = TClassInt.scientists.bell;
TemplateClassInt.scientists galileo = TemplateClassInt.scientists.galileo;
if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed");
if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed");
if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed");
if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed");
if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed");
if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed");
if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed");
if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed");
if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed");
// if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed");
if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed");
// if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed");
if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed");
if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed");
if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed");
if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed");
if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed");
if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed");
if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed");
if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed");
if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed");
if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed");
if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed");
if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed");
if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed");
if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed");
if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed");
if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed");
if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed");
if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed");
if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed");
if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed");
if (enum_thorough_typesafe.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed");
if (enum_thorough_typesafe.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed");
if (enum_thorough_typesafe.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed");
if (enum_thorough_typesafe.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed");
if (enum_thorough_typesafe.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed");
if (enum_thorough_typesafe.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed");
if (enum_thorough_typesafe.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed");
if (enum_thorough_typesafe.scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed");
}
{
newname val = newname.argh;
if (enum_thorough_typesafe.renameTest1(val) != val) throw new Exception("renameTest Global 1 failed");
if (enum_thorough_typesafe.renameTest2(val) != val) throw new Exception("renameTest Global 2 failed");
}
{
NewNameStruct n = new NewNameStruct();
if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 1 failed");
if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 2 failed");
if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest 3 failed");
if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 4 failed");
if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 5 failed");
if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest 6 failed");
}
{
if (enum_thorough_typesafe.renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest Global 3 failed");
if (enum_thorough_typesafe.renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest Global 4 failed");
if (enum_thorough_typesafe.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 5 failed");
if (enum_thorough_typesafe.renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 6 failed");
if (enum_thorough_typesafe.renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest Global 7 failed");
}
{
TreesClass t = new TreesClass();
TreesClass.trees pine = TreesClass.trees.pine;
if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed");
if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed");
if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed");
if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed");
if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed");
if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed");
if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed");
if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed");
if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed");
if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed");
if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed");
if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed");
if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed");
if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed");
if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed");
if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed");
if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed");
if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed");
if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed");
if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed");
if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed");
if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed");
if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed");
if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed");
if (enum_thorough_typesafe.treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed");
if (enum_thorough_typesafe.treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed");
if (enum_thorough_typesafe.treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed");
if (enum_thorough_typesafe.treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed");
if (enum_thorough_typesafe.treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed");
if (enum_thorough_typesafe.treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed");
if (enum_thorough_typesafe.treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed");
if (enum_thorough_typesafe.treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed");
if (enum_thorough_typesafe.treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed");
if (enum_thorough_typesafe.treesTestA(pine) != pine) throw new Exception("treesTest Global A failed");
if (enum_thorough_typesafe.treesTestB(pine) != pine) throw new Exception("treesTest Global B failed");
if (enum_thorough_typesafe.treesTestC(pine) != pine) throw new Exception("treesTest Global C failed");
if (enum_thorough_typesafe.treesTestD(pine) != pine) throw new Exception("treesTest Global D failed");
if (enum_thorough_typesafe.treesTestE(pine) != pine) throw new Exception("treesTest Global E failed");
if (enum_thorough_typesafe.treesTestF(pine) != pine) throw new Exception("treesTest Global F failed");
if (enum_thorough_typesafe.treesTestG(pine) != pine) throw new Exception("treesTest Global G failed");
if (enum_thorough_typesafe.treesTestH(pine) != pine) throw new Exception("treesTest Global H failed");
if (enum_thorough_typesafe.treesTestI(pine) != pine) throw new Exception("treesTest Global I failed");
if (enum_thorough_typesafe.treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed");
if (enum_thorough_typesafe.treesTestK(pine) != pine) throw new Exception("treesTest Global K failed");
if (enum_thorough_typesafe.treesTestL(pine) != pine) throw new Exception("treesTest Global L failed");
if (enum_thorough_typesafe.treesTestM(pine) != pine) throw new Exception("treesTest Global M failed");
// if (enum_thorough_typesafe.treesTestN(pine) != pine) throw new Exception("treesTest Global N failed");
if (enum_thorough_typesafe.treesTestO(pine) != pine) throw new Exception("treesTest Global O failed");
if (enum_thorough_typesafe.treesTestP(pine) != pine) throw new Exception("treesTest Global P failed");
if (enum_thorough_typesafe.treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed");
if (enum_thorough_typesafe.treesTestR(pine) != pine) throw new Exception("treesTest Global R failed");
}
{
HairStruct h = new HairStruct();
HairStruct.hair ginger = HairStruct.hair.ginger;
if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed");
if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed");
if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed");
if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed");
if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed");
if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed");
if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed");
if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed");
if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed");
if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed");
if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed");
colour red = colour.red;
if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed");
if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed");
if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed");
if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed");
TreesClass.trees fir = TreesClass.trees.fir;
if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed");
if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed");
if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed");
if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed");
}
{
HairStruct.hair blonde = HairStruct.hair.blonde;
if (enum_thorough_typesafe.hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed");
if (enum_thorough_typesafe.hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed");
if (enum_thorough_typesafe.hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed");
if (enum_thorough_typesafe.hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed");
if (enum_thorough_typesafe.hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed");
if (enum_thorough_typesafe.hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed");
if (enum_thorough_typesafe.hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed");
if (enum_thorough_typesafe.hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed");
if (enum_thorough_typesafe.hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed");
if (enum_thorough_typesafe.hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed");
if (enum_thorough_typesafe.hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed");
if (enum_thorough_typesafe.hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed");
if (enum_thorough_typesafe.hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed");
if (enum_thorough_typesafe.hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed");
if (enum_thorough_typesafe.hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed");
if (enum_thorough_typesafe.hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed");
if (enum_thorough_typesafe.hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed");
if (enum_thorough_typesafe.hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed");
if (enum_thorough_typesafe.hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed");
if (enum_thorough_typesafe.hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed");
if (enum_thorough_typesafe.hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed");
if (enum_thorough_typesafe.hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed");
if (enum_thorough_typesafe.hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed");
if (enum_thorough_typesafe.hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed");
if (enum_thorough_typesafe.hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed");
if (enum_thorough_typesafe.hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed");
if (enum_thorough_typesafe.hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed");
if (enum_thorough_typesafe.hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed");
if (enum_thorough_typesafe.hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed");
if (enum_thorough_typesafe.hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed");
if (enum_thorough_typesafe.hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed");
if (enum_thorough_typesafe.hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed");
if (enum_thorough_typesafe.hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed");
if (enum_thorough_typesafe.hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed");
if (enum_thorough_typesafe.hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed");
if (enum_thorough_typesafe.hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed");
if (enum_thorough_typesafe.hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed");
if (enum_thorough_typesafe.hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed");
if (enum_thorough_typesafe.hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed");
if (enum_thorough_typesafe.hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed");
if (enum_thorough_typesafe.hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed");
if (enum_thorough_typesafe.hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed");
if (enum_thorough_typesafe.hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed");
if (enum_thorough_typesafe.hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed");
if (enum_thorough_typesafe.hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed");
if (enum_thorough_typesafe.hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed");
if (enum_thorough_typesafe.hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed");
if (enum_thorough_typesafe.hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed");
}
{
FirStruct f = new FirStruct();
HairStruct.hair blonde = HairStruct.hair.blonde;
if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed");
if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed");
if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed");
if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed");
if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed");
if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed");
if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed");
if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed");
if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed");
if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed");
}
{
enum_thorough_typesafe.GlobalInstance = enum_thorough_typesafe.globalinstance2;
if (enum_thorough_typesafe.GlobalInstance != enum_thorough_typesafe.globalinstance2) throw new Exception("GlobalInstance 1 failed");
Instances i = new Instances();
i.MemberInstance = Instances.memberinstance3;
if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
}
// ignore enum item tests start
{
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue != 0) throw new Exception("ignoreATest 0 failed");
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue != 3) throw new Exception("ignoreATest 3 failed");
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue != 10) throw new Exception("ignoreATest 10 failed");
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue != 11) throw new Exception("ignoreATest 11 failed");
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue != 13) throw new Exception("ignoreATest 13 failed");
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue != 14) throw new Exception("ignoreATest 14 failed");
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue != 20) throw new Exception("ignoreATest 20 failed");
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue != 30) throw new Exception("ignoreATest 30 failed");
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue != 32) throw new Exception("ignoreATest 32 failed");
if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue != 33) throw new Exception("ignoreATest 33 failed");
}
{
if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue != 11) throw new Exception("ignoreBTest 11 failed");
if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue != 12) throw new Exception("ignoreBTest 12 failed");
if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue != 31) throw new Exception("ignoreBTest 31 failed");
if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue != 32) throw new Exception("ignoreBTest 32 failed");
if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue != 41) throw new Exception("ignoreBTest 41 failed");
if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue != 42) throw new Exception("ignoreBTest 42 failed");
}
{
if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue != 10) throw new Exception("ignoreCTest 10 failed");
if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue != 12) throw new Exception("ignoreCTest 12 failed");
if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue != 30) throw new Exception("ignoreCTest 30 failed");
if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue != 32) throw new Exception("ignoreCTest 32 failed");
if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue != 40) throw new Exception("ignoreCTest 40 failed");
if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue != 42) throw new Exception("ignoreCTest 42 failed");
}
{
if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue != 21) throw new Exception("ignoreDTest 21 failed");
if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue != 22) throw new Exception("ignoreDTest 22 failed");
}
{
if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue != 0) throw new Exception("ignoreETest 0 failed");
if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue != 21) throw new Exception("ignoreETest 21 failed");
if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue != 22) throw new Exception("ignoreETest 22 failed");
}
// ignore enum item tests end
{
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.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");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltrue).swigValue != 1) throw new Exception("differentTypes 2 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltwo).swigValue != 2) throw new Exception("differentTypes 3 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeboolfalse).swigValue != 0) throw new Exception("differentTypes 4 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typechar).swigValue != (int)'C') throw new Exception("differentTypes 5 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typedefaultint).swigValue != (int)'D') throw new Exception("differentTypes 6 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typecharcompound).swigValue != (int)'A' + 1) throw new Exception("differentTypes 7 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typecharcompound2).swigValue != (int)'B' << 2) throw new Exception("differentTypes 8 failed");
int global_enum = enum_thorough_typesafe.global_typeint;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
global_enum = enum_thorough_typesafe.global_typeboolfalse;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
global_enum = enum_thorough_typesafe.global_typebooltrue;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
global_enum = enum_thorough_typesafe.global_typebooltwo;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
global_enum = enum_thorough_typesafe.global_typechar;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
global_enum = enum_thorough_typesafe.global_typedefaultint;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
global_enum = enum_thorough_typesafe.global_typecharcompound;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != (int)'A' + 1) throw new Exception("global differentTypes 7 failed");
global_enum = enum_thorough_typesafe.global_typecharcompound2;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != (int)'B' << 2) throw new Exception("global differentTypes 8 failed");
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
using exception_orderNamespace;
public class runme {
static void Main() {
A a = new A();
try {
a.foo();
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "C++ E1 exception thrown")
throw new ApplicationException("bad exception order: " + e.Message);
}
try {
a.bar();
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "C++ E2 exception thrown")
throw new ApplicationException("bad exception order: " + e.Message);
}
try {
a.foobar();
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "postcatch unknown")
throw new ApplicationException("bad exception order: " + e.Message);
}
try {
a.barfoo(1);
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "C++ E1 exception thrown")
throw new ApplicationException("bad exception order: " + e.Message);
}
try {
a.barfoo(2);
throw new Exception("missed exception");
} catch (ApplicationException e) {
if (e.Message != "C++ E2 * exception thrown")
throw new ApplicationException("bad exception order: " + e.Message);
}
}
}

View File

@@ -0,0 +1,43 @@
using System;
using friendsNamespace;
public class friends_runme {
public static void Main() {
A a = new A(2);
if (friends.get_val1(a) != 2)
throw new Exception("failed");
if (friends.get_val2(a) != 4)
throw new Exception("failed");
if (friends.get_val3(a) != 6)
throw new Exception("failed");
// nice overload working fine
if (friends.get_val1(1,2,3) != 1)
throw new Exception("failed");
B b = new B(3);
// David's case
if (friends.mix(a,b) != 5)
throw new Exception("failed");
D_d di = new D_d(2);
D_d dd = new D_d(3.3);
// incredible template overloading working just fine
if (friends.get_val1(di) != 2)
throw new Exception("failed");
if (friends.get_val1(dd) != 3.3)
throw new Exception("failed");
friends.set(di, 4);
friends.set(dd, 1.3);
if (friends.get_val1(di) != 4)
throw new Exception("failed");
if (friends.get_val1(dd) != 1.3)
throw new Exception("failed");
}
}

View File

@@ -0,0 +1,18 @@
using System;
using importsNamespace;
public class runme
{
static void Main() {
B b = new B();
b.hello(); //call member function in A which is in a different SWIG generated library.
b.bye();
if (b.member_virtual_test(A.MemberEnum.memberenum1) != A.MemberEnum.memberenum2)
throw new Exception("Test 1 failed");
if (b.global_virtual_test(GlobalEnum.globalenum1) != GlobalEnum.globalenum2)
throw new Exception("Test 2 failed");
imports_b.global_test(A.MemberEnum.memberenum1);
}
}

View File

@@ -0,0 +1,24 @@
using System;
using inherit_target_languageNamespace;
public class inherit_target_language_runme {
public static void Main() {
new Derived1().targetLanguageBaseMethod();
new Derived2().targetLanguageBaseMethod();
new MultipleDerived1().targetLanguageBaseMethod();
new MultipleDerived2().targetLanguageBaseMethod();
new MultipleDerived3().f();
new MultipleDerived4().g();
BaseX baseX = new BaseX();
baseX.basex();
baseX.targetLanguageBase2Method();
DerivedX derivedX = new DerivedX();
derivedX.basex();
derivedX.derivedx();
derivedX.targetLanguageBase2Method();
}
}

View File

@@ -0,0 +1,21 @@
/***********************************************************************************************
NOTE: This is a custom testcase and should be run using make intermediary_classname.customtest
***********************************************************************************************/
using System;
using intermediary_classnameNamespace;
public class runme
{
static void Main()
{
// test the renamed module class is correctly named
double d = intermediary_classnameModule.maxdouble(10.0, 20.0);
if (d!=20.0) throw new Exception("Test failed");
// test the renamed intermediary class is correctly named
IntPtr ptr = intermediary_classname.new_vecdouble(10);
intermediary_classname.delete_vecdouble(new System.Runtime.InteropServices.HandleRef(null,ptr));
}
}

View File

@@ -0,0 +1,78 @@
// Ported from Python li_attribute_runme.py
using System;
using li_attributeNamespace;
public class li_attribute_runme {
public static void Main() {
A aa = new A(1,2,3);
if (aa.a != 1)
throw new ApplicationException("error");
aa.a = 3;
if (aa.a != 3)
throw new ApplicationException("error");
if (aa.b != 2)
throw new ApplicationException("error");
aa.b = 5;
if (aa.b != 5)
throw new ApplicationException("error");
if (aa.d != aa.b)
throw new ApplicationException("error");
if (aa.c != 3)
throw new ApplicationException("error");
//aa.c = 5;
//if (aa.c != 3)
// throw new ApplicationException("error");
Param_i pi = new Param_i(7);
if (pi.value != 7)
throw new ApplicationException("error");
pi.value=3;
if (pi.value != 3)
throw new ApplicationException("error");
B b = new B(aa);
if (b.a.c != 3)
throw new ApplicationException("error");
// class/struct attribute with get/set methods using return/pass by reference
MyFoo myFoo = new MyFoo();
myFoo.x = 8;
MyClass myClass = new MyClass();
myClass.Foo = myFoo;
if (myClass.Foo.x != 8)
throw new ApplicationException("error");
// class/struct attribute with get/set methods using return/pass by value
MyClassVal myClassVal = new MyClassVal();
if (myClassVal.ReadWriteFoo.x != -1)
throw new ApplicationException("error");
if (myClassVal.ReadOnlyFoo.x != -1)
throw new ApplicationException("error");
myClassVal.ReadWriteFoo = myFoo;
if (myClassVal.ReadWriteFoo.x != 8)
throw new ApplicationException("error");
if (myClassVal.ReadOnlyFoo.x != 8)
throw new ApplicationException("error");
// string attribute with get/set methods using return/pass by value
MyStringyClass myStringClass = new MyStringyClass("initial string");
if (myStringClass.ReadWriteString != "initial string")
throw new ApplicationException("error");
if (myStringClass.ReadOnlyString != "initial string")
throw new ApplicationException("error");
myStringClass.ReadWriteString = "changed string";
if (myStringClass.ReadWriteString != "changed string")
throw new ApplicationException("error");
if (myStringClass.ReadOnlyString != "changed string")
throw new ApplicationException("error");
}
}

View File

@@ -0,0 +1,27 @@
using System;
using li_boost_shared_ptr_bitsNamespace;
public class runme
{
static void Main()
{
VectorIntHolder v = new VectorIntHolder();
v.Add(new IntHolder(11));
v.Add(new IntHolder(22));
v.Add(new IntHolder(33));
int sum = li_boost_shared_ptr_bits.sum(v);
if (sum != 66)
throw new ApplicationException("sum is wrong");
HiddenDestructor hidden = HiddenDestructor.create();
hidden.Dispose();
HiddenPrivateDestructor hiddenPrivate = HiddenPrivateDestructor.create();
if (HiddenPrivateDestructor.DeleteCount != 0)
throw new ApplicationException("Count should be zero");
hiddenPrivate.Dispose();
if (HiddenPrivateDestructor.DeleteCount != 1)
throw new ApplicationException("Count should be one");
}
}

View File

@@ -0,0 +1,598 @@
using System;
using li_boost_shared_ptrNamespace;
public class runme
{
// Debugging flag
public static bool debug = false;
private static void WaitForGC()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
System.Threading.Thread.Sleep(10);
}
static void Main()
{
if (debug)
Console.WriteLine("Started");
li_boost_shared_ptr.debug_shared=debug;
// Change loop count to run for a long time to monitor memory
const int loopCount = 1; //50000;
for (int i=0; i<loopCount; i++) {
new runme().runtest();
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
if (i%100 == 0) {
System.Threading.Thread.Sleep(1); // give some time to the lower priority finalizer thread
}
}
if (debug)
Console.WriteLine("Nearly finished");
{
int countdown = 500;
int expectedCount = 1;
while (true) {
WaitForGC();
if (--countdown == 0)
break;
if (Klass.getTotal_count() == expectedCount) // Expect the one global variable (GlobalValue)
break;
}
int actualCount = Klass.getTotal_count();
if (actualCount != expectedCount)
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
}
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
if (wrapper_count != li_boost_shared_ptr.NOT_COUNTING)
if (wrapper_count != 1) // Expect the one global variable (GlobalSmartValue)
throw new ApplicationException("shared_ptr wrapper count=" + wrapper_count);
if (debug)
Console.WriteLine("Finished");
}
private void runtest() {
// simple shared_ptr usage - created in C++
{
Klass k = new Klass("me oh my");
String val = k.getValue();
verifyValue("me oh my", val);
verifyCount(1, k);
}
// simple shared_ptr usage - not created in C++
{
Klass k = li_boost_shared_ptr.factorycreate();
String val = k.getValue();
verifyValue("factorycreate", val);
verifyCount(1, k);
}
// pass by shared_ptr
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.smartpointertest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointertest", val);
verifyCount(2, k);
verifyCount(2, kret);
}
// pass by shared_ptr pointer
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.smartpointerpointertest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointerpointertest", val);
verifyCount(2, k);
verifyCount(2, kret);
}
// pass by shared_ptr reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.smartpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointerreftest", val);
verifyCount(2, k);
verifyCount(2, kret);
}
// pass by shared_ptr pointer reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.smartpointerpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointerpointerreftest", val);
verifyCount(2, k);
verifyCount(2, kret);
}
// const pass by shared_ptr
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.constsmartpointertest(k);
String val = kret.getValue();
verifyValue("me oh my", val);
verifyCount(2, k);
verifyCount(2, kret);
}
// const pass by shared_ptr pointer
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.constsmartpointerpointertest(k);
String val = kret.getValue();
verifyValue("me oh my", val);
verifyCount(2, k);
verifyCount(2, kret);
}
// const pass by shared_ptr reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.constsmartpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my", val);
verifyCount(2, k);
verifyCount(2, kret);
}
// pass by value
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.valuetest(k);
String val = kret.getValue();
verifyValue("me oh my valuetest", val);
verifyCount(1, k);
verifyCount(1, kret);
}
// pass by pointer
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.pointertest(k);
String val = kret.getValue();
verifyValue("me oh my pointertest", val);
verifyCount(1, k);
verifyCount(1, kret);
}
// pass by reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.reftest(k);
String val = kret.getValue();
verifyValue("me oh my reftest", val);
verifyCount(1, k);
verifyCount(1, kret);
}
// pass by pointer reference
{
Klass k = new Klass("me oh my");
Klass kret = li_boost_shared_ptr.pointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my pointerreftest", val);
verifyCount(1, k);
verifyCount(1, kret);
}
// null tests
{
Klass k = null;
// TODO: add in const versions too
if (li_boost_shared_ptr.smartpointertest(k) != null)
throw new ApplicationException("return was not null");
if (li_boost_shared_ptr.smartpointerpointertest(k) != null)
throw new ApplicationException("return was not null");
if (li_boost_shared_ptr.smartpointerreftest(k) != null)
throw new ApplicationException("return was not null");
if (li_boost_shared_ptr.smartpointerpointerreftest(k) != null)
throw new ApplicationException("return was not null");
if (li_boost_shared_ptr.nullsmartpointerpointertest(null) != "null pointer")
throw new ApplicationException("not null smartpointer pointer");
try { li_boost_shared_ptr.valuetest(k); throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
if (li_boost_shared_ptr.pointertest(k) != null)
throw new ApplicationException("return was not null");
try { li_boost_shared_ptr.reftest(k); throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
}
// $owner
{
Klass k = li_boost_shared_ptr.pointerownertest();
String val = k.getValue();
verifyValue("pointerownertest", val);
verifyCount(1, k);
}
{
Klass k = li_boost_shared_ptr.smartpointerpointerownertest();
String val = k.getValue();
verifyValue("smartpointerpointerownertest", val);
verifyCount(1, k);
}
////////////////////////////////// Derived classes ////////////////////////////////////////
// derived pass by shared_ptr
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_shared_ptr.derivedsmartptrtest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrtest-Derived", val);
verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
verifyCount(4, kret);
}
// derived pass by shared_ptr pointer
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_shared_ptr.derivedsmartptrpointertest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
verifyCount(4, kret);
}
// derived pass by shared_ptr ref
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_shared_ptr.derivedsmartptrreftest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrreftest-Derived", val);
verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
verifyCount(4, kret);
}
// derived pass by shared_ptr pointer ref
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_shared_ptr.derivedsmartptrpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
verifyCount(4, kret);
}
// derived pass by pointer
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_shared_ptr.derivedpointertest(k);
String val = kret.getValue();
verifyValue("me oh my derivedpointertest-Derived", val);
verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
verifyCount(2, kret);
}
// derived pass by ref
{
KlassDerived k = new KlassDerived("me oh my");
KlassDerived kret = li_boost_shared_ptr.derivedreftest(k);
String val = kret.getValue();
verifyValue("me oh my derivedreftest-Derived", val);
verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
verifyCount(2, kret);
}
////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
// pass by shared_ptr (mixed)
{
Klass k = new KlassDerived("me oh my");
Klass kret = li_boost_shared_ptr.smartpointertest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointertest-Derived", val);
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyCount(3, kret);
}
// pass by shared_ptr pointer (mixed)
{
Klass k = new KlassDerived("me oh my");
Klass kret = li_boost_shared_ptr.smartpointerpointertest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointerpointertest-Derived", val);
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyCount(3, kret);
}
// pass by shared_ptr reference (mixed)
{
Klass k = new KlassDerived("me oh my");
Klass kret = li_boost_shared_ptr.smartpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointerreftest-Derived", val);
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyCount(3, kret);
}
// pass by shared_ptr pointer reference (mixed)
{
Klass k = new KlassDerived("me oh my");
Klass kret = li_boost_shared_ptr.smartpointerpointerreftest(k);
String val = kret.getValue();
verifyValue("me oh my smartpointerpointerreftest-Derived", val);
verifyCount(3, k); // an extra reference for the upcast in the proxy class
verifyCount(3, kret);
}
// pass by value (mixed)
{
Klass k = new KlassDerived("me oh my");
Klass kret = li_boost_shared_ptr.valuetest(k);
String val = kret.getValue();
verifyValue("me oh my valuetest", val); // note slicing
verifyCount(2, k); // an extra reference for the upcast in the proxy class
verifyCount(1, kret);
}
// pass by pointer (mixed)
{
Klass k = new KlassDerived("me oh my");
Klass kret = li_boost_shared_ptr.pointertest(k);
String val = kret.getValue();
verifyValue("me oh my pointertest-Derived", val);
verifyCount(2, k); // an extra reference for the upcast in the proxy class
verifyCount(1, kret);
}
// pass by ref (mixed)
{
Klass k = new KlassDerived("me oh my");
Klass kret = li_boost_shared_ptr.reftest(k);
String val = kret.getValue();
verifyValue("me oh my reftest-Derived", val);
verifyCount(2, k); // an extra reference for the upcast in the proxy class
verifyCount(1, kret);
}
// 3rd derived class
{
Klass k = new Klass3rdDerived("me oh my");
String val = k.getValue();
verifyValue("me oh my-3rdDerived", val);
verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
val = li_boost_shared_ptr.test3rdupcast(k);
verifyValue("me oh my-3rdDerived", val);
verifyCount(3, k);
}
////////////////////////////////// Member variables ////////////////////////////////////////
// smart pointer by value
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("smart member value");
m.SmartMemberValue = k;
String val = k.getValue();
verifyValue("smart member value", val);
verifyCount(2, k);
Klass kmember = m.SmartMemberValue;
val = kmember.getValue();
verifyValue("smart member value", val);
verifyCount(3, kmember);
verifyCount(3, k);
m.Dispose();
verifyCount(2, kmember);
verifyCount(2, k);
}
// smart pointer by pointer
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("smart member pointer");
m.SmartMemberPointer = k;
String val = k.getValue();
verifyValue("smart member pointer", val);
verifyCount(1, k);
Klass kmember = m.SmartMemberPointer;
val = kmember.getValue();
verifyValue("smart member pointer", val);
verifyCount(2, kmember);
verifyCount(2, k);
m.Dispose();
verifyCount(2, kmember);
verifyCount(2, k);
}
// smart pointer by reference
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("smart member reference");
m.SmartMemberReference = k;
String val = k.getValue();
verifyValue("smart member reference", val);
verifyCount(2, k);
Klass kmember = m.SmartMemberReference;
val = kmember.getValue();
verifyValue("smart member reference", val);
verifyCount(3, kmember);
verifyCount(3, k);
// The C++ reference refers to SmartMemberValue...
Klass kmemberVal = m.SmartMemberValue;
val = kmember.getValue();
verifyValue("smart member reference", val);
verifyCount(4, kmemberVal);
verifyCount(4, kmember);
verifyCount(4, k);
m.Dispose();
verifyCount(3, kmember);
verifyCount(3, k);
}
// plain by value
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("plain member value");
m.MemberValue = k;
String val = k.getValue();
verifyValue("plain member value", val);
verifyCount(1, k);
Klass kmember = m.MemberValue;
val = kmember.getValue();
verifyValue("plain member value", val);
verifyCount(1, kmember);
verifyCount(1, k);
m.Dispose();
verifyCount(1, kmember);
verifyCount(1, k);
}
// plain by pointer
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("plain member pointer");
m.MemberPointer = k;
String val = k.getValue();
verifyValue("plain member pointer", val);
verifyCount(1, k);
Klass kmember = m.MemberPointer;
val = kmember.getValue();
verifyValue("plain member pointer", val);
verifyCount(1, kmember);
verifyCount(1, k);
m.Dispose();
verifyCount(1, kmember);
verifyCount(1, k);
}
// plain by reference
{
MemberVariables m = new MemberVariables();
Klass k = new Klass("plain member reference");
m.MemberReference = k;
String val = k.getValue();
verifyValue("plain member reference", val);
verifyCount(1, k);
Klass kmember = m.MemberReference;
val = kmember.getValue();
verifyValue("plain member reference", val);
verifyCount(1, kmember);
verifyCount(1, k);
m.Dispose();
verifyCount(1, kmember);
verifyCount(1, k);
}
// null member variables
{
MemberVariables m = new MemberVariables();
// shared_ptr by value
Klass k = m.SmartMemberValue;
if (k != null)
throw new ApplicationException("expected null");
m.SmartMemberValue = null;
k = m.SmartMemberValue;
if (k != null)
throw new ApplicationException("expected null");
verifyCount(0, k);
// plain by value
try { m.MemberValue = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
}
////////////////////////////////// Global variables ////////////////////////////////////////
// smart pointer
{
Klass kglobal = li_boost_shared_ptr.GlobalSmartValue;
if (kglobal != null)
throw new ApplicationException("expected null");
Klass k = new Klass("smart global value");
li_boost_shared_ptr.GlobalSmartValue = k;
verifyCount(2, k);
kglobal = li_boost_shared_ptr.GlobalSmartValue;
String val = kglobal.getValue();
verifyValue("smart global value", val);
verifyCount(3, kglobal);
verifyCount(3, k);
verifyValue("smart global value", li_boost_shared_ptr.GlobalSmartValue.getValue());
li_boost_shared_ptr.GlobalSmartValue = null;
}
// plain value
{
Klass kglobal;
Klass k = new Klass("global value");
li_boost_shared_ptr.GlobalValue = k;
verifyCount(1, k);
kglobal = li_boost_shared_ptr.GlobalValue;
String val = kglobal.getValue();
verifyValue("global value", val);
verifyCount(1, kglobal);
verifyCount(1, k);
verifyValue("global value", li_boost_shared_ptr.GlobalValue.getValue());
try { li_boost_shared_ptr.GlobalValue = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
}
// plain pointer
{
Klass kglobal = li_boost_shared_ptr.GlobalPointer;
if (kglobal != null)
throw new ApplicationException("expected null");
Klass k = new Klass("global pointer");
li_boost_shared_ptr.GlobalPointer = k;
verifyCount(1, k);
kglobal = li_boost_shared_ptr.GlobalPointer;
String val = kglobal.getValue();
verifyValue("global pointer", val);
verifyCount(1, kglobal);
verifyCount(1, k);
li_boost_shared_ptr.GlobalPointer = null;
}
// plain reference
{
Klass kglobal;
Klass k = new Klass("global reference");
li_boost_shared_ptr.GlobalReference = k;
verifyCount(1, k);
kglobal = li_boost_shared_ptr.GlobalReference;
String val = kglobal.getValue();
verifyValue("global reference", val);
verifyCount(1, kglobal);
verifyCount(1, k);
try { li_boost_shared_ptr.GlobalReference = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
}
////////////////////////////////// Templates ////////////////////////////////////////
{
PairIntDouble pid = new PairIntDouble(10, 20.2);
if (pid.baseVal1 != 20 || pid.baseVal2 != 40.4)
throw new ApplicationException("Base values wrong");
if (pid.val1 != 10 || pid.val2 != 20.2)
throw new ApplicationException("Derived Values wrong");
}
}
private void verifyValue(String expected, String got) {
if (expected != got)
throw new Exception("verify value failed. Expected: " + expected + " Got: " + got);
}
private void verifyCount(int expected, Klass k) {
int got = li_boost_shared_ptr.use_count(k);
if (expected != got)
throw new Exception("verify use_count failed. Expected: " + expected + " Got: " + got);
}
}

View File

@@ -0,0 +1,57 @@
using System;
using li_std_auto_ptrNamespace;
public class li_std_auto_ptr_runme {
private static void WaitForGC()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
System.Threading.Thread.Sleep(10);
}
public static void Main()
{
Klass k1 = li_std_auto_ptr.makeKlassAutoPtr("first");
if (k1.getLabel() != "first")
throw new Exception("wrong object label");
Klass k2 = li_std_auto_ptr.makeKlassAutoPtr("second");
if (Klass.getTotal_count() != 2)
throw new Exception("number of objects should be 2");
k1 = null;
{
int countdown = 500;
int expectedCount = 1;
while (true) {
WaitForGC();
if (--countdown == 0)
break;
if (Klass.getTotal_count() == expectedCount)
break;
};
int actualCount = Klass.getTotal_count();
if (actualCount != expectedCount)
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
}
if (k2.getLabel() != "second")
throw new Exception("wrong object label");
k2 = null;
{
int countdown = 500;
int expectedCount = 0;
while (true) {
WaitForGC();
if (--countdown == 0)
break;
if (Klass.getTotal_count() == expectedCount)
break;
}
int actualCount = Klass.getTotal_count();
if (actualCount != expectedCount)
Console.Error.WriteLine("Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
}
}
}

View File

@@ -0,0 +1,31 @@
using System;
using li_std_combinationsNamespace;
public class li_std_combinations_runme {
public static void Main() {
VectorPairIntString vpis = new VectorPairIntString();
vpis.Add(new PairIntString(123, "one hundred and twenty three"));
VectorString vs = new VectorString();
vs.Add("hi");
PairIntVectorString pivs = new PairIntVectorString(456, vs);
if (pivs.second[0] != "hi")
throw new ApplicationException("PairIntVectorString");
VectorVectorString vvs = new VectorVectorString();
vvs.Add(vs);
PairIntPairIntString pipis = new PairIntPairIntString(12, new PairIntString(3, "4"));
if (pipis.first != 12)
throw new ApplicationException("PairIntPairIntString");
PairDoubleString pds = new PairDoubleString(12.34, "okay");
VectorPairDoubleString vpds = new VectorPairDoubleString();
vpds.Add(pds);
// Check SWIG_STD_VECTOR_ENHANCED macro - it provides the Contains method
if (!vpds.Contains(pds))
throw new ApplicationException("VectorPairDoubleString");
}
}

View File

@@ -0,0 +1,25 @@
// This test tests all the methods in the C# collection wrapper
using System;
using li_std_exceptNamespace;
public class li_std_except_runme {
public static void Main() {
Test test = new Test();
try { test.throw_bad_cast(); throw new Exception("throw_bad_cast failed"); } catch (InvalidCastException) {}
try { test.throw_bad_exception(); throw new Exception("throw_bad_exception failed"); } catch (ApplicationException) {}
try { test.throw_domain_error(); throw new Exception("throw_domain_error failed"); } catch (ApplicationException) {}
try { test.throw_exception(); throw new Exception("throw_exception failed"); } catch (ApplicationException) {}
try { test.throw_invalid_argument(); throw new Exception("throw_invalid_argument failed"); } catch (ArgumentException) {}
try { test.throw_length_error(); throw new Exception("throw_length_error failed"); } catch (IndexOutOfRangeException) {}
try { test.throw_logic_error(); throw new Exception("throw_logic_error failed"); } catch (ApplicationException) {}
try { test.throw_out_of_range(); throw new Exception("throw_out_of_range failed"); } catch (ArgumentOutOfRangeException) {}
try { test.throw_overflow_error(); throw new Exception("throw_overflow_error failed"); } catch (OverflowException) {}
try { test.throw_range_error(); throw new Exception("throw_range_error failed"); } catch (IndexOutOfRangeException) {}
try { test.throw_runtime_error(); throw new Exception("throw_runtime_error failed"); } catch (ApplicationException) {}
try { test.throw_underflow_error(); throw new Exception("throw_underflow_error failed"); } catch (OverflowException) {}
}
}

View File

@@ -0,0 +1,246 @@
/* -----------------------------------------------------------------------------
* li_std_map_runme.cs
*
* SWIG C# tester for std_map.i
* This class tests all the functionality of the std_map.i wrapper.
* Upon successful testing, the main function doesn't print out anything.
* If any error is found - it will be printed on the screen.
* ----------------------------------------------------------------------------- */
using System;
using System.Collections.Generic;
using li_std_mapNamespace;
public class li_std_map_runme {
private static readonly int collectionSize = 20;
private static readonly int midCollection = collectionSize / 2;
public static void Main()
{
// Set up an int int map
StringIntMap simap = new StringIntMap();
for (int i = 0; i < collectionSize; i++)
{
int val = i * 18;
simap.Add(i.ToString(), val);
}
// Count property test
if (simap.Count != collectionSize)
throw new Exception("Count test failed");
// IsReadOnly property test
if (simap.IsReadOnly)
throw new Exception("IsReadOnly test failed");
// Item indexing test
simap["0"] = 200;
if (simap["0"] != 200)
throw new Exception("Item property test failed");
simap["0"] = 0 * 18;
// ContainsKey() test
for (int i = 0; i < collectionSize; i++)
{
if (!simap.ContainsKey(i.ToString()))
throw new Exception("ContainsKey test " + i + " failed");
}
// ContainsKey() test
for (int i = 0; i < collectionSize; i++)
{
if (!simap.Contains(new KeyValuePair<string, int>(i.ToString(), i * 18)))
throw new Exception("Contains test " + i + " failed");
}
// TryGetValue() test
int value;
bool rc = simap.TryGetValue("3", out value);
if (rc != true || value != (3 * 18))
throw new Exception("TryGetValue test 1 failed");
rc = simap.TryGetValue("-1", out value);
if (rc != false)
throw new Exception("TryGetValue test 2 failed");
// Keys and Values test
{
IList<string> keys = new List<string>(simap.Keys);
IList<int> values = new List<int>(simap.Values);
Dictionary<string, int> check = new Dictionary<string, int>();
if (keys.Count != collectionSize)
throw new Exception("Keys count test failed");
if (values.Count != collectionSize)
throw new Exception("Values count test failed");
for (int i = 0; i < keys.Count; i++)
{
if (simap[keys[i]] != values[i])
throw new Exception("Keys and values test failed for index " + i);
check.Add(keys[i], values[i]);
}
for (int i = 0; i < collectionSize; i++)
{
if (!check.ContainsKey(i.ToString()))
throw new Exception("Keys and Values ContainsKey test " + i + " failed");
}
}
// Add and Remove test
for (int i = 100; i < 103; i++)
{
simap.Add(i.ToString(), i * 18);
if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
throw new Exception("Add test failed for index " + i);
simap.Remove(i.ToString());
if (simap.ContainsKey(i.ToString()))
throw new Exception("Remove test failed for index " + i);
}
for (int i = 200; i < 203; i++)
{
simap.Add(new KeyValuePair<string, int>(i.ToString(), i * 18));
if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
throw new Exception("Add explicit test failed for index " + i);
simap.Remove(new KeyValuePair<string, int>(i.ToString(), i * 18));
if (simap.ContainsKey(i.ToString()))
throw new Exception("Remove explicit test failed for index " + i);
}
// Duplicate key test
try
{
simap.Add("3", 0);
throw new Exception("Adding duplicate key test failed");
}
catch (ArgumentException)
{
}
// CopyTo() test
{
KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize];
simap.CopyTo(outputarray);
foreach (KeyValuePair<string, int> val in outputarray)
{
if (simap[val.Key] != val.Value)
throw new Exception("CopyTo (1) test failed, index:" + val.Key);
}
}
{
KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[midCollection + collectionSize];
simap.CopyTo(outputarray, midCollection);
for (int i = midCollection; i < midCollection + collectionSize; i++)
{
KeyValuePair<string, int> val = outputarray[i];
if (simap[val.Key] != val.Value)
throw new Exception("CopyTo (2) test failed, index:" + val.Key);
}
}
{
KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize - 1];
try
{
simap.CopyTo(outputarray);
throw new Exception("CopyTo (4) test failed");
}
catch (ArgumentException)
{
}
}
// Clear test
simap.Clear();
if (simap.Count != 0)
throw new Exception("Clear test failed");
// Test wrapped methods
for (int i = 1; i <= 5; i++)
{
simap[i.ToString()] = i;
}
double avg = li_std_map.valueAverage(simap);
if (avg != 3.0)
throw new Exception("Wrapped method valueAverage test failed. Got " + avg);
string keyStringified = li_std_map.stringifyKeys(simap);
if (keyStringified != " 1 2 3 4 5")
throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified);
// Test a map with a new complex type (Struct)
{
IntStructMap ismap = new IntStructMap();
for (int i = 0; i < 10; i++)
{
ismap.Add(i, new Struct(i * 10.1));
}
if (ismap.Count != 10)
throw new Exception("Count test on complex type map failed");
foreach (KeyValuePair<int, Struct> p in ismap)
{
if ((p.Key * 10.1) != p.Value.num)
throw new Exception("Iteration test on complex type map failed for index " + p.Key);
}
}
// Test a map of pointers
{
IntStructPtrMap ispmap = new IntStructPtrMap();
for (int i = 0; i < 10; i++)
{
ispmap.Add(i, new Struct(i * 10.1));
}
if (ispmap.Count != 10)
throw new Exception("Count test on complex type pointer map failed");
foreach (KeyValuePair<int, Struct> p in ispmap)
{
if ((p.Key * 10.1) != p.Value.num)
throw new Exception("Iteration test on complex type pointer map failed for index " + p.Key);
}
}
{
IntStructConstPtrMap iscpmap = new IntStructConstPtrMap();
for (int i = 0; i < 10; i++)
{
iscpmap.Add(i, new Struct(i * 10.1));
}
if (iscpmap.Count != 10)
throw new Exception("Count test on complex type const pointer map failed");
foreach (KeyValuePair<int, Struct> p in iscpmap)
{
if ((p.Key * 10.1) != p.Value.num)
throw new Exception("Iteration test on complex type const pointer map failed for index " + p.Key);
}
}
// Test complex type as key (Struct)
{
StructIntMap limap = new StructIntMap();
Struct s7 = new Struct(7);
Struct s8 = new Struct(8);
limap[s7] = 8;
if (limap[s7] != 8)
throw new Exception("Assignment test on complex key map failed");
if (!limap.ContainsKey(s7))
throw new Exception("Key test (1) on complex key map failed");
if (limap.ContainsKey(s8))
throw new Exception("Key test (2) on complex key map failed");
}
// All done
}
}

View File

@@ -0,0 +1,100 @@
using System;
using li_std_stringNamespace;
public class runme
{
static void Main()
{
// Checking expected use of %typemap(in) std::string {}
li_std_string.test_value("Fee");
// Checking expected result of %typemap(out) std::string {}
if (li_std_string.test_value("Fi") != "Fi")
throw new Exception("Test 1 failed");
// Verify type-checking for %typemap(in) std::string {}
try {
li_std_string.test_value(null);
throw new Exception("Test 2 failed");
} catch (ArgumentNullException) {
}
// Checking expected use of %typemap(in) const std::string & {}
li_std_string.test_const_reference("Fo");
// Checking expected result of %typemap(out) const std::string& {}
if (li_std_string.test_const_reference("Fum") != "Fum")
throw new Exception("Test 3 failed");
// Verify type-checking for %typemap(in) const std::string & {}
try {
li_std_string.test_const_reference(null);
throw new Exception("Test 4 failed");
} catch (ArgumentNullException) {
}
//
// Input and output typemaps for pointers and non-const references to
// std::string are *not* supported; the following tests confirm
// that none of these cases are slipping through.
//
SWIGTYPE_p_std__string stringPtr = null;
stringPtr = li_std_string.test_pointer_out();
li_std_string.test_pointer(stringPtr);
stringPtr = li_std_string.test_const_pointer_out();
li_std_string.test_const_pointer(stringPtr);
stringPtr = li_std_string.test_reference_out();
li_std_string.test_reference(stringPtr);
// Check throw exception specification
try {
li_std_string.test_throw();
throw new Exception("Test 5 failed");
} catch (ApplicationException e) {
if (e.Message != "test_throw message")
throw new Exception("Test 5 string check: " + e.Message);
}
try {
li_std_string.test_const_reference_throw();
throw new Exception("Test 6 failed");
} catch (ApplicationException e) {
if (e.Message != "test_const_reference_throw message")
throw new Exception("Test 6 string check: " + e.Message);
}
// Global variables
const string s = "initial string";
if (li_std_string.GlobalString2 != "global string 2")
throw new Exception("GlobalString2 test 1");
li_std_string.GlobalString2 = s;
if (li_std_string.GlobalString2 != s)
throw new Exception("GlobalString2 test 2");
if (li_std_string.ConstGlobalString != "const global string")
throw new Exception("ConstGlobalString test");
// Member variables
Structure myStructure = new Structure();
if (myStructure.MemberString2 != "member string 2")
throw new Exception("MemberString2 test 1");
myStructure.MemberString2 = s;
if (myStructure.MemberString2 != s)
throw new Exception("MemberString2 test 2");
if (myStructure.ConstMemberString != "const member string")
throw new Exception("ConstMemberString test");
if (Structure.StaticMemberString2 != "static member string 2")
throw new Exception("StaticMemberString2 test 1");
Structure.StaticMemberString2 = s;
if (Structure.StaticMemberString2 != s)
throw new Exception("StaticMemberString2 test 2");
if (Structure.ConstStaticMemberString != "const static member string")
throw new Exception("ConstStaticMemberString test");
}
}

View File

@@ -0,0 +1,27 @@
// This test tests all the methods in the C# collection wrapper
using System;
using li_std_vector_enumNamespace;
public class li_std_vector_enum_runme {
public static void Main() {
EnumVector ev = new EnumVector();
check((int)ev.nums[0], 10);
check((int)ev.nums[1], 20);
check((int)ev.nums[2], 30);
int expected = 10;
foreach (EnumVector.numbers val in ev.nums) {
check((int)val, expected);
expected += 10;
}
}
private static void check(int a, int b) {
if (a != b)
throw new ApplicationException("values don't match");
}
}

View File

@@ -0,0 +1,625 @@
// This test tests all the methods in the C# collection wrapper
using System;
using li_std_vectorNamespace;
public class li_std_vector_runme {
private static readonly int collectionSize = 20;
private static readonly int midCollection = collectionSize/2;
public static DoubleVector myDoubleVector;
public static RealVector myRealVector;
public static void Main() {
// Setup collection
DoubleVector vect = new DoubleVector();
for (int i=0; i<collectionSize; i++) {
double num = i*10.1;
vect.Add(num);
}
// Count property test
if (vect.Count != collectionSize)
throw new Exception("Count test failed");
// IsFixedSize property test
if (vect.IsFixedSize)
throw new Exception("IsFixedSize test failed");
// IsReadOnly property test
if (vect.IsReadOnly)
throw new Exception("IsReadOnly test failed");
// Item indexing
vect[0] = 200.1;
if (vect[0] != 200.1)
throw new Exception("Item property test failed");
vect[0] = 0*10.1;
try {
vect[-1] = 777.1;
throw new Exception("Item out of range (1) test failed");
} catch (ArgumentOutOfRangeException) {
}
try {
vect[vect.Count] = 777.1;
throw new Exception("Item out of range (2) test failed");
} catch (ArgumentOutOfRangeException) {
}
// CopyTo() test
{
double[] outputarray = new double[collectionSize];
vect.CopyTo(outputarray);
int index = 0;
foreach(double val in outputarray) {
if (vect[index] != val)
throw new Exception("CopyTo (1) test failed, index:" + index);
index++;
}
}
{
double[] outputarray = new double[midCollection+collectionSize];
vect.CopyTo(outputarray, midCollection);
int index = midCollection;
foreach(double val in vect) {
if (outputarray[index] != val)
throw new Exception("CopyTo (2) test failed, index:" + index);
index++;
}
}
{
double[] outputarray = new double[3];
vect.CopyTo(10, outputarray, 1, 2);
if (outputarray[0] != 0.0 || outputarray[1] != vect[10] || outputarray[2] != vect[11])
throw new Exception("CopyTo (3) test failed");
}
{
double[] outputarray = new double[collectionSize-1];
try {
vect.CopyTo(outputarray);
throw new Exception("CopyTo (4) test failed");
} catch (ArgumentException) {
}
}
{
StructVector inputvector = new StructVector();
int arrayLen = 10;
for (int i=0; i<arrayLen; i++) {
inputvector.Add(new Struct(i/10.0));
}
Struct[] outputarray = new Struct[arrayLen];
inputvector.CopyTo(outputarray);
for(int i=0; i<arrayLen; i++) {
if (outputarray[i].num != inputvector[i].num)
throw new Exception("CopyTo (6) test failed, i:" + i);
}
foreach (Struct s in inputvector) {
s.num += 20.0;
}
for(int i=0; i<arrayLen; i++) {
if (outputarray[i].num + 20.0 != inputvector[i].num )
throw new Exception("CopyTo (7) test failed (only a shallow copy was made), i:" + i);
}
}
{
try {
vect.CopyTo(null);
throw new Exception("CopyTo (8) test failed");
} catch (ArgumentNullException) {
}
}
// Contains() test
if (!vect.Contains(0*10.1))
throw new Exception("Contains test 1 failed");
if (!vect.Contains(10*10.1))
throw new Exception("Contains test 2 failed");
if (!vect.Contains(19*10.1))
throw new Exception("Contains test 3 failed");
if (vect.Contains(20*10.1))
throw new Exception("Contains test 4 failed");
{
// ICollection constructor
double[] doubleArray = new double[] { 0.0, 11.1, 22.2, 33.3, 44.4, 55.5, 33.3 };
DoubleVector dv = new DoubleVector(doubleArray);
if (doubleArray.Length != dv.Count)
throw new Exception("ICollection constructor length check failed: " + doubleArray.Length + "-" + dv.Count);
for (int i=0; i<doubleArray.Length; i++) {
if (doubleArray[i] != dv[i])
throw new Exception("ICollection constructor failed, index:" + i);
}
{
Struct[] structArray = new Struct[] { new Struct(0.0), new Struct(11.1), new Struct(22.2), new Struct(33.3) };
StructVector sv = new StructVector(structArray);
for (int i=0; i<structArray.Length; i++) {
structArray[i].num += 200.0;
}
for (int i=0; i<structArray.Length; i++) {
if (structArray[i].num != sv[i].num + 200.0)
throw new Exception("ICollection constructor not a deep copy, index:" + i);
}
}
try {
new DoubleVector((System.Collections.ICollection)null);
throw new Exception("ICollection constructor null test failed");
} catch (ArgumentNullException) {
}
{
// Collection initializer test, requires C# 3.0
// myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 };
}
// IndexOf() test
for (int i=0; i<collectionSize; i++) {
if (vect.IndexOf(i*10.1) != i)
throw new Exception("IndexOf test " + i + " failed");
}
if (vect.IndexOf(200.1) != -1)
throw new Exception("IndexOf non-existent test failed");
if (dv.IndexOf(33.3) != 3)
throw new Exception("IndexOf position test failed");
// LastIndexOf() test
for (int i=0; i<collectionSize; i++) {
if (vect.LastIndexOf(i*10.1) != i)
throw new Exception("LastIndexOf test " + i + " failed");
}
if (vect.LastIndexOf(200.1) != -1)
throw new Exception("LastIndexOf non-existent test failed");
if (dv.LastIndexOf(33.3) != 6)
throw new Exception("LastIndexOf position test failed");
// Copy constructor test
DoubleVector dvCopy = new DoubleVector(dv);
for (int i=0; i<doubleArray.Length; i++) {
if (doubleArray[i] != dvCopy[i])
throw new Exception("Copy constructor failed, index:" + i);
}
}
{
// Repeat() test
try {
myDoubleVector = DoubleVector.Repeat(77.7, -1);
throw new Exception("Repeat negative count test failed");
} catch (ArgumentOutOfRangeException) {
}
DoubleVector dv = DoubleVector.Repeat(77.7, 5);
if (dv.Count != 5)
throw new Exception("Repeat count test failed");
// Also tests enumerator
{
System.Collections.IEnumerator myEnumerator = dv.GetEnumerator();
while ( myEnumerator.MoveNext() ) {
if ((double)myEnumerator.Current != 77.7)
throw new Exception("Repeat (1) test failed");
}
}
{
System.Collections.Generic.IEnumerator<double> myEnumerator = dv.GetEnumerator();
while ( myEnumerator.MoveNext() ) {
if (myEnumerator.Current != 77.7)
throw new Exception("Repeat (2) test failed");
}
}
}
{
// InsertRange() test
DoubleVector dvect = new DoubleVector();
for (int i=0; i<5; i++) {
dvect.Add(1000.0*i);
}
vect.InsertRange(midCollection, dvect);
if (vect.Count != collectionSize+dvect.Count)
throw new Exception("InsertRange test size failed");
for (int i=0; i<midCollection; i++) {
if (vect.IndexOf(i*10.1) != i)
throw new Exception("InsertRange (1) test " + i + " failed");
}
for (int i=0; i<dvect.Count; i++) {
if (vect[i+midCollection] != dvect[i])
throw new Exception("InsertRange (2) test " + i + " failed");
}
for (int i=midCollection; i<collectionSize; i++) {
if (vect.IndexOf(i*10.1) != i+dvect.Count)
throw new Exception("InsertRange (3) test " + i + " failed");
}
try {
vect.InsertRange(0, null);
throw new Exception("InsertRange (4) test failed");
} catch (ArgumentNullException) {
}
// RemoveRange() test
vect.RemoveRange(0, 0);
vect.RemoveRange(midCollection, dvect.Count);
if (vect.Count != collectionSize)
throw new Exception("RemoveRange test size failed");
for (int i=0; i<collectionSize; i++) {
if (vect.IndexOf(i*10.1) != i)
throw new Exception("RemoveRange test " + i + " failed");
}
try {
vect.RemoveRange(-1, 0);
throw new Exception("RemoveRange index out of range (1) test failed");
} catch (ArgumentOutOfRangeException) {
}
try {
vect.RemoveRange(0, -1);
throw new Exception("RemoveRange count out of range (2) test failed");
} catch (ArgumentOutOfRangeException) {
}
try {
vect.RemoveRange(collectionSize+1, 0);
throw new Exception("RemoveRange index and count out of range (1) test failed");
} catch (ArgumentException) {
}
try {
vect.RemoveRange(0, collectionSize+1);
throw new Exception("RemoveRange index and count out of range (2) test failed");
} catch (ArgumentException) {
}
// AddRange() test
vect.AddRange(dvect);
if (vect.Count != collectionSize+dvect.Count)
throw new Exception("AddRange test size failed");
for (int i=0; i<collectionSize; i++) {
if (vect.IndexOf(i*10.1) != i)
throw new Exception("AddRange (1) test " + i + " failed");
}
for (int i=0; i<dvect.Count; i++) {
if (vect[i+collectionSize] != dvect[i])
throw new Exception("AddRange (2) test " + i + " failed");
}
try {
vect.AddRange(null);
throw new Exception("AddRange (3) test failed");
} catch (ArgumentNullException) {
}
vect.RemoveRange(collectionSize, dvect.Count);
// GetRange() test
int rangeSize = 5;
DoubleVector returnedVec = vect.GetRange(0, 0);
returnedVec = vect.GetRange(midCollection, rangeSize);
if (returnedVec.Count != rangeSize)
throw new Exception("GetRange test size failed");
for (int i=0; i<rangeSize; i++) {
if (returnedVec.IndexOf((i+midCollection)*10.1) != i)
throw new Exception("GetRange test " + i + " failed");
}
try {
vect.GetRange(-1, 0);
throw new Exception("GetRange index out of range (1) test failed");
} catch (ArgumentOutOfRangeException) {
}
try {
vect.GetRange(0, -1);
throw new Exception("GetRange count out of range (2) test failed");
} catch (ArgumentOutOfRangeException) {
}
try {
vect.GetRange(collectionSize+1, 0);
throw new Exception("GetRange index and count out of range (1) test failed");
} catch (ArgumentException) {
}
try {
vect.GetRange(0, collectionSize+1);
throw new Exception("GetRange index and count out of range (2) test failed");
} catch (ArgumentException) {
}
{
StructVector inputvector = new StructVector();
int arrayLen = 10;
for (int i=0; i<arrayLen; i++) {
inputvector.Add(new Struct(i/10.0));
}
StructVector outputvector = inputvector.GetRange(0,arrayLen);
for(int i=0; i<arrayLen; i++) {
if (outputvector[i].num != inputvector[i].num)
throw new Exception("GetRange (1) test failed, i:" + i);
}
foreach (Struct s in inputvector) {
s.num += 20.0;
}
for(int i=0; i<arrayLen; i++) {
if (outputvector[i].num + 20.0 != inputvector[i].num )
throw new Exception("GetRange (2) test failed (only a shallow copy was made), i:" + i);
}
}
}
// Insert() test
int pos = 0;
int count = vect.Count;
vect.Insert(pos, -5.1);
count++;
if (vect.Count != count || vect[pos] != -5.1)
throw new Exception("Insert at beginning test failed");
pos = midCollection;
vect.Insert(pos, 85.1);
count++;
if (vect.Count != count || vect[pos] != 85.1)
throw new Exception("Insert at " + pos + " test failed");
pos = vect.Count;
vect.Insert(pos, 195.1);
count++;
if (vect.Count != count || vect[pos] != 195.1)
throw new Exception("Insert at end test failed");
pos = vect.Count+1;
try {
vect.Insert(pos, 222.1); // should throw
throw new Exception("Insert after end (1) test failed");
} catch (ArgumentOutOfRangeException) {
}
if (vect.Count != count)
throw new Exception("Insert after end (2) test failed");
pos = -1;
try {
vect.Insert(pos, 333.1); // should throw
throw new Exception("Insert before start (1) test failed");
} catch (ArgumentOutOfRangeException) {
}
if (vect.Count != count)
throw new Exception("Insert before start (2) test failed");
// Remove() test
vect.Remove(195.1);
count--;
vect.Remove(-5.1);
count--;
vect.Remove(85.1);
count--;
vect.Remove(9999.1); // element does not exist, should quietly do nothing
if (vect.Count != count)
throw new Exception("Remove count check test failed");
for (int i=0; i<collectionSize; i++) {
if (vect[i] != i*10.1)
throw new Exception("Remove test failed, index:" + i);
}
// RemoveAt() test
vect.Insert(0, -4.1);
vect.Insert(midCollection, 84.1);
vect.Insert(vect.Count, 194.1);
vect.RemoveAt(vect.Count-1);
vect.RemoveAt(midCollection);
vect.RemoveAt(0);
try {
vect.RemoveAt(-1);
throw new Exception("RemoveAt test (1) failed");
} catch (ArgumentOutOfRangeException) {
}
try {
vect.RemoveAt(vect.Count);
throw new Exception("RemoveAt test (2) failed");
} catch (ArgumentOutOfRangeException) {
}
for (int i=0; i<collectionSize; i++) {
if (vect[i] != i*10.1)
throw new Exception("RemoveAt test (3) failed, index:" + i);
}
{
// Capacity test
try {
myDoubleVector = new DoubleVector(-1);
throw new Exception("constructor setting capacity (1) test failed");
} catch (ArgumentOutOfRangeException) {
}
DoubleVector dv = new DoubleVector(10);
if (dv.Capacity != 10 || dv.Count != 0)
throw new Exception("constructor setting capacity (2) test failed");
dv.Capacity = 20;
if (dv.Capacity != 20)
throw new Exception("capacity test (1) failed");
dv.Add(1.11);
try {
dv.Capacity = dv.Count-1;
throw new Exception("capacity test (2) failed");
} catch (ArgumentOutOfRangeException) {
}
// SetRange() test
for (int i=dv.Count; i<collectionSize; i++) {
dv.Add(0.0);
}
dv.SetRange(0, vect);
if (dv.Count != collectionSize)
throw new Exception("SetRange count check test failed");
for (int i=0; i<collectionSize; i++) {
if (vect[i] != dv[i])
throw new Exception("SetRange test (1) failed, index:" + i);
}
try {
dv.SetRange(-1, vect);
throw new Exception("SetRange test (2) failed");
} catch (ArgumentOutOfRangeException) {
}
try {
dv.SetRange(1, vect);
throw new Exception("SetRange test (3) failed");
} catch (ArgumentOutOfRangeException) {
}
try {
vect.SetRange(0, null);
throw new Exception("SetRange (4) test failed");
} catch (ArgumentNullException) {
}
// Reverse() test
dv.Reverse();
for (int i=0; i<collectionSize; i++) {
if (vect[i] != dv[collectionSize-i-1])
throw new Exception("Reverse test (1) failed, index:" + i);
}
dv.Reverse(0, collectionSize);
for (int i=0; i<collectionSize; i++) {
if (vect[i] != dv[i])
throw new Exception("Reverse test (2) failed, index:" + i);
}
dv.Reverse(0, 0); // should do nothing!
for (int i=0; i<collectionSize; i++) {
if (vect[i] != dv[i])
throw new Exception("Reverse test (3) failed, index:" + i);
}
try {
dv.Reverse(-1, 0);
throw new Exception("Reverse test (4) failed");
} catch (ArgumentOutOfRangeException) {
}
try {
dv.Reverse(0, -1);
throw new Exception("Reverse test (5) failed");
} catch (ArgumentOutOfRangeException) {
}
try {
dv.Reverse(collectionSize+1, 0);
throw new Exception("Reverse test (6) failed");
} catch (ArgumentException) {
}
try {
dv.Reverse(0, collectionSize+1);
throw new Exception("Reverse test (7) failed");
} catch (ArgumentException) {
}
}
// foreach test
{
int index=0;
foreach (double s in vect) {
if (s != index*10.1)
throw new Exception("foreach test failed, index:" + index);
index++;
}
}
// Clear() test
vect.Clear();
if (vect.Count != 0)
throw new Exception("Clear failed");
// Finally test the methods being wrapped
{
IntVector iv = new IntVector();
for (int i=0; i<4; i++) {
iv.Add(i);
}
double x = li_std_vector.average(iv);
x += li_std_vector.average( new IntVector( new int[] {1, 2, 3, 4} ) );
myRealVector = li_std_vector.half( new RealVector( new float[] {10F, 10.5F, 11F, 11.5F} ) );
DoubleVector dvec = new DoubleVector();
for (int i=0; i<10; i++) {
dvec.Add(i/2.0);
}
li_std_vector.halve_in_place(dvec);
}
// Dispose()
{
using (StructVector vs = new StructVector( new Struct[] { new Struct(0.0), new Struct(11.1) } ) )
using (DoubleVector vd = new DoubleVector( new double[] { 0.0, 11.1 } ) ) {
}
}
// More wrapped methods
{
RealVector v0 = li_std_vector.vecreal(new RealVector());
float flo = 123.456f;
v0.Add(flo);
flo = v0[0];
IntVector v1 = li_std_vector.vecintptr(new IntVector());
IntPtrVector v2 = li_std_vector.vecintptr(new IntPtrVector());
IntConstPtrVector v3 = li_std_vector.vecintconstptr(new IntConstPtrVector());
v1.Add(123);
v2.Clear();
v3.Clear();
StructVector v4 = li_std_vector.vecstruct(new StructVector());
StructPtrVector v5 = li_std_vector.vecstructptr(new StructPtrVector());
StructConstPtrVector v6 = li_std_vector.vecstructconstptr(new StructConstPtrVector());
v4.Add(new Struct(123));
v5.Add(new Struct(123));
v6.Add(new Struct(123));
}
// Test vectors of pointers
{
StructPtrVector inputvector = new StructPtrVector();
int arrayLen = 10;
for (int i=0; i<arrayLen; i++) {
inputvector.Add(new Struct(i/10.0));
}
Struct[] outputarray = new Struct[arrayLen];
inputvector.CopyTo(outputarray);
for(int i=0; i<arrayLen; i++) {
if (outputarray[i].num != inputvector[i].num)
throw new Exception("StructPtrVector test (1) failed, i:" + i);
}
foreach (Struct s in inputvector) {
s.num += 20.0;
}
for(int i=0; i<arrayLen; i++) {
if (outputarray[i].num != 20.0 + i/10.0)
throw new Exception("StructPtrVector test (2) failed (a deep copy was incorrectly made), i:" + i);
}
int rangeSize = 5;
int mid = arrayLen/2;
StructPtrVector returnedVec = inputvector.GetRange(mid, rangeSize);
for (int i=0; i<rangeSize; i++) {
if (inputvector[i+mid].num != returnedVec[i].num)
throw new Exception("StructPtrVector test (3) failed, i:" + i);
}
}
// Test vectors of const pointers
{
StructConstPtrVector inputvector = new StructConstPtrVector();
int arrayLen = 10;
for (int i=0; i<arrayLen; i++) {
inputvector.Add(new Struct(i/10.0));
}
Struct[] outputarray = new Struct[arrayLen];
inputvector.CopyTo(outputarray);
for(int i=0; i<arrayLen; i++) {
if (outputarray[i].num != inputvector[i].num)
throw new Exception("StructConstPtrVector test (1) failed, i:" + i);
}
foreach (Struct s in inputvector) {
s.num += 20.0;
}
for(int i=0; i<arrayLen; i++) {
if (outputarray[i].num != 20.0 + i/10.0)
throw new Exception("StructConstPtrVector test (2) failed (a deep copy was incorrectly made), i:" + i);
}
int rangeSize = 5;
int mid = arrayLen/2;
StructConstPtrVector returnedVec = inputvector.GetRange(mid, rangeSize);
for (int i=0; i<rangeSize; i++) {
if (inputvector[i+mid].num != returnedVec[i].num)
throw new Exception("StructConstPtrVector test (3) failed, i:" + i);
}
}
}
}

View File

@@ -0,0 +1,76 @@
using System;
using li_std_wstringNamespace;
public class runme
{
static void Main()
{
char y='h';
if (li_std_wstring.test_wcvalue(y) != y)
throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue(y));
if (li_std_wstring.test_wcvalue_w() != 'W')
throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue_w());
string x="hello";
if (li_std_wstring.test_ccvalue(x) != x)
throw new Exception("bad string mapping");
if (li_std_wstring.test_cvalue(x) != x)
throw new Exception("bad string mapping");
if (li_std_wstring.test_value(x) != x)
throw new Exception("bad string mapping: " + x + li_std_wstring.test_value(x));
if (li_std_wstring.test_const_reference(x) != x)
throw new Exception("bad string mapping");
string s = "he";
s = s + "llo";
if (s != x)
throw new Exception("bad string mapping: " + s + x);
if (li_std_wstring.test_value(s) != x)
throw new Exception("bad string mapping");
if (li_std_wstring.test_const_reference(s) != x)
throw new Exception("bad string mapping");
string a = s;
if (li_std_wstring.test_value(a) != x)
throw new Exception("bad string mapping");
if (li_std_wstring.test_const_reference(a) != x)
throw new Exception("bad string mapping");
string b = " world";
if (a + b != "hello world")
throw new Exception("bad string mapping");
if (a + " world" != "hello world")
throw new Exception("bad string mapping");
if ("hello" + b != "hello world")
throw new Exception("bad string mapping");
s = "hello world";
B myB = new B("hi");
myB.name = "hello";
if (myB.name != "hello")
throw new Exception("bad string mapping");
myB.a = "hello";
if (myB.a != "hello")
throw new Exception("bad string mapping");
}
}

View File

@@ -0,0 +1,56 @@
using System;
using li_swigtype_inoutNamespace;
public class li_swigtype_inout_runme {
public static void Main() {
XXX xxx = new XXX(999);
check_count(1);
XXX x1 = null;
XXX x2 = null;
XXX x3 = null;
XXX x4 = null;
li_swigtype_inout.ptr_ref_out(out x1, out x2, out x3, out x4);
check_value(111, x1.value);
check_value(222, x2.value);
check_value(333, x3.value);
check_value(444, x4.value);
check_count(5);
x1.Dispose();
x2.Dispose();
x3.Dispose();
x4.Dispose();
xxx.Dispose();
check_count(0);
x1 = null;
x2 = null;
x3 = null;
x4 = null;
new ConstructorTest(out x1, out x2, out x3, out x4);
check_count(4);
check_value(111, x1.value);
check_value(222, x2.value);
check_value(333, x3.value);
check_value(444, x4.value);
x1.Dispose();
x2.Dispose();
x3.Dispose();
x4.Dispose();
check_count(0);
}
public static void check_count(int count) {
int actual = XXX.count;
if( count != actual ) {
throw new Exception(String.Format("Count wrong. Expected: {0} Got: {1}", count, actual));
}
}
public static void check_value(int expected, int actual) {
if( expected != actual ) {
throw new Exception(String.Format("Wrong value. Expected: {0} Got: {1}", expected, actual));
}
}
}

View File

@@ -0,0 +1,101 @@
// Check a few of the INPUT, OUTPUT and INOUT typemaps.
using System;
using li_typemapsNamespace;
public class runme
{
static void Main()
{
// Check double INPUT typemaps
if (li_typemaps.in_double(22.22) != 22.22) exit_test("in_double");
if (li_typemaps.inr_double(22.22) != 22.22) exit_test("inr_double");
// Check double OUTPUT typemaps
{
double var = 44.44;
li_typemaps.out_double(22.22, out var);
if (var != 22.22) exit_test("out_double");
}
{
double var = 44.44;
li_typemaps.outr_double(22.22, out var);
if (var != 22.22) exit_test("outr_double");
}
// Check double INOUT typemaps
{
double var = 44.44;
li_typemaps.inout_double(ref var);
if (var != 44.44) exit_test("inout_double");
}
{
double var = 44.44;
li_typemaps.inoutr_double(ref var);
if (var != 44.44) exit_test("inoutr_double");
}
// Check unsigned long long INPUT typemaps
if (li_typemaps.in_ulonglong(20) != 20) exit_test("in_ulonglong");
if (li_typemaps.inr_ulonglong(20) != 20) exit_test("inr_ulonglong");
// Check unsigned long long OUTPUT typemaps
{
ulong var = 40;
li_typemaps.out_ulonglong(20, out var);
if (var != 20) exit_test("out_ulonglong");
}
{
ulong var = 40;
li_typemaps.outr_ulonglong(20, out var);
if (var != 20) exit_test("outr_ulonglong");
}
// Check unsigned long long INOUT typemaps
{
ulong var = 40;
li_typemaps.inout_ulonglong(ref var);
if (var != 40) exit_test("inout_ulonglong");
}
{
ulong var = 40;
li_typemaps.inoutr_ulonglong(ref var);
if (var != 40) exit_test("inoutr_ulonglong");
}
// Check unsigned bool INPUT typemaps
if (li_typemaps.in_bool(false) != false) exit_test("in_bool");
if (li_typemaps.inr_bool(false) != false) exit_test("inr_bool");
// Check unsigned bool OUTPUT typemaps
{
bool var = false;
li_typemaps.out_bool(true, out var);
if (var != true) exit_test("out_bool");
}
{
bool var = false;
li_typemaps.outr_bool(true, out var);
if (var != true) exit_test("outr_bool");
}
// Check unsigned bool INOUT typemaps
{
bool var = false;
li_typemaps.inout_bool(ref var);
if (var != false) exit_test("inout_bool");
}
{
bool var = false;
li_typemaps.inoutr_bool(ref var);
if (var != false) exit_test("inoutr_bool");
}
}
private static void exit_test(String funcName) {
throw new Exception("Test FAILED in function " + funcName);
}
}

View File

@@ -0,0 +1,41 @@
// This is the long_long runtime testcase. It checks that the long long and
// unsigned long long types work.
using System;
using long_longNamespace;
public class long_long_runme {
public static void Main() {
check_ll(0L);
check_ll(0x7FFFFFFFFFFFFFFFL);
check_ll(-10);
check_ull(0);
check_ull(127);
check_ull(128);
check_ull(9223372036854775807); //0x7FFFFFFFFFFFFFFFL
check_ull(18446744073709551615); //0xFFFFFFFFFFFFFFFFL
}
public static void check_ll(long ll) {
long_long.ll = ll;
long ll_check = long_long.ll;
if (ll != ll_check) {
string ErrorMessage = "Runtime test using long long failed. ll=" + ll + " ll_check=" + ll_check;
throw new Exception(ErrorMessage);
}
}
public static void check_ull(ulong ull) {
long_long.ull = ull;
ulong ull_check = long_long.ull;
if (ull != ull_check) {
string ErrorMessage = "Runtime test using unsigned long long failed. ull=" + ull + " ull_check=" + ull_check;
throw new Exception(ErrorMessage);
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
using member_pointerNamespace;
public class runme {
public static SWIGTYPE_m_Shape__f_void__double memberPtr = null;
static void Main() {
// Get the pointers
SWIGTYPE_m_Shape__f_void__double area_pt = member_pointer.areapt();
SWIGTYPE_m_Shape__f_void__double perim_pt = member_pointer.perimeterpt();
// Create some objects
Square s = new Square(10);
// Do some calculations
check( "Square area ", 100.0, member_pointer.do_op(s,area_pt) );
check( "Square perim", 40.0, member_pointer.do_op(s,perim_pt) );
memberPtr = member_pointer.areavar;
memberPtr = member_pointer.perimetervar;
// Try the variables
check( "Square area ", 100.0, member_pointer.do_op(s,member_pointer.areavar) );
check( "Square perim", 40.0, member_pointer.do_op(s,member_pointer.perimetervar) );
// Modify one of the variables
member_pointer.areavar = perim_pt;
check( "Square perimeter", 40.0, member_pointer.do_op(s,member_pointer.areavar) );
// Try the constants
memberPtr = member_pointer.AREAPT;
memberPtr = member_pointer.PERIMPT;
memberPtr = member_pointer.NULLPT;
check( "Square area ", 100.0, member_pointer.do_op(s,member_pointer.AREAPT) );
check( "Square perim", 40.0, member_pointer.do_op(s,member_pointer.PERIMPT) );
}
private static void check(string what, double expected, double actual) {
if (expected != actual)
throw new ApplicationException("Failed: " + what + " Expected: " + expected + " Actual: " + actual);
}
}

View File

@@ -0,0 +1,245 @@
using System;
using multiple_inheritance_abstractNamespace;
public class multiple_inheritance_abstract_runme {
//Test base class as a parameter in C#
int jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(bool fail, string msg) {
if (fail)
throw new Exception(msg);
}
public static void Main() {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in C#
multiple_inheritance_abstract_runme mhar=new multiple_inheritance_abstract_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_abstract.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_abstract.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_abstract.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_abstract.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_abstract.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_abstract.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_abstract.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_abstract.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_abstract.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_abstract.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_abstract.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_abstract.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_abstract.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_abstract.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_abstract.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_abstract.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_abstract.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_abstract.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_abstract.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_abstract.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_abstract.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_abstract.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_abstract.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_abstract.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_abstract.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_abstract.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View File

@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using multiple_inheritance_interfacesNamespace;
public class multiple_inheritance_interfaces_runme {
static string SortArrayToString(string[] types) {
Array.Sort<string>(types);
return string.Join(" ", types);
}
static string SortArrayToString(Type[] types) {
List<string> stypes = new List<string>();
foreach (Type t in types)
stypes.Add(t.Name);
return SortArrayToString(stypes.ToArray());
}
private static void checkBaseAndInterfaces(Type cls, bool interfaceExpected, string baseClass, string[] interfaces) {
string[] expectedInterfaces = new string[interfaces.Length + (interfaceExpected ? 0 : 1)];
for (int i=0; i<interfaces.Length; ++i)
expectedInterfaces[i] = interfaces[i];
if (!interfaceExpected)
expectedInterfaces[interfaces.Length] = "IDisposable";
Type[] actualInterfaces = cls.GetInterfaces();
string expectedInterfacesString = SortArrayToString(expectedInterfaces);
string actualInterfacesString = SortArrayToString(actualInterfaces);
if (expectedInterfacesString != actualInterfacesString)
throw new Exception("Expected interfaces for " + cls.Name + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString);
string expectedBaseString = null;
if (interfaceExpected) {
// expecting an interface
if (!cls.IsInterface)
throw new Exception(cls.Name + " should be an interface but is not");
expectedBaseString = string.IsNullOrEmpty(baseClass) ? "" : "multiple_inheritance_interfacesNamespace." + baseClass;
} else {
// expecting a class
if (cls.IsInterface)
throw new Exception(cls.Name + " is an interface but it should not be");
expectedBaseString = string.IsNullOrEmpty(baseClass) ? "Object" : baseClass;
}
string actualBaseString = cls.BaseType == null ? "" : cls.BaseType.Name;
if (expectedBaseString != actualBaseString)
throw new Exception("Expected base for " + cls.Name + ": [" + expectedBaseString + "]" + " Actual base: [" + actualBaseString + "]");
}
public static void Main() {
// Note that we can't get just the immediate interface
// Type.GetInterfaces() returns all interfaces up the inheritance hierarchy
checkBaseAndInterfaces(typeof(IA), true, "", new string[] {});
checkBaseAndInterfaces(typeof(IB), true, "", new string[] {});
checkBaseAndInterfaces(typeof(IC), true, "", new string[] {"IA", "IB"});
checkBaseAndInterfaces(typeof(A), false, "", new string[] {"IA"});
checkBaseAndInterfaces(typeof(B), false, "", new string[] {"IB"});
checkBaseAndInterfaces(typeof(C), false, "", new string[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(typeof(D), false, "", new string[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(typeof(E), false, "D", new string[] {"IA", "IB", "IC"});
checkBaseAndInterfaces(typeof(IJ), true, "", new string[] {});
checkBaseAndInterfaces(typeof(IK), true, "", new string[] {"IJ"});
checkBaseAndInterfaces(typeof(IL), true, "", new string[] {"IJ", "IK"});
checkBaseAndInterfaces(typeof(J), false, "", new string[] {"IJ"});
checkBaseAndInterfaces(typeof(K), false, "", new string[] {"IJ", "IK"});
checkBaseAndInterfaces(typeof(L), false, "", new string[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(typeof(M), false, "", new string[] {"IJ", "IK", "IL"});
checkBaseAndInterfaces(typeof(P), false, "", new string[] {});
checkBaseAndInterfaces(typeof(IQ), true, "", new string[] {});
checkBaseAndInterfaces(typeof(Q), false, "", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(R), false, "P", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(S), false, "P", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(T), false, "", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(U), false, "R", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(V), false, "S", new string[] {"IQ"});
checkBaseAndInterfaces(typeof(W), false, "T", new string[] {"IQ"});
// overloaded methods check
D d = new D();
d.ia();
d.ia(10);
d.ia("bye");
d.ia("bye", false);
}
}

View File

@@ -0,0 +1,246 @@
using System;
using multiple_inheritance_nspaceNamespace;
using multiple_inheritance_nspaceNamespace.Space;
public class multiple_inheritance_nspace_runme {
//Test base class as a parameter in C#
int jcbase1b(CBase1SwigInterface cb1){
return cb1.cbase1y();
}
int jabase1(ABase1SwigInterface ab1){
return ab1.abase1();
}
int jcbase2(CBase2SwigInterface cb2){
return cb2.cbase2();
}
public static void check(bool fail, string msg) {
if (fail)
throw new Exception(msg);
}
public static void Main() {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1SwigInterface cb1=new CBase1();
CBase2SwigInterface cb2=new CBase2();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test nspace class as return value
ABase1SwigInterface ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1SwigInterface cb6=d2.cloneit();
CBase2SwigInterface cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1SwigInterface cb3=new Derived1();
CBase1SwigInterface cb4=new Derived3();
CBase2SwigInterface cb5=new Derived3();
ABase1SwigInterface ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in C#
multiple_inheritance_nspace_runme mhar=new multiple_inheritance_nspace_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_nspace.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_nspace.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_nspace.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_nspace.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_nspace.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_nspace.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_nspace.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_nspace.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_nspace.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_nspace.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_nspace.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_nspace.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_nspace.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_nspace.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_nspace.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_nspace.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_nspace.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_nspace.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_nspace.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_nspace.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_nspace.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_nspace.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_nspace.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_nspace.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_nspace.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_nspace.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_nspace.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_nspace.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
}
}

View File

@@ -0,0 +1,329 @@
using System;
using multiple_inheritance_shared_ptrNamespace;
public class multiple_inheritance_shared_ptr_runme {
//Test base class as a parameter in C#
int jcbase1b(CBase1 cb1){
return cb1.cbase1y();
}
int jabase1(ABase1 ab1){
return ab1.abase1();
}
int jcbase2(CBase2 cb2){
return cb2.cbase2();
}
public static void check(bool fail, string msg) {
if (fail)
throw new Exception(msg);
}
public static void Main() {
//Test Derived1
Derived1 d1=new Derived1();
check(d1.cbase1y()!=3, "Derived1::cbase1y() failed");
check(d1.cbase2()!=4, "Derived1::cbase2() failed");
//Test Derived2
Derived2 d2=new Derived2();
check(d2.cbase1y()!=6, "Derived2::cbase1y() failed");
check(d2.abase1()!=5, "Derived2::abase1() failed");
//Test Derived3
Derived3 d3=new Derived3();
check(d3.cbase1y()!=7, "Derived3::cbase1y() failed");
check(d3.cbase2()!=8, "Derived3::cbase2() failed");
check(d3.abase1()!=9, "Derived3::abase1() failed");
//Test Bottom1
Bottom1 b1=new Bottom1();
check(b1.cbase1y()!=103, "Bottom1::cbase1y() failed");
check(b1.cbase2()!=104, "Bottom1::cbase2() failed");
//Test Bottom2
Bottom2 b2=new Bottom2();
check(b2.cbase1y()!=206, "Bottom2::cbase1y() failed");
check(b2.abase1()!=205, "Bottom2::abase1() failed");
//Test Bottom3
Bottom3 b3=new Bottom3();
check(b3.cbase1y()!=307, "Bottom3::cbase1y() failed");
check(b3.cbase2()!=308, "Bottom3::cbase2() failed");
check(b3.abase1()!=309, "Bottom3::abase1() failed");
//Test interfaces from c++ classes
CBase1 cb1=new CBase1SwigImpl();
CBase2 cb2=new CBase2SwigImpl();
check(cb1.cbase1y()!=1, "CBase1::cbase1y() failed");
check(cb2.cbase2()!=2, "CBase2::cbase2() failed");
//Test abstract class as return value
ABase1 ab1=d3.cloneit();
check(ab1.abase1()!=9, "Derived3::abase1() through ABase1 failed");
//Test concrete base class as return value
CBase1 cb6=d2.cloneit();
CBase2 cb7=d1.cloneit();
check(cb6.cbase1y()!=6, "Derived2::cbase1y() through CBase1 failed");
check(cb7.cbase2()!=4, "Derived1:cbase2() through ABase1 failed");
//Test multi inheritance
CBase1 cb3=new Derived1();
CBase1 cb4=new Derived3();
CBase2 cb5=new Derived3();
ABase1 ab6=new Derived2();
check(cb3.cbase1y()!=3, "Derived1::cbase1y() through CBase1 failed");
check(cb4.cbase1y()!=7, "Derived3::cbase1y() through CBase1 failed");
check(cb5.cbase2()!=8, "Derived3::cbase2() through CBase2 failed");
check(ab6.abase1()!=5, "Derived2::abase1() through ABase1 failed");
//Test base classes as parameter in C#
multiple_inheritance_shared_ptr_runme mhar=new multiple_inheritance_shared_ptr_runme();
check(mhar.jcbase1b(d1)!=3, "jcbase1b() through Derived1 as parameter failed");
check(mhar.jcbase1b(d2)!=6, "jcbase1b() through Derived2 as parameter failed");
check(mhar.jcbase1b(d3)!=7, "jcbase1b() through Derived3 as parameter failed");
check(mhar.jcbase2(d1)!=4, "jcbase2() through Derived1 as parameter failed");
check(mhar.jcbase2(d3)!=8, "jcbase2() through Derived3 as parameter failed");
check(mhar.jabase1(d2)!=5, "jabase1() through Derived2 as parameter failed");
check(mhar.jabase1(d3)!=9, "jabase1() through Derived3 as parameter failed");
//Value parameters
//Test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
check(multiple_inheritance_shared_ptr.InputValCBase1(d1)!=1, "InputValCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d2)!=1, "InputValCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(d3)!=1, "InputValCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d3)!=2, "InputValCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(d1)!=2, "InputValCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(cb1)!=1, "InputValCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(cb2)!=2, "InputValCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b1)!=1, "InputValCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b2)!=1, "InputValCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase1(b3)!=1, "InputValCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b3)!=2, "InputValCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputValCBase2(b1)!=2, "InputValCBase2(), Bottom1 as a parameter failed");
//Pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputPtrABase1(d2)!=5, "InputPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(d3)!=9, "InputPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b2)!=205, "InputPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrABase1(b3)!=309, "InputPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d1)!=3, "InputPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d2)!=6, "InputPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(d3)!=7, "InputPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d3)!=8, "InputPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(d1)!=4, "InputPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(cb1)!=1, "InputPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(cb2)!=2, "InputPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b1)!=103, "InputPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b2)!=206, "InputPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase1(b3)!=307, "InputPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b3)!=308, "InputPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputPtrCBase2(b1)!=104, "InputPtrCBase2(), Bottom1 as a parameter failed");
//Reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputRefABase1(d2)!=5, "InputRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(d3)!=9, "InputRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b2)!=205, "InputRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefABase1(b3)!=309, "InputRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputRefCBase1(d1)!=3, "InputRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d2)!=6, "InputRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(d3)!=7, "InputRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d3)!=8, "InputRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(d1)!=4, "InputRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(cb1)!=1, "InputRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(cb2)!=2, "InputRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b1)!=103, "InputRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b2)!=206, "InputRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase1(b3)!=307, "InputRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b3)!=308, "InputRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputRefCBase2(b1)!=104, "InputRefCBase2(), Bottom1 as a parameter failed");
//Const reference pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d2)!=5, "InputCPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(d3)!=9, "InputCPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b2)!=205, "InputCPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefABase1(b3)!=309, "InputCPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d1)!=3, "InputCPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d2)!=6, "InputCPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(d3)!=7, "InputCPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d3)!=8, "InputCPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(d1)!=4, "InputCPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(cb1)!=1, "InputCPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(cb2)!=2, "InputCPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b1)!=103, "InputCPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b2)!=206, "InputCPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase1(b3)!=307, "InputCPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b3)!=308, "InputCPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefCBase2(b1)!=104, "InputCPtrRefCBase2(), Bottom1 as a parameter failed");
//Shared pointer parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d2)!=5, "InputSharedPtrABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(d3)!=9, "InputSharedPtrABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b2)!=205, "InputSharedPtrABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrABase1(b3)!=309, "InputSharedPtrABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d1)!=3, "InputSharedPtrCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d2)!=6, "InputSharedPtrCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(d3)!=7, "InputSharedPtrCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d3)!=8, "InputSharedPtrCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(d1)!=4, "InputSharedPtrCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(cb1)!=1, "InputSharedPtrCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(cb2)!=2, "InputSharedPtrCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b1)!=103, "InputSharedPtrCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b2)!=206, "InputSharedPtrCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase1(b3)!=307, "InputSharedPtrCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b3)!=308, "InputSharedPtrCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrCBase2(b1)!=104, "InputSharedPtrCBase2(), Bottom1 as a parameter failed");
//Shared pointer reference parameters
//Test ABase1 as a parameter
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d2)!=5, "InputSharedPtrRefABase1() through Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(d3)!=9, "InputSharedPtrRefABase1() through Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b2)!=205, "InputSharedPtrRefABase1() through Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefABase1(b3)!=309, "InputSharedPtrRefABase1() through Bottom3 as a parameter failed");
//Test CBase1 CBase2 as parameters
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d1)!=3, "InputSharedPtrRefCBase1(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d2)!=6, "InputSharedPtrRefCBase1(), Derived2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(d3)!=7, "InputSharedPtrRefCBase1(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d3)!=8, "InputSharedPtrRefCBase2(), Derived3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(d1)!=4, "InputSharedPtrRefCBase2(), Derived1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(cb1)!=1, "InputSharedPtrRefCBase1(), CBase1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(cb2)!=2, "InputSharedPtrRefCBase2(), CBase2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b1)!=103, "InputSharedPtrRefCBase1(), Bottom1 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b2)!=206, "InputSharedPtrRefCBase1(), Bottom2 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase1(b3)!=307, "InputSharedPtrRefCBase1(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b3)!=308, "InputSharedPtrRefCBase2(), Bottom3 as a parameter failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefCBase2(b1)!=104, "InputSharedPtrRefCBase2(), Bottom1 as a parameter failed");
//Derived classes as parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(d1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(d2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(d3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(d1)!=3+4, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(d2)!=6+5, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(d3)!=7+8+9, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(d1)!=3+4, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(d2)!=6+5, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(d3)!=7+8+9, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(d1)!=3+4, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(d2)!=6+5, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(d3)!=7+8+9, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(d1)!=3+4, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(d2)!=6+5, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(d3)!=7+8+9, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(d1)!=3+4, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(d2)!=6+5, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(d3)!=7+8+9, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Derived parameters
check(multiple_inheritance_shared_ptr.InputValDerived1(b1)!=3+4, "InputValDerived1() failed");
check(multiple_inheritance_shared_ptr.InputValDerived2(b2)!=6+5, "InputValDerived2() failed");
check(multiple_inheritance_shared_ptr.InputValDerived3(b3)!=7+8+9, "InputValDerived3() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived1(b1)!=103+104, "InputRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived2(b2)!=206+205, "InputRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputRefDerived3(b3)!=307+308+309, "InputRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived1(b1)!=103+104, "InputPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived2(b2)!=206+205, "InputPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputPtrDerived3(b3)!=307+308+309, "InputPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived1(b1)!=103+104, "InputCPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived2(b2)!=206+205, "InputCPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefDerived3(b3)!=307+308+309, "InputCPtrRefDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived1(b1)!=103+104, "InputSharedPtrDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived2(b2)!=206+205, "InputSharedPtrDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrDerived3(b3)!=307+308+309, "InputSharedPtrDerived3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived1(b1)!=103+104, "InputSharedPtrRefDerived1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived2(b2)!=206+205, "InputSharedPtrRefDerived2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefDerived3(b3)!=307+308+309, "InputSharedPtrRefDerived3() failed");
//Bottom classes as Bottom parameters
check(multiple_inheritance_shared_ptr.InputValBottom1(b1)!=103+104, "InputValBottom1() failed");
check(multiple_inheritance_shared_ptr.InputValBottom2(b2)!=206+205, "InputValBottom2() failed");
check(multiple_inheritance_shared_ptr.InputValBottom3(b3)!=307+308+309, "InputValBottom3() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom1(b1)!=103+104, "InputRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom2(b2)!=206+205, "InputRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputRefBottom3(b3)!=307+308+309, "InputRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom1(b1)!=103+104, "InputPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom2(b2)!=206+205, "InputPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputPtrBottom3(b3)!=307+308+309, "InputPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom1(b1)!=103+104, "InputSharedPtrBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom2(b2)!=206+205, "InputSharedPtrBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrBottom3(b3)!=307+308+309, "InputSharedPtrBottom3() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom1(b1)!=103+104, "InputSharedPtrRefBottom1() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom2(b2)!=206+205, "InputSharedPtrRefBottom2() failed");
check(multiple_inheritance_shared_ptr.InputSharedPtrRefBottom3(b3)!=307+308+309, "InputSharedPtrRefBottom3() failed");
// Return pointers
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_CBase1().cbase1y()!=6, "MakePtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived2_ABase1().abase1()!=5, "MakePtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_ABase1().abase1()!=9, "MakePtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase1().cbase1y()!=7, "MakePtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakePtrDerived3_CBase2().cbase2()!=8, "MakePtrDerived3_CBase2 failed");
// Return references
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase1().cbase1y()!=3, "MakeRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived1_CBase2().cbase2()!=4, "MakeRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_CBase1().cbase1y()!=6, "MakeRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived2_ABase1().abase1()!=5, "MakeRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_ABase1().abase1()!=9, "MakeRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
// Return by value (sliced objects)
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived2_CBase1().cbase1y()!=1, "MakeValDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase1().cbase1y()!=1, "MakeValDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeValDerived3_CBase2().cbase2()!=2, "MakeValDerived3_CBase2 failed");
// Return smart pointers
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived1_CBase2().cbase2()!=4, "MakeSharedPtrDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived2_ABase1().abase1()!=5, "MakeSharedPtrDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_ABase1().abase1()!=9, "MakeSharedPtrDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrDerived3_CBase2().cbase2()!=8, "MakeSharedPtrDerived3_CBase2 failed");
// Return smart pointers
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase1().cbase1y()!=3, "MakeSharedPtrRefDerived1_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived1_CBase2().cbase2()!=4, "MakeSharedPtrRefDerived1_CBase2 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_CBase1().cbase1y()!=6, "MakeSharedPtrRefDerived2_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived2_ABase1().abase1()!=5, "MakeSharedPtrRefDerived2_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_ABase1().abase1()!=9, "MakeSharedPtrRefDerived3_ABase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase1().cbase1y()!=7, "MakeSharedPtrRefDerived3_CBase1 failed");
check(multiple_inheritance_shared_ptr.MakeSharedPtrRefDerived3_CBase2().cbase2()!=8, "MakeSharedPtrRefDerived3_CBase2 failed");
}
}

View File

@@ -0,0 +1,66 @@
using System;
using nested_classNamespace;
#pragma warning disable 219
public class runme {
static void Main() {
Outer outer = new Outer();
outer.a = 1;
outer.b = 2;
Outer.InnerStruct1 is1 = outer.makeInnerStruct1();
Outer.InnerClass1 ic1 = outer.makeInnerClass1();
Outer.InnerUnion1 iu1 = outer.makeInnerUnion1();
Outer.InnerStruct2 is2 = outer.makeInnerStruct2();
Outer.InnerClass2 ic2 = outer.makeInnerClass2();
Outer.InnerUnion2 iu2 = outer.makeInnerUnion2();
Outer.InnerClass4Typedef ic4 = outer.makeInnerClass4Typedef();
Outer.InnerStruct4Typedef is4 = outer.makeInnerStruct4Typedef();
Outer.InnerUnion4Typedef iu4 = outer.makeInnerUnion4Typedef();
Outer.InnerClass5Typedef ic5 = outer.makeInnerClass5();
Outer.InnerStruct5Typedef is5 = outer.makeInnerStruct5();
Outer.InnerUnion5Typedef iu5 = outer.makeInnerUnion5();
ic5 = outer.makeInnerClass5Typedef();
is5 = outer.makeInnerStruct5Typedef();
iu5 = outer.makeInnerUnion5Typedef();
{
Outer.InnerMultiple im1 = outer.MultipleInstance1;
Outer.InnerMultiple im2 = outer.MultipleInstance2;
Outer.InnerMultiple im3 = outer.MultipleInstance3;
Outer.InnerMultiple im4 = outer.MultipleInstance4;
}
{
Outer.InnerMultipleDerived im1 = outer.MultipleDerivedInstance1;
Outer.InnerMultipleDerived im2 = outer.MultipleDerivedInstance2;
Outer.InnerMultipleDerived im3 = outer.MultipleDerivedInstance3;
Outer.InnerMultipleDerived im4 = outer.MultipleDerivedInstance4;
}
{
Outer.InnerMultipleDerived im1 = outer.MultipleDerivedInstance1;
Outer.InnerMultipleDerived im2 = outer.MultipleDerivedInstance2;
Outer.InnerMultipleDerived im3 = outer.MultipleDerivedInstance3;
Outer.InnerMultipleDerived im4 = outer.MultipleDerivedInstance4;
}
{
Outer.InnerMultipleAnonTypedef1 mat1 = outer.makeInnerMultipleAnonTypedef1();
Outer.InnerMultipleAnonTypedef1 mat2 = outer.makeInnerMultipleAnonTypedef2();
SWIGTYPE_p_p_Outer__InnerMultipleAnonTypedef1 mat3 = outer.makeInnerMultipleAnonTypedef3();
Outer.InnerMultipleNamedTypedef1 mnt = outer.makeInnerMultipleNamedTypedef();
Outer.InnerMultipleNamedTypedef1 mnt1 = outer.makeInnerMultipleNamedTypedef1();
Outer.InnerMultipleNamedTypedef1 mnt2 = outer.makeInnerMultipleNamedTypedef2();
SWIGTYPE_p_p_Outer__InnerMultipleNamedTypedef mnt3 = outer.makeInnerMultipleNamedTypedef3();
}
{
Outer.InnerSameName isn = outer.makeInnerSameName();
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using nested_directorsNamespace;
#pragma warning disable 219
public class CNested : Base.Nest {
public override bool GetValue() {return true;}
}
public class CSub : Sub {
protected override bool GetValue() { return base.GetValue(); }
public bool Test(){ return GetValue(); }
}
public class runme {
static void Main() {
CNested n = new CNested();
CSub s = new CSub();
if (!s.Test())
throw new Exception("Sub.GetValue");
}
}

View File

@@ -0,0 +1,28 @@
using System;
using nested_structsNamespace;
#pragma warning disable 219
public class runme {
static void Main() {
Outer outer = new Outer();
nested_structs.setValues(outer, 10);
Outer_inner1 inner1 = outer.inner1;
Outer_inner1 inner2 = outer.inner2;
Outer_inner1 inner3 = outer.inner3;
Outer_inner1 inner4 = outer.inner4;
if (inner1.val != 10) throw new Exception("failed inner1");
if (inner2.val != 20) throw new Exception("failed inner2");
if (inner3.val != 20) throw new Exception("failed inner3");
if (inner4.val != 40) throw new Exception("failed inner4");
Named inside1 = outer.inside1;
Named inside2 = outer.inside2;
Named inside3 = outer.inside3;
Named inside4 = outer.inside4;
if (inside1.val != 100) throw new Exception("failed inside1");
if (inside2.val != 200) throw new Exception("failed inside2");
if (inside3.val != 200) throw new Exception("failed inside3");
if (inside4.val != 400) throw new Exception("failed inside4");
}
}

View File

@@ -0,0 +1,23 @@
using System;
using nested_workaroundNamespace;
#pragma warning disable 219
public class runme {
static void Main() {
{
Inner inner = new Inner(5);
Outer outer = new Outer();
Inner newInner = outer.doubleInnerValue(inner);
if (newInner.getValue() != 10)
throw new Exception("inner failed");
}
{
Outer outer = new Outer();
Inner inner = outer.createInner(3);
Inner newInner = outer.doubleInnerValue(inner);
if (outer.getInnerValue(newInner) != 6)
throw new Exception("inner failed");
}
}
}

View File

@@ -0,0 +1,39 @@
using System;
public class runme
{
static void Main()
{
{
// constructors and destructors
nspace_extendNamespace.Outer.Inner1.Color color1 = new nspace_extendNamespace.Outer.Inner1.Color();
nspace_extendNamespace.Outer.Inner1.Color color = new nspace_extendNamespace.Outer.Inner1.Color(color1);
color1.Dispose();
color1 = null;
// class methods
color.colorInstanceMethod(20.0);
nspace_extendNamespace.Outer.Inner1.Color.colorStaticMethod(20.0);
nspace_extendNamespace.Outer.Inner1.Color created = nspace_extendNamespace.Outer.Inner1.Color.create();
created.Dispose();
}
{
// constructors and destructors
nspace_extendNamespace.Outer.Inner2.Color color2 = new nspace_extendNamespace.Outer.Inner2.Color();
nspace_extendNamespace.Outer.Inner2.Color color = new nspace_extendNamespace.Outer.Inner2.Color(color2);
color2.Dispose();
color2 = null;
// class methods
color.colorInstanceMethod(20.0);
nspace_extendNamespace.Outer.Inner2.Color.colorStaticMethod(20.0);
nspace_extendNamespace.Outer.Inner2.Color created = nspace_extendNamespace.Outer.Inner2.Color.create();
created.Dispose();
// Same class different namespaces
nspace_extendNamespace.Outer.Inner1.Color col1 = new nspace_extendNamespace.Outer.Inner1.Color();
nspace_extendNamespace.Outer.Inner2.Color col2 = nspace_extendNamespace.Outer.Inner2.Color.create();
col2.colors(col1, col1, col2, col2, col2);
}
}
}

View File

@@ -0,0 +1,76 @@
using System;
public class runme
{
static void Main()
{
// constructors and destructors
nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
nspaceNamespace.Outer.Inner1.Color color = new nspaceNamespace.Outer.Inner1.Color(color1);
color1.Dispose();
color1 = null;
// class methods
color.colorInstanceMethod(20.0);
nspaceNamespace.Outer.Inner1.Color.colorStaticMethod(20.0);
nspaceNamespace.Outer.Inner1.Color created = nspaceNamespace.Outer.Inner1.Color.create();
created.Dispose();
// class enums
nspaceNamespace.Outer.SomeClass someClass = new nspaceNamespace.Outer.SomeClass();
nspaceNamespace.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
if (channel != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
throw new ApplicationException("Transmission wrong");
// class anonymous enums
int val1 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal1;
int val2 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal2;
if (val1 != 0 || val2 != 0x22)
throw new ApplicationException("ColorEnumVal wrong");
// instance member variables
color.instanceMemberVariable = 123;
if (color.instanceMemberVariable != 123)
throw new ApplicationException("instance member variable failed");
// static member variables
nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789;
if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789)
throw new ApplicationException("static member variable failed");
if (nspaceNamespace.Outer.Inner1.Color.staticConstMemberVariable != 222)
throw new ApplicationException("static const member variable failed");
if (nspaceNamespace.Outer.Inner1.Color.staticConstEnumMemberVariable != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
throw new ApplicationException("static const enum member variable failed");
// check globals in a namespace don't get mangled with the nspaceNamespace option
nspaceNamespace.nspace.namespaceFunction(color);
nspaceNamespace.nspace.namespaceVar = 111;
if (nspaceNamespace.nspace.namespaceVar != 111)
throw new ApplicationException("global var failed");
// Same class different namespaces
nspaceNamespace.Outer.Inner1.Color col1 = new nspaceNamespace.Outer.Inner1.Color();
nspaceNamespace.Outer.Inner2.Color col2 = nspaceNamespace.Outer.Inner2.Color.create();
col2.colors(col1, col1, col2, col2, col2);
// global enums
nspaceNamespace.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
if (outerChannel1 != nspaceNamespace.Outer.Inner1.Channel.Transmission1)
throw new ApplicationException("Transmission1 wrong");
nspaceNamespace.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
if (outerChannel2 != nspaceNamespace.Outer.Inner2.Channel.Transmission2)
throw new ApplicationException("Transmission2 wrong");
// turn feature off / ignoring
nspaceNamespace.Outer.namespce ns = new nspaceNamespace.Outer.namespce();
ns.Dispose();
nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
nons.Dispose();
// Derived class
nspaceNamespace.Outer.Inner3.Blue blue3 = new nspaceNamespace.Outer.Inner3.Blue();
blue3.blueInstanceMethod();
nspaceNamespace.Outer.Inner4.Blue blue4 = new nspaceNamespace.Outer.Inner4.Blue();
blue4.blueInstanceMethod();
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Threading;
using operator_overloadNamespace;
public class runme
{
static void Main()
{
Op.sanity_check();
{
Op op = new Op(100);
Op opNew = op++;
if (op.i != 101) throw new Exception("operator++ postfix failed (op)");
if (opNew.i != 100) throw new Exception("operator++ postfix failed (opNew)");
}
{
Op op = new Op(100);
Op opNew = op--;
if (op.i != 99) throw new Exception("operator-- postfix failed (op)");
if (opNew.i != 100) throw new Exception("operator-- postfix failed (opNew)");
}
{
Op op = new Op(100);
Op opNew = ++op;
if (op.i != 101) throw new Exception("operator++ prefix failed (op)");
if (opNew.i != 101) throw new Exception("operator++ prefix failed (opNew)");
}
{
Op op = new Op(100);
Op opNew = --op;
if (op.i != 99) throw new Exception("operator-- prefix failed (op)");
if (opNew.i != 99) throw new Exception("operator-- prefix failed (opNew)");
}
// overloaded operator class
Op k = new OpDerived(3);
int check_k = k.IntCast();
Assert(check_k == 6);
}
public static void Assert(bool b) {
if (!b)
throw new Exception("Assertion failed");
}
}

View File

@@ -0,0 +1,55 @@
using System;
using overload_complicatedNamespace;
public class runme
{
static void Main()
{
SWIGTYPE_p_int pInt = null;
// Check the correct constructors are available
Pop p = new Pop(pInt);
p = new Pop(pInt, false);
// Check overloaded in const only and pointers/references which target languages cannot disambiguate
if (p.hip(false) != 701)
throw new Exception("Test 1 failed");
if (p.hip(pInt) != 702)
throw new Exception("Test 2 failed");
// Reverse the order for the above
if (p.hop(pInt) != 805)
throw new Exception("Test 3 failed");
if (p.hop(false) != 801)
throw new Exception("Test 4 failed");
// Few more variations and order shuffled
if (p.pop(false) != 901)
throw new Exception("Test 5 failed");
if (p.pop(pInt) != 902)
throw new Exception("Test 6 failed");
if (p.pop() != 905)
throw new Exception("Test 7 failed");
// Overload on const only
if (p.bop(pInt) != 1001)
throw new Exception("Test 8 failed");
if (p.bip(pInt) != 2001)
throw new Exception("Test 9 failed");
// Globals
if (overload_complicated.muzak(false) != 3001)
throw new Exception("Test 10 failed");
if (overload_complicated.muzak(pInt) != 3002)
throw new Exception("Test 11 failed");
}
}

View File

@@ -0,0 +1,152 @@
using System;
using overload_templateNamespace;
public class runme
{
static void Main()
{
int f = overload_template.foo();
f += overload_template.maximum(3,4);
double b = overload_template.maximum(3.4,5.2);
b++; // warning suppression
// mix 1
if (overload_template.mix1("hi") != 101)
throw new Exception ("mix1(const char*)");
if (overload_template.mix1(1.0, 1.0) != 102)
throw new Exception ("mix1(double, const double &)");
if (overload_template.mix1(1.0) != 103)
throw new Exception ("mix1(double)");
// mix 2
if (overload_template.mix2("hi") != 101)
throw new Exception ("mix2(const char*)");
if (overload_template.mix2(1.0, 1.0) != 102)
throw new Exception ("mix2(double, const double &)");
if (overload_template.mix2(1.0) != 103)
throw new Exception ("mix2(double)");
// mix 3
if (overload_template.mix3("hi") != 101)
throw new Exception ("mix3(const char*)");
if (overload_template.mix3(1.0, 1.0) != 102)
throw new Exception ("mix3(double, const double &)");
if (overload_template.mix3(1.0) != 103)
throw new Exception ("mix3(double)");
// Combination 1
if (overload_template.overtparams1(100) != 10)
throw new Exception ("overtparams1(int)");
if (overload_template.overtparams1(100.0, 100) != 20)
throw new Exception ("overtparams1(double, int)");
// Combination 2
if (overload_template.overtparams2(100.0, 100) != 40)
throw new Exception ("overtparams2(double, int)");
// Combination 3
if (overload_template.overloaded() != 60)
throw new Exception ("overloaded()");
if (overload_template.overloaded(100.0, 100) != 70)
throw new Exception ("overloaded(double, int)");
// Combination 4
if (overload_template.overloadedagain("hello") != 80)
throw new Exception ("overloadedagain(const char *)");
if (overload_template.overloadedagain() != 90)
throw new Exception ("overloadedagain(double)");
// specializations
if (overload_template.specialization(10) != 202)
throw new Exception ("specialization(int)");
if (overload_template.specialization(10.0) != 203)
throw new Exception ("specialization(double)");
if (overload_template.specialization(10, 10) != 204)
throw new Exception ("specialization(int, int)");
if (overload_template.specialization(10.0, 10.0) != 205)
throw new Exception ("specialization(double, double)");
if (overload_template.specialization("hi", "hi") != 201)
throw new Exception ("specialization(const char *, const char *)");
// simple specialization
overload_template.xyz();
overload_template.xyz_int();
overload_template.xyz_double();
// a bit of everything
if (overload_template.overload("hi") != 0)
throw new Exception ("overload()");
if (overload_template.overload(1) != 10)
throw new Exception ("overload(int t)");
if (overload_template.overload(1, 1) != 20)
throw new Exception ("overload(int t, const int &)");
if (overload_template.overload(1, "hello") != 30)
throw new Exception ("overload(int t, const char *)");
Klass k = new Klass();
if (overload_template.overload(k) != 10)
throw new Exception ("overload(Klass t)");
if (overload_template.overload(k, k) != 20)
throw new Exception ("overload(Klass t, const Klass &)");
if (overload_template.overload(k, "hello") != 30)
throw new Exception ("overload(Klass t, const char *)");
if (overload_template.overload(10.0, "hi") != 40)
throw new Exception ("overload(double t, const char *)");
if (overload_template.overload() != 50)
throw new Exception ("overload(const char *)");
// everything put in a namespace
if (overload_template.nsoverload("hi") != 1000)
throw new Exception ("nsoverload()");
if (overload_template.nsoverload(1) != 1010)
throw new Exception ("nsoverload(int t)");
if (overload_template.nsoverload(1, 1) != 1020)
throw new Exception ("nsoverload(int t, const int &)");
if (overload_template.nsoverload(1, "hello") != 1030)
throw new Exception ("nsoverload(int t, const char *)");
if (overload_template.nsoverload(k) != 1010)
throw new Exception ("nsoverload(Klass t)");
if (overload_template.nsoverload(k, k) != 1020)
throw new Exception ("nsoverload(Klass t, const Klass &)");
if (overload_template.nsoverload(k, "hello") != 1030)
throw new Exception ("nsoverload(Klass t, const char *)");
if (overload_template.nsoverload(10.0, "hi") != 1040)
throw new Exception ("nsoverload(double t, const char *)");
if (overload_template.nsoverload() != 1050)
throw new Exception ("nsoverload(const char *)");
}
}

View File

@@ -0,0 +1,21 @@
// This test tests all the methods in the C# collection wrapper
using System;
using pointer_referenceNamespace;
public class pointer_reference_runme {
public static void Main() {
Struct s = pointer_reference.get();
if (s.value != 10) throw new Exception("get test failed");
Struct ss = new Struct(20);
pointer_reference.set(ss);
if (Struct.instance.value != 20) throw new Exception("set test failed");
if (pointer_reference.overloading(1) != 111) throw new Exception("overload test 1 failed");
if (pointer_reference.overloading(ss) != 222) throw new Exception("overload test 2 failed");
}
}

View File

@@ -0,0 +1,70 @@
using System;
using System.Reflection;
using preproc_constants_cNamespace;
// Same as preproc_constants_c.i testcase, but bool types are int instead
public class runme {
static void Main() {
assert( typeof(int) == preproc_constants_c.CONST_INT1.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_INT2.GetType() );
assert( typeof(uint) == preproc_constants_c.CONST_UINT1.GetType() );
assert( typeof(uint) == preproc_constants_c.CONST_UINT2.GetType() );
assert( typeof(uint) == preproc_constants_c.CONST_UINT3.GetType() );
assert( typeof(uint) == preproc_constants_c.CONST_UINT4.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_LONG1.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_LONG2.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_LONG3.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_LONG4.GetType() );
assert( typeof(long) == preproc_constants_c.CONST_LLONG1.GetType() );
assert( typeof(long) == preproc_constants_c.CONST_LLONG2.GetType() );
assert( typeof(long) == preproc_constants_c.CONST_LLONG3.GetType() );
assert( typeof(long) == preproc_constants_c.CONST_LLONG4.GetType() );
assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG1.GetType() );
assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG2.GetType() );
assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG3.GetType() );
assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG4.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE1.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE2.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE3.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE4.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE5.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE6.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_BOOL1.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_BOOL2.GetType() );
assert( typeof(char) == preproc_constants_c.CONST_CHAR.GetType() );
assert( typeof(string) == preproc_constants_c.CONST_STRING1.GetType() );
assert( typeof(string) == preproc_constants_c.CONST_STRING2.GetType() );
assert( typeof(int) == preproc_constants_c.INT_AND_BOOL.GetType() );
// assert( typeof(int) == preproc_constants_c.INT_AND_CHAR.GetType() );
assert( typeof(int) == preproc_constants_c.INT_AND_INT.GetType() );
assert( typeof(uint) == preproc_constants_c.INT_AND_UINT.GetType() );
assert( typeof(int) == preproc_constants_c.INT_AND_LONG.GetType() );
assert( typeof(uint) == preproc_constants_c.INT_AND_ULONG.GetType() );
assert( typeof(long) == preproc_constants_c.INT_AND_LLONG.GetType() );
assert( typeof(ulong) == preproc_constants_c.INT_AND_ULLONG.GetType() );
assert( typeof(int ) == preproc_constants_c.BOOL_AND_BOOL.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_MULTIPLY.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_DIVIDE.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_PLUS.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_MINUS.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_LSHIFT.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_RSHIFT.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_LTE.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_GTE.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_INEQUALITY.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_EQUALITY.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_AND.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_XOR.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_OR.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_LAND.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_LOR.GetType() );
assert( typeof(double) == preproc_constants_c.EXPR_CONDITIONAL.GetType() );
}
static void assert(bool assertion) {
if (!assertion)
throw new ApplicationException("test failed");
}
}

View File

@@ -0,0 +1,69 @@
using System;
using System.Reflection;
using preproc_constantsNamespace;
public class runme {
static void Main() {
assert( typeof(int) == preproc_constants.CONST_INT1.GetType() );
assert( typeof(int) == preproc_constants.CONST_INT2.GetType() );
assert( typeof(uint) == preproc_constants.CONST_UINT1.GetType() );
assert( typeof(uint) == preproc_constants.CONST_UINT2.GetType() );
assert( typeof(uint) == preproc_constants.CONST_UINT3.GetType() );
assert( typeof(uint) == preproc_constants.CONST_UINT4.GetType() );
assert( typeof(int) == preproc_constants.CONST_LONG1.GetType() );
assert( typeof(int) == preproc_constants.CONST_LONG2.GetType() );
assert( typeof(int) == preproc_constants.CONST_LONG3.GetType() );
assert( typeof(int) == preproc_constants.CONST_LONG4.GetType() );
assert( typeof(long) == preproc_constants.CONST_LLONG1.GetType() );
assert( typeof(long) == preproc_constants.CONST_LLONG2.GetType() );
assert( typeof(long) == preproc_constants.CONST_LLONG3.GetType() );
assert( typeof(long) == preproc_constants.CONST_LLONG4.GetType() );
assert( typeof(ulong) == preproc_constants.CONST_ULLONG1.GetType() );
assert( typeof(ulong) == preproc_constants.CONST_ULLONG2.GetType() );
assert( typeof(ulong) == preproc_constants.CONST_ULLONG3.GetType() );
assert( typeof(ulong) == preproc_constants.CONST_ULLONG4.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE1.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE2.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE3.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE4.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE5.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE6.GetType() );
assert( typeof(bool) == preproc_constants.CONST_BOOL1.GetType() );
assert( typeof(bool) == preproc_constants.CONST_BOOL2.GetType() );
assert( typeof(char) == preproc_constants.CONST_CHAR.GetType() );
assert( typeof(string) == preproc_constants.CONST_STRING1.GetType() );
assert( typeof(string) == preproc_constants.CONST_STRING2.GetType() );
assert( typeof(int) == preproc_constants.INT_AND_BOOL.GetType() );
// assert( typeof(int) == preproc_constants.INT_AND_CHAR.GetType() );
assert( typeof(int) == preproc_constants.INT_AND_INT.GetType() );
assert( typeof(uint) == preproc_constants.INT_AND_UINT.GetType() );
assert( typeof(int) == preproc_constants.INT_AND_LONG.GetType() );
assert( typeof(uint) == preproc_constants.INT_AND_ULONG.GetType() );
assert( typeof(long) == preproc_constants.INT_AND_LLONG.GetType() );
assert( typeof(ulong) == preproc_constants.INT_AND_ULLONG.GetType() );
assert( typeof(int ) == preproc_constants.BOOL_AND_BOOL.GetType() );
assert( typeof(int) == preproc_constants.EXPR_MULTIPLY.GetType() );
assert( typeof(int) == preproc_constants.EXPR_DIVIDE.GetType() );
assert( typeof(int) == preproc_constants.EXPR_PLUS.GetType() );
assert( typeof(int) == preproc_constants.EXPR_MINUS.GetType() );
assert( typeof(int) == preproc_constants.EXPR_LSHIFT.GetType() );
assert( typeof(int) == preproc_constants.EXPR_RSHIFT.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_LTE.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_GTE.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_INEQUALITY.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_EQUALITY.GetType() );
assert( typeof(int) == preproc_constants.EXPR_AND.GetType() );
assert( typeof(int) == preproc_constants.EXPR_XOR.GetType() );
assert( typeof(int) == preproc_constants.EXPR_OR.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_LAND.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_LOR.GetType() );
assert( typeof(double) == preproc_constants.EXPR_CONDITIONAL.GetType() );
}
static void assert(bool assertion) {
if (!assertion)
throw new ApplicationException("test failed");
}
}

View File

@@ -0,0 +1,33 @@
using System;
using proxycodeNamespace;
public class proxycode_runme {
public static void Main() {
if (new Proxy1().proxycode1(100) != 101)
throw new Exception("Fail");
if (new Proxy2().proxycode2a(100) != 102)
throw new Exception("Fail");
if (new Proxy2().proxycode2b(100) != 102)
throw new Exception("Fail");
if (new Proxy3().proxycode3(100) != 103)
throw new Exception("Fail");
if (new Proxy4().proxycode4(100) != 104)
throw new Exception("Fail");
if (new Proxy4.Proxy4Nested().proxycode4nested(100) != 144)
throw new Exception("Fail");
if (new Proxy5a().proxycode5((short)100) != (short)100)
throw new Exception("Fail");
if (new Proxy5b().proxycode5(100) != 100)
throw new Exception("Fail");
if (new Proxy5b().proxycode5(100, 100) != 255)
throw new Exception("Fail");
uint t1 = 10;
uint t2 = 100;
Proxy6 p = new Proxy6().proxyUseT(t1, t2);
p.useT(t1, t2);
}
}

View File

@@ -0,0 +1,15 @@
using System;
using rename_pcre_encoderNamespace;
public class runme {
static void Main() {
SomeWidget w = new SomeWidget();
w.put_borderWidth(17);
if ( w.get_borderWidth() != 17 )
throw new Exception(String.Format("Border with should be 17, not {0}",
w.get_borderWidth()));
if ( rename_pcre_encoder.StartINSAneAndUNSAvoryTraNSAtlanticRaNSAck() != 42 )
throw new Exception("Unexpected result of renamed function call");
}
}

View File

@@ -0,0 +1,24 @@
using System;
using rename_pcre_enumNamespace;
public class runme {
static void Main() {
Foo foo = Foo.First;
if ( foo == Foo.Second )
throw new Exception("Enum values should be different");
// Check that Foo_Max enum element was ignored.
int numFooEnumElements = Enum.GetValues(typeof(Foo)).Length;
if ( numFooEnumElements != 2 )
throw new Exception(String.Format("Enum should have 2 elements, not {0}",
numFooEnumElements));
BoundaryCondition bc = BoundaryCondition.MaxMax;
if ( (int)bc != 2 )
throw new Exception("Wrong enum value");
Colour c = Colour.red;
if ( c == Colour.blue )
throw new Exception("Enum values should be different");
}
}

View File

@@ -0,0 +1,30 @@
using System;
using rename_simpleNamespace;
public class rename_simple_runme {
public static void Main() {
NewStruct s = new NewStruct();
check(111, s.NewInstanceVariable, "NewInstanceVariable");
check(222, s.NewInstanceMethod(), "NewInstanceMethod");
check(333, NewStruct.NewStaticMethod(), "NewStaticMethod");
check(444, NewStruct.NewStaticVariable, "NewStaticVariable");
check(555, rename_simple.NewFunction(), "NewFunction");
check(666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
s.NewInstanceVariable = 1111;
NewStruct.NewStaticVariable = 4444;
rename_simple.NewGlobalVariable = 6666;
check(1111, s.NewInstanceVariable, "NewInstanceVariable");
check(4444, NewStruct.NewStaticVariable, "NewStaticVariable");
check(6666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
}
public static void check(int expected, int actual, string msg) {
if (expected != actual)
throw new Exception("Failed: Expected: " + expected + " actual: " + actual + " " + msg);
}
}

View File

@@ -0,0 +1,18 @@
using System;
using sizetNamespace;
public class sizet_runme {
public static void Main() {
uint s = 2000;
s = sizet.test1(s+1);
s = sizet.test2(s+1);
s = sizet.test3(s+1);
s = sizet.test4(s+1);
if (s != 2004)
throw new Exception("failed");
}
}

View File

@@ -0,0 +1,20 @@
using System;
using sneaky1Namespace;
public class runme
{
static void Main()
{
if (sneaky1.add(30, 2) != 32)
throw new Exception("add test failed");
if (sneaky1.subtract(20, 2) != 18)
throw new Exception("subtract test failed");
if (sneaky1.mul(20, 2) != 40)
throw new Exception("mul test failed");
if (sneaky1.divide(20, 2) != 10)
throw new Exception("div test failed");
}
}

View File

@@ -0,0 +1,30 @@
using System;
using special_variable_attributesNamespace;
public class special_variable_attributes_runme {
public static void Main() {
if (special_variable_attributes.getNumber1() != 111)
throw new ApplicationException("getNumber1 failed");
if (special_variable_attributes.getNumber2() != 222)
throw new ApplicationException("getNumber2 failed");
if (special_variable_attributes.getNumber3() != 333)
throw new ApplicationException("getNumber3 failed");
if (special_variable_attributes.bounceNumber1(10) != 110)
throw new ApplicationException("bounceNumber1 failed");
if (special_variable_attributes.bounceNumber2(10) != 220)
throw new ApplicationException("bounceNumber2 failed");
if (special_variable_attributes.bounceNumber3(10) != 330)
throw new ApplicationException("bounceNumber3 failed");
if (special_variable_attributes.multi1(12.34) != 12+34)
throw new ApplicationException("multi1 failed");
if (special_variable_attributes.multi2(12.34) != 12+34+55)
throw new ApplicationException("multi2 failed");
if (special_variable_attributes.multi3(12.34) != 12+34+77)
throw new ApplicationException("multi3 failed");
}
}

View File

@@ -0,0 +1,24 @@
using System;
using special_variable_macrosNamespace;
public class runme {
static void Main() {
Name name = new Name();
if (special_variable_macros.testFred(name) != "none")
throw new Exception("test failed");
if (special_variable_macros.testJack(name) != "$specialname")
throw new Exception("test failed");
if (special_variable_macros.testJill(name) != "jilly")
throw new Exception("test failed");
if (special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap")
throw new Exception("test failed");
if (special_variable_macros.testJames(name) != "SWIGTYPE_Name")
throw new Exception("test failed");
if (special_variable_macros.testJim(name) != "multiname num")
throw new Exception("test failed");
if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
throw new Exception("test failed");
NewName newName = NewName.factory("factoryname");
name = newName.getStoredName();
}
}

View File

@@ -0,0 +1,25 @@
using System;
using template_nestedNamespace;
#pragma warning disable 219
public class runme {
static void Main() {
new T_NormalTemplateNormalClass().tmethod(new NormalClass());
new OuterClass().T_OuterTMethodNormalClass(new NormalClass());
TemplateFuncs tf = new TemplateFuncs();
if (tf.T_TemplateFuncs1Int(-10) != -10)
throw new Exception("it failed");
if (tf.T_TemplateFuncs2Double(-12.3) != -12.3)
throw new Exception("it failed");
T_NestedOuterTemplateDouble tn = new T_NestedOuterTemplateDouble();
if (tn.hohum(-12.3) != -12.3)
throw new Exception("it failed");
OuterClass.T_OuterClassInner1Int inner1 = new OuterClass().useInner1(new OuterClass.T_OuterClassInner1Int());
OuterClass.T_OuterClassInner2NormalClass inner2 = new OuterClass.T_OuterClassInner2NormalClass();
inner2.embeddedVar = 2;
OuterClass.T_OuterClassInner2NormalClass inner22 = new OuterClass().useInner2Again(inner2);
}
}

View File

@@ -0,0 +1,61 @@
using System;
using System.Threading;
using threadsNamespace;
public class runme
{
static void Main()
{
Kerfuffle kerf = new Kerfuffle();
const int NUM_THREADS = 8;
Thread[] threads = new Thread[NUM_THREADS];
TestThread[] testThreads = new TestThread[NUM_THREADS];
// invoke the threads
for (int i=0; i<NUM_THREADS; i++) {
testThreads[i] = new TestThread(kerf, i);
threads[i] = new Thread(new ThreadStart(testThreads[i].Run));
threads[i].Start();
}
// wait for the threads to finish
for (int i=0; i<NUM_THREADS; i++) {
threads[i].Join();
}
for (int i=0; i<NUM_THREADS; i++) {
if (testThreads[i].Failed) throw new Exception("Test Failed");
}
}
}
public class TestThread {
private int threadId;
private Kerfuffle kerf;
public bool Failed;
public TestThread(Kerfuffle t, int id) {
kerf = t;
threadId = id;
}
public void Run() {
Failed = false;
try {
for (int i=0; i<30000; i++) { // run test for a few seconds on a 1GHz machine
string given = "This is the test string that should come back. A number: " + i;
string received = kerf.StdString(given);
if (received != given) {
throw new ApplicationException("StdString string does not match. Received:\n[" + received + "].\nExpected:\n{" + given + "}");
}
}
for (int i=0; i<30000; i++) { // run test for a few seconds on a 1GHz machine
string given = "This is the test string that should come back. A number: " + i;
string received = kerf.CharString(given);
if (received != given) {
throw new ApplicationException("StdString string does not match. Received:\n[" + received + "].\nExpected:\n{" + given + "}");
}
}
} catch (Exception e) {
Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message);
Failed = true;
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using throw_exceptionNamespace;
public class runme
{
static void Main() {
Foo f = new Foo();
try {
f.test_int();
throw new Exception("Integer exception should have been thrown");
} catch (System.Exception) {
}
try {
f.test_msg();
throw new Exception("String exception should have been thrown");
} catch (System.Exception) {
}
try {
f.test_cls();
throw new Exception("Class exception should have been thrown");
} catch (System.Exception) {
}
}
}

View File

@@ -0,0 +1,16 @@
// This test tests all the methods in the C# collection wrapper
using System;
using typemap_namespaceNamespace;
public class typemap_namespace_runme {
public static void Main() {
if (typemap_namespace.test1("hello") != "hello")
throw new Exception("test1 failed");
if (typemap_namespace.test2("hello") != "hello")
throw new Exception("test2 failed");
}
}

View File

@@ -0,0 +1,13 @@
using System;
using typemap_out_optimalNamespace;
public class typemap_out_optimal_runme {
public static XX x = null;
public static void Main() {
XX.debug = false;
x = XX.create();
}
}

View File

@@ -0,0 +1,20 @@
// varargs test
using System;
using varargsNamespace;
public class varargs_runme {
public static void Main() {
if (varargs.test("Hello") != "Hello")
throw new Exception("Failed");
Foo f = new Foo("Greetings");
if (f.str != "Greetings")
throw new Exception("Failed");
if (f.test("Hello") != "Hello")
throw new Exception("Failed");
}
}

View File

@@ -0,0 +1,51 @@
using System;
using virtual_polyNamespace;
public class runme {
static void Main() {
NDouble d = new NDouble(3.5);
NInt i = new NInt(2);
//
// These two natural 'copy' forms fail because no covariant (polymorphic) return types
// are supported in C#.
//
// NDouble dc = d.copy();
// NInt ic = i.copy();
//
// Unlike C++, we have to downcast instead.
//
NDouble dc = (NDouble)d.copy();
NInt ic = (NInt)i.copy();
NDouble ddc = NDouble.narrow(dc);
NInt dic = NInt.narrow(ic);
dc = ddc; ic = dic; // warning suppression
virtual_poly.incr(ic);
if ( (i.get() + 1) != ic.get() )
throw new Exception("incr test failed");
//
// Checking a pure user downcast
//
NNumber n1 = d.copy();
NNumber n2 = d.nnumber();
NDouble dn1 = NDouble.narrow(n1);
NDouble dn2 = NDouble.narrow(n2);
if ( (dn1.get()) != dn2.get() )
throw new Exception("copy/narrow test failed");
//
// Checking the ref polymorphic case
//
NNumber nr = d.ref_this();
NDouble dr1 = NDouble.narrow(nr);
NDouble dr2 = (NDouble)d.ref_this();
if ( dr1.get() != dr2.get() )
throw new Exception("copy/narrow test failed");
}
}