Add raw pointer handling test for virtual inheritance
This is a test added for D in previous commit, now expanded to all target languages. Tidy up counting object instances.
This commit is contained in:
parent
910fd1e3cf
commit
d4b1152d4b
20 changed files with 236 additions and 224 deletions
|
|
@ -18,6 +18,15 @@ public class cpp11_std_unique_ptr_runme {
|
|||
|
||||
public static void Main()
|
||||
{
|
||||
// Test raw pointer handling involving virtual inheritance
|
||||
using (KlassInheritance kini = new KlassInheritance("KlassInheritanceInput")) {
|
||||
checkCount(1);
|
||||
string s = cpp11_std_unique_ptr.useKlassRawPtr(kini);
|
||||
if (s != "KlassInheritanceInput")
|
||||
throw new ApplicationException("Incorrect string: " + s);
|
||||
}
|
||||
checkCount(0);
|
||||
|
||||
// unique_ptr as input
|
||||
using (Klass kin = new Klass("KlassInput")) {
|
||||
checkCount(1);
|
||||
|
|
@ -63,7 +72,7 @@ public class cpp11_std_unique_ptr_runme {
|
|||
}
|
||||
if (!exception_thrown)
|
||||
throw new ApplicationException("Should have thrown 'Cannot release ownership as memory is not owned' error");
|
||||
checkCount(1);
|
||||
checkCount(1);
|
||||
}
|
||||
checkCount(0);
|
||||
|
||||
|
|
@ -84,49 +93,22 @@ public class cpp11_std_unique_ptr_runme {
|
|||
throw new Exception("wrong object label");
|
||||
|
||||
Klass k2 = cpp11_std_unique_ptr.makeKlassUniquePtr("second");
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new Exception("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
using (Klass k3 = cpp11_std_unique_ptr.makeKlassUniquePtr("second")) {
|
||||
if (Klass.getTotal_count() != 3)
|
||||
throw new Exception("number of objects should be 3");
|
||||
checkCount(3);
|
||||
}
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new Exception("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
k1.Dispose();
|
||||
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
|
||||
}
|
||||
checkCount(1);
|
||||
|
||||
if (k2.getLabel() != "second")
|
||||
throw new Exception("wrong object label");
|
||||
|
||||
k2.Dispose();
|
||||
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
|
||||
}
|
||||
checkCount(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,15 @@ public class li_std_auto_ptr_runme {
|
|||
|
||||
public static void Main()
|
||||
{
|
||||
// Test raw pointer handling involving virtual inheritance
|
||||
using (KlassInheritance kini = new KlassInheritance("KlassInheritanceInput")) {
|
||||
checkCount(1);
|
||||
string s = li_std_auto_ptr.useKlassRawPtr(kini);
|
||||
if (s != "KlassInheritanceInput")
|
||||
throw new ApplicationException("Incorrect string: " + s);
|
||||
}
|
||||
checkCount(0);
|
||||
|
||||
// auto_ptr as input
|
||||
using (Klass kin = new Klass("KlassInput")) {
|
||||
checkCount(1);
|
||||
|
|
@ -84,49 +93,22 @@ public class li_std_auto_ptr_runme {
|
|||
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");
|
||||
checkCount(2);
|
||||
|
||||
using (Klass k3 = li_std_auto_ptr.makeKlassAutoPtr("second")) {
|
||||
if (Klass.getTotal_count() != 3)
|
||||
throw new Exception("number of objects should be 3");
|
||||
checkCount(3);
|
||||
}
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new Exception("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
k1.Dispose();
|
||||
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
|
||||
}
|
||||
checkCount(1);
|
||||
|
||||
if (k2.getLabel() != "second")
|
||||
throw new Exception("wrong object label");
|
||||
|
||||
k2.Dispose();
|
||||
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
|
||||
}
|
||||
checkCount(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,17 +93,14 @@ void main() {
|
|||
throw new Exception("wrong object label");
|
||||
|
||||
Klass k2 = makeKlassUniquePtr("second");
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new Exception("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
k1.dispose();
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new Exception("number of objects should be 1");
|
||||
checkCount(1);
|
||||
|
||||
if (k2.getLabel() != "second")
|
||||
throw new Exception("wrong object label");
|
||||
|
||||
k2.dispose();
|
||||
if (Klass.getTotal_count() != 0)
|
||||
throw new Exception("no objects should be left");
|
||||
checkCount(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,17 +93,14 @@ void main() {
|
|||
throw new Exception("wrong object label");
|
||||
|
||||
Klass k2 = makeKlassUniquePtr("second");
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new Exception("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
k1.dispose();
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new Exception("number of objects should be 1");
|
||||
checkCount(1);
|
||||
|
||||
if (k2.getLabel() != "second")
|
||||
throw new Exception("wrong object label");
|
||||
|
||||
k2.dispose();
|
||||
if (Klass.getTotal_count() != 0)
|
||||
throw new Exception("no objects should be left");
|
||||
checkCount(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,17 +93,14 @@ void main() {
|
|||
throw new Exception("wrong object label");
|
||||
|
||||
Klass k2 = makeKlassAutoPtr("second");
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new Exception("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
k1.dispose();
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new Exception("number of objects should be 1");
|
||||
checkCount(1);
|
||||
|
||||
if (k2.getLabel() != "second")
|
||||
throw new Exception("wrong object label");
|
||||
|
||||
k2.dispose();
|
||||
if (Klass.getTotal_count() != 0)
|
||||
throw new Exception("no objects should be left");
|
||||
checkCount(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ void main() {
|
|||
scope KlassInheritance kini = new KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
string s = useKlassRawPtr(kini);
|
||||
checkCount(1);
|
||||
if (s != "KlassInheritanceInput")
|
||||
throw new Exception("Incorrect string: " ~ s);
|
||||
}
|
||||
|
|
@ -94,17 +93,14 @@ void main() {
|
|||
throw new Exception("wrong object label");
|
||||
|
||||
Klass k2 = makeKlassAutoPtr("second");
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new Exception("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
k1.dispose();
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new Exception("number of objects should be 1");
|
||||
checkCount(1);
|
||||
|
||||
if (k2.getLabel() != "second")
|
||||
throw new Exception("wrong object label");
|
||||
|
||||
k2.dispose();
|
||||
if (Klass.getTotal_count() != 0)
|
||||
throw new Exception("no objects should be left");
|
||||
checkCount(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,17 @@ public class cpp11_std_unique_ptr_runme {
|
|||
|
||||
public static void main(String argv[]) throws Throwable
|
||||
{
|
||||
// Test raw pointer handling involving virtual inheritance
|
||||
{
|
||||
KlassInheritance kini = new KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
String s = cpp11_std_unique_ptr.useKlassRawPtr(kini);
|
||||
if (!s.equals("KlassInheritanceInput"))
|
||||
throw new RuntimeException("Incorrect string: " + s);
|
||||
kini.delete();
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
// unique_ptr as input
|
||||
{
|
||||
Klass kin = new Klass("KlassInput");
|
||||
|
|
@ -102,42 +113,17 @@ public class cpp11_std_unique_ptr_runme {
|
|||
throw new RuntimeException("wrong object label");
|
||||
|
||||
Klass k2 = cpp11_std_unique_ptr.makeKlassUniquePtr("second");
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new RuntimeException("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
k1.delete();
|
||||
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)
|
||||
System.err.println("GC failed to run (cpp11_std_unique_ptr 1). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
checkCount(1);
|
||||
|
||||
if (!k2.getLabel().equals("second"))
|
||||
throw new RuntimeException("wrong object label");
|
||||
|
||||
k2.delete();
|
||||
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)
|
||||
System.err.println("GC failed to run (cpp11_std_unique_ptr 2). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
checkCount(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,17 @@ public class li_std_auto_ptr_runme {
|
|||
|
||||
public static void main(String argv[]) throws Throwable
|
||||
{
|
||||
// Test raw pointer handling involving virtual inheritance
|
||||
{
|
||||
KlassInheritance kini = new KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
String s = li_std_auto_ptr.useKlassRawPtr(kini);
|
||||
if (!s.equals("KlassInheritanceInput"))
|
||||
throw new RuntimeException("Incorrect string: " + s);
|
||||
kini.delete();
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
// auto_ptr as input
|
||||
{
|
||||
Klass kin = new Klass("KlassInput");
|
||||
|
|
@ -102,42 +113,17 @@ public class li_std_auto_ptr_runme {
|
|||
throw new RuntimeException("wrong object label");
|
||||
|
||||
Klass k2 = li_std_auto_ptr.makeKlassAutoPtr("second");
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new RuntimeException("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
k1.delete();
|
||||
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)
|
||||
System.err.println("GC failed to run (li_std_auto_ptr 1). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
checkCount(1);
|
||||
|
||||
if (!k2.getLabel().equals("second"))
|
||||
throw new RuntimeException("wrong object label");
|
||||
|
||||
k2.delete();
|
||||
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)
|
||||
System.err.println("GC failed to run (li_std_auto_ptr 2). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
|
||||
}
|
||||
checkCount(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,20 @@ var checkCount = function(expected_count) {
|
|||
throw new Error("Counts incorrect, expected:" + expected_count + " actual:" + actual_count);
|
||||
}
|
||||
|
||||
// Test raw pointer handling involving virtual inheritance
|
||||
{
|
||||
kini = new cpp11_std_unique_ptr.KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
s = cpp11_std_unique_ptr.useKlassRawPtr(kini);
|
||||
if (s !== "KlassInheritanceInput")
|
||||
throw new Error("Incorrect string: " + s);
|
||||
// delete kini;
|
||||
// Above not deleting the C++ object(node v12) - can't reliably control GC
|
||||
cpp11_std_unique_ptr.takeKlassUniquePtr(kini);
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
|
||||
// unique_ptr as input
|
||||
{
|
||||
kin = new cpp11_std_unique_ptr.Klass("KlassInput");
|
||||
|
|
@ -82,14 +96,12 @@ if (k1.getLabel() !== "first")
|
|||
throw new Error("wrong object label");
|
||||
|
||||
k2 = cpp11_std_unique_ptr.makeKlassUniquePtr("second");
|
||||
if (cpp11_std_unique_ptr.Klass.getTotal_count() != 2)
|
||||
throw new Error("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
// delete k1;
|
||||
// Above not deleting the C++ object(node v12), not sure why, use below as workaround
|
||||
// Above not deleting the C++ object(node v12) - can't reliably control GC
|
||||
cpp11_std_unique_ptr.takeKlassUniquePtr(k1);
|
||||
if (cpp11_std_unique_ptr.Klass.getTotal_count() != 1)
|
||||
throw new Error("number of objects should be 1");
|
||||
checkCount(1);
|
||||
|
||||
if (k2.getLabel() !== "second")
|
||||
throw new Error("wrong object label");
|
||||
|
|
@ -97,5 +109,4 @@ if (k2.getLabel() !== "second")
|
|||
// delete k2;
|
||||
// Above not deleting the C++ object(node v12) - can't reliably control GC
|
||||
cpp11_std_unique_ptr.takeKlassUniquePtr(k2);
|
||||
if (cpp11_std_unique_ptr.Klass.getTotal_count() != 0)
|
||||
throw new Error("no objects should be left");
|
||||
checkCount(0);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,20 @@ var checkCount = function(expected_count) {
|
|||
throw new Error("Counts incorrect, expected:" + expected_count + " actual:" + actual_count);
|
||||
}
|
||||
|
||||
// Test raw pointer handling involving virtual inheritance
|
||||
{
|
||||
kini = new li_std_auto_ptr.KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
s = li_std_auto_ptr.useKlassRawPtr(kini);
|
||||
if (s !== "KlassInheritanceInput")
|
||||
throw new Error("Incorrect string: " + s);
|
||||
// delete kini;
|
||||
// Above not deleting the C++ object(node v12) - can't reliably control GC
|
||||
li_std_auto_ptr.takeKlassAutoPtr(kini);
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
|
||||
// auto_ptr as input
|
||||
{
|
||||
kin = new li_std_auto_ptr.Klass("KlassInput");
|
||||
|
|
@ -82,14 +96,12 @@ if (k1.getLabel() !== "first")
|
|||
throw new Error("wrong object label");
|
||||
|
||||
k2 = li_std_auto_ptr.makeKlassAutoPtr("second");
|
||||
if (li_std_auto_ptr.Klass.getTotal_count() != 2)
|
||||
throw new Error("number of objects should be 2");
|
||||
checkCount(2);
|
||||
|
||||
// delete k1;
|
||||
// Above not deleting the C++ object(node v12), not sure why, use below as workaround
|
||||
// Above not deleting the C++ object(node v12) - can't reliably control GC
|
||||
li_std_auto_ptr.takeKlassAutoPtr(k1);
|
||||
if (li_std_auto_ptr.Klass.getTotal_count() != 1)
|
||||
throw new Error("number of objects should be 1");
|
||||
checkCount(1);
|
||||
|
||||
if (k2.getLabel() !== "second")
|
||||
throw new Error("wrong object label");
|
||||
|
|
@ -97,5 +109,4 @@ if (k2.getLabel() !== "second")
|
|||
// delete k2;
|
||||
// Above not deleting the C++ object(node v12) - can't reliably control GC
|
||||
li_std_auto_ptr.takeKlassAutoPtr(k2);
|
||||
if (li_std_auto_ptr.Klass.getTotal_count() != 0)
|
||||
throw new Error("no objects should be left");
|
||||
checkCount(0);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,16 @@ function checkCount(expected_count)
|
|||
endif
|
||||
end
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
kini = KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
s = takeKlassUniquePtr(kini);
|
||||
if (!strcmp(s, "KlassInheritanceInput"))
|
||||
error("Incorrect string: %s", s);
|
||||
endif
|
||||
clear kini;
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as input
|
||||
kin = Klass("KlassInput");
|
||||
|
|
@ -91,20 +101,14 @@ if (!strcmp(k1.getLabel(), "first"))
|
|||
endif
|
||||
|
||||
k2 = makeKlassUniquePtr("second");
|
||||
if (Klass_getTotal_count() != 2)
|
||||
error("number of objects should be 2");
|
||||
endif
|
||||
checkCount(2);
|
||||
|
||||
clear k1;
|
||||
if (Klass.getTotal_count() != 1)
|
||||
error("number of objects should be 1");
|
||||
endif
|
||||
checkCount(1);
|
||||
|
||||
if (!strcmp(k2.getLabel(), "second"))
|
||||
error("wrong object label");
|
||||
endif
|
||||
|
||||
clear k2;
|
||||
if (Klass.getTotal_count() != 0)
|
||||
error("no objects should be left");
|
||||
endif
|
||||
checkCount(0);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,17 @@ function checkCount(expected_count)
|
|||
endif
|
||||
end
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
kini = KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
s = takeKlassAutoPtr(kini);
|
||||
if (!strcmp(s, "KlassInheritanceInput"))
|
||||
error("Incorrect string: %s", s);
|
||||
endif
|
||||
clear kini;
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# auto_ptr as input
|
||||
kin = Klass("KlassInput");
|
||||
checkCount(1);
|
||||
|
|
@ -90,20 +101,14 @@ if (!strcmp(k1.getLabel(), "first"))
|
|||
endif
|
||||
|
||||
k2 = makeKlassAutoPtr("second");
|
||||
if (Klass_getTotal_count() != 2)
|
||||
error("number of objects should be 2");
|
||||
endif
|
||||
checkCount(2);
|
||||
|
||||
clear k1;
|
||||
if (Klass.getTotal_count() != 1)
|
||||
error("number of objects should be 1");
|
||||
endif
|
||||
checkCount(1);
|
||||
|
||||
if (!strcmp(k2.getLabel(), "second"))
|
||||
error("wrong object label");
|
||||
endif
|
||||
|
||||
clear k2;
|
||||
if (Klass.getTotal_count() != 0)
|
||||
error("no objects should be left");
|
||||
endif
|
||||
checkCount(0);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 25;
|
||||
use Test::More tests => 28;
|
||||
BEGIN { use_ok('cpp11_std_unique_ptr') }
|
||||
require_ok('cpp11_std_unique_ptr');
|
||||
|
||||
|
|
@ -12,6 +12,17 @@ sub checkCount {
|
|||
is($actual_count, $expected_count, "Counts incorrect, expected: $expected_count actual: $actual_count");
|
||||
}
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
{
|
||||
my $kini = new cpp11_std_unique_ptr::KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
my $s = cpp11_std_unique_ptr::takeKlassUniquePtr($kini);
|
||||
is($s, "KlassInheritanceInput", "Incorrect string: $s");
|
||||
undef $kini;
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
|
||||
# unique_ptr as input
|
||||
{
|
||||
my $kin = new cpp11_std_unique_ptr::Klass("KlassInput");
|
||||
|
|
@ -65,12 +76,12 @@ sub checkCount {
|
|||
# unique_ptr as output
|
||||
my $k1 = cpp11_std_unique_ptr::makeKlassUniquePtr("first");
|
||||
my $k2 = cpp11_std_unique_ptr::makeKlassUniquePtr("second");
|
||||
is(cpp11_std_unique_ptr::Klass::getTotal_count, 2, "have 2 pointers");
|
||||
checkCount(2);
|
||||
|
||||
undef $k1;
|
||||
is(cpp11_std_unique_ptr::Klass::getTotal_count, 1, "left 1 pointer");
|
||||
checkCount(1);
|
||||
|
||||
is($k2->getLabel, "second", "proper label");
|
||||
|
||||
undef $k2;
|
||||
is(cpp11_std_unique_ptr::Klass::getTotal_count, 0, "remove all pointers");
|
||||
checkCount(0);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 25;
|
||||
use Test::More tests => 28;
|
||||
BEGIN { use_ok('li_std_auto_ptr') }
|
||||
require_ok('li_std_auto_ptr');
|
||||
|
||||
|
|
@ -12,6 +12,17 @@ sub checkCount {
|
|||
is($actual_count, $expected_count, "Counts incorrect, expected: $expected_count actual: $actual_count");
|
||||
}
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
{
|
||||
my $kini = new li_std_auto_ptr::KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
my $s = li_std_auto_ptr::takeKlassAutoPtr($kini);
|
||||
is($s, "KlassInheritanceInput", "Incorrect string: $s");
|
||||
undef $kini;
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
|
||||
# auto_ptr as input
|
||||
{
|
||||
my $kin = new li_std_auto_ptr::Klass("KlassInput");
|
||||
|
|
@ -65,12 +76,12 @@ sub checkCount {
|
|||
# auto_ptr as output
|
||||
my $k1 = li_std_auto_ptr::makeKlassAutoPtr("first");
|
||||
my $k2 = li_std_auto_ptr::makeKlassAutoPtr("second");
|
||||
is(li_std_auto_ptr::Klass::getTotal_count, 2, "have 2 pointers");
|
||||
checkCount(2);
|
||||
|
||||
undef $k1;
|
||||
is(li_std_auto_ptr::Klass::getTotal_count, 1, "left 1 pointer");
|
||||
checkCount(1);
|
||||
|
||||
is($k2->getLabel, "second", "proper label");
|
||||
|
||||
undef $k2;
|
||||
is(li_std_auto_ptr::Klass::getTotal_count, 0, "remove all pointers");
|
||||
checkCount(0);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,16 @@ def checkCount(expected_count):
|
|||
if (actual_count != expected_count):
|
||||
raise RuntimeError("Counts incorrect, expected:" + expected_count + " actual:" + actual_count)
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
kini = KlassInheritance("KlassInheritanceInput")
|
||||
checkCount(1)
|
||||
s = takeKlassUniquePtr(kini)
|
||||
if s != "KlassInheritanceInput":
|
||||
raise RuntimeError("Incorrect string: " + s)
|
||||
del kini
|
||||
checkCount(0)
|
||||
|
||||
|
||||
# unique_ptr as input
|
||||
kin = Klass("KlassInput")
|
||||
checkCount(1)
|
||||
|
|
@ -70,16 +80,13 @@ checkCount(0)
|
|||
# unique_ptr as output
|
||||
k1 = makeKlassUniquePtr("first")
|
||||
k2 = makeKlassUniquePtr("second")
|
||||
if Klass.getTotal_count() != 2:
|
||||
raise "number of objects should be 2"
|
||||
checkCount(2)
|
||||
|
||||
del k1
|
||||
if Klass.getTotal_count() != 1:
|
||||
raise "number of objects should be 1"
|
||||
checkCount(1)
|
||||
|
||||
if k2.getLabel() != "second":
|
||||
raise "wrong object label"
|
||||
|
||||
del k2
|
||||
if Klass.getTotal_count() != 0:
|
||||
raise "no objects should be left"
|
||||
checkCount(0)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,16 @@ def checkCount(expected_count):
|
|||
if (actual_count != expected_count):
|
||||
raise RuntimeError("Counts incorrect, expected:" + expected_count + " actual:" + actual_count)
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
kini = KlassInheritance("KlassInheritanceInput")
|
||||
checkCount(1)
|
||||
s = takeKlassAutoPtr(kini)
|
||||
if s != "KlassInheritanceInput":
|
||||
raise RuntimeError("Incorrect string: " + s)
|
||||
del kini
|
||||
checkCount(0)
|
||||
|
||||
|
||||
# auto_ptr as input
|
||||
kin = Klass("KlassInput")
|
||||
checkCount(1)
|
||||
|
|
@ -70,16 +80,13 @@ checkCount(0)
|
|||
# auto_ptr as output
|
||||
k1 = makeKlassAutoPtr("first")
|
||||
k2 = makeKlassAutoPtr("second")
|
||||
if Klass.getTotal_count() != 2:
|
||||
raise "number of objects should be 2"
|
||||
checkCount(2)
|
||||
|
||||
del k1
|
||||
if Klass.getTotal_count() != 1:
|
||||
raise "number of objects should be 1"
|
||||
checkCount(1)
|
||||
|
||||
if k2.getLabel() != "second":
|
||||
raise "wrong object label"
|
||||
|
||||
del k2
|
||||
if Klass.getTotal_count() != 0:
|
||||
raise "no objects should be left"
|
||||
checkCount(0)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,16 @@ def checkCount(expected_count)
|
|||
end
|
||||
end
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
kini = Cpp11_std_unique_ptr::KlassInheritance.new("KlassInheritanceInput")
|
||||
checkCount(1)
|
||||
s = Cpp11_std_unique_ptr.takeKlassUniquePtr(kini)
|
||||
if (s != "KlassInheritanceInput")
|
||||
raise RuntimeError, "Incorrect string: " + s
|
||||
end
|
||||
kini = nil
|
||||
checkCount(0)
|
||||
|
||||
|
||||
# unique_ptr as input
|
||||
kin = Cpp11_std_unique_ptr::Klass.new("KlassInput")
|
||||
|
|
|
|||
|
|
@ -18,6 +18,16 @@ def checkCount(expected_count)
|
|||
end
|
||||
end
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
kini = Li_std_auto_ptr::KlassInheritance.new("KlassInheritanceInput")
|
||||
checkCount(1)
|
||||
s = Li_std_auto_ptr.takeKlassAutoPtr(kini)
|
||||
if (s != "KlassInheritanceInput")
|
||||
raise RuntimeError, "Incorrect string: " + s
|
||||
end
|
||||
kini = nil
|
||||
checkCount(0)
|
||||
|
||||
|
||||
# auto_ptr as input
|
||||
kin = Li_std_auto_ptr::Klass.new("KlassInput")
|
||||
|
|
|
|||
|
|
@ -44,6 +44,13 @@ $k4 -delete
|
|||
checkCount 0
|
||||
################################# Tcl pointer recycling bug end
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
KlassInheritance kini "KlassInheritanceInput"
|
||||
checkCount 1
|
||||
set s [takeKlassUniquePtr kini]
|
||||
kini -delete
|
||||
checkCount 0
|
||||
|
||||
|
||||
# unique_ptr as input
|
||||
Klass kin "KlassInput"
|
||||
|
|
@ -122,20 +129,14 @@ checkCount 0
|
|||
# unique_ptr as output
|
||||
set k1 [makeKlassUniquePtr "first"]
|
||||
set k2 [makeKlassUniquePtr "second"]
|
||||
if {[Klass_getTotal_count] != 2} {
|
||||
error "number of objects should be 2"
|
||||
}
|
||||
checkCount 2
|
||||
|
||||
$k1 -delete
|
||||
if {[Klass_getTotal_count] != 1} {
|
||||
error "number of objects should be 1"
|
||||
}
|
||||
checkCount 1
|
||||
|
||||
if {[$k2 getLabel] != "second"} {
|
||||
error "wrong object label"
|
||||
}
|
||||
|
||||
$k2 -delete
|
||||
if {[Klass_getTotal_count] != 0} {
|
||||
error "no objects should be left"
|
||||
}
|
||||
checkCount 0
|
||||
|
|
|
|||
|
|
@ -15,6 +15,13 @@ proc checkCount {expected_count} {
|
|||
# Not copied from cpp11_std_unique_ptr_runme.tcl
|
||||
################################# Tcl pointer recycling bug end
|
||||
|
||||
# Test raw pointer handling involving virtual inheritance
|
||||
KlassInheritance kini "KlassInheritanceInput"
|
||||
checkCount 1
|
||||
set s [takeKlassAutoPtr kini]
|
||||
kini -delete
|
||||
checkCount 0
|
||||
|
||||
|
||||
# auto_ptr as input
|
||||
Klass kin "KlassInput"
|
||||
|
|
@ -93,20 +100,14 @@ checkCount 0
|
|||
# auto_ptr as output
|
||||
set k1 [makeKlassAutoPtr "first"]
|
||||
set k2 [makeKlassAutoPtr "second"]
|
||||
if {[Klass_getTotal_count] != 2} {
|
||||
error "number of objects should be 2"
|
||||
}
|
||||
checkCount 2
|
||||
|
||||
$k1 -delete
|
||||
if {[Klass_getTotal_count] != 1} {
|
||||
error "number of objects should be 1"
|
||||
}
|
||||
checkCount 1
|
||||
|
||||
if {[$k2 getLabel] != "second"} {
|
||||
error "wrong object label"
|
||||
}
|
||||
|
||||
$k2 -delete
|
||||
if {[Klass_getTotal_count] != 0} {
|
||||
error "no objects should be left"
|
||||
}
|
||||
checkCount 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue