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
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue