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:
William S Fulton 2022-08-05 20:36:29 +01:00
commit d4b1152d4b
20 changed files with 236 additions and 224 deletions

View file

@ -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)