director string testing additions

Add test for C# based on Java example to test strings in and out.
Memory cleanup for Java test.
This commit is contained in:
William S Fulton 2022-02-12 12:09:01 +00:00
parent 31af3ce9bf
commit 86eaf30735
2 changed files with 77 additions and 12 deletions

View File

@ -0,0 +1,58 @@
using System;
namespace director_defaultNamespace {
public class runme
{
static void Main()
{
{
MyFoo a = new MyFoo();
a = new MyFoo(10);
a.Dispose();
}
{
MyFoo a = new MyFoo();
if (a.GetMsg() != "MyFoo-default") {
throw new Exception( "Test 1 failed" );
}
if (a.GetMsg("boo") != "MyFoo-boo") {
throw new Exception( "Test 2 failed" );
}
a.Dispose();
}
{
Foo b = new Foo();
if (b.GetMsg() != "Foo-default") {
throw new Exception( "Test 1 failed" );
}
if (b.GetMsg("boo") != "Foo-boo") {
throw new Exception( "Test 2 failed" );
}
b.Dispose();
}
}
}
public class MyFoo : Foo
{
public MyFoo()
: base()
{
}
public MyFoo(int i)
: base(i)
{
}
public override string Msg(string msg)
{
return "MyFoo-" + msg;
}
}
}

View File

@ -16,22 +16,29 @@ public class director_default_runme {
{ {
director_default_MyFoo a = new director_default_MyFoo(); director_default_MyFoo a = new director_default_MyFoo();
a = new director_default_MyFoo(10); a = new director_default_MyFoo(10);
a.delete();
} }
director_default_MyFoo a = new director_default_MyFoo(); {
if (!a.GetMsg().equals("director_default_MyFoo-default")) { director_default_MyFoo a = new director_default_MyFoo();
throw new RuntimeException ( "Test 1 failed" ); if (!a.GetMsg().equals("director_default_MyFoo-default")) {
} throw new RuntimeException ( "Test 1 failed" );
if (!a.GetMsg("boo").equals("director_default_MyFoo-boo")) { }
throw new RuntimeException ( "Test 2 failed" ); if (!a.GetMsg("boo").equals("director_default_MyFoo-boo")) {
throw new RuntimeException ( "Test 2 failed" );
}
a.delete();
} }
Foo b = new Foo(); {
if (!b.GetMsg().equals("Foo-default")) { Foo b = new Foo();
throw new RuntimeException ( "Test 1 failed" ); if (!b.GetMsg().equals("Foo-default")) {
} throw new RuntimeException ( "Test 1 failed" );
if (!b.GetMsg("boo").equals("Foo-boo")) { }
throw new RuntimeException ( "Test 2 failed" ); if (!b.GetMsg("boo").equals("Foo-boo")) {
throw new RuntimeException ( "Test 2 failed" );
}
b.delete();
} }
} }