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