diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-05-24 14:00:26 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-05-24 14:00:26 +0100 |
commit | 2fb1b29d371f1536d730852681f90ab6757acd8a (patch) | |
tree | 94a47c276f69450a823c5ac15a657898ce1fd92f /libstdc++-v3 | |
parent | 245254b8bb4a4933a9e10439bd31debd48843b54 (diff) | |
download | gcc-2fb1b29d371f1536d730852681f90ab6757acd8a.zip gcc-2fb1b29d371f1536d730852681f90ab6757acd8a.tar.gz gcc-2fb1b29d371f1536d730852681f90ab6757acd8a.tar.bz2 |
Fix broken shared_ptr test
* testsuite/20_util/shared_ptr/cons/alias-rval.cc: Fix test.
* testsuite/20_util/shared_ptr/cons/alias.cc: Remove unused function.
From-SVN: r271603
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias-rval.cc | 20 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc | 2 |
3 files changed, 16 insertions, 11 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 90043c5..0a83bd3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2019-05-24 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/20_util/shared_ptr/cons/alias-rval.cc: Fix test. + * testsuite/20_util/shared_ptr/cons/alias.cc: Remove unused function. + 2019-05-23 Jonathan Wakely <jwakely@redhat.com> * testsuite/20_util/function_objects/invoke/1.cc: Move C++17-specific diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias-rval.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias-rval.cc index 205587c..f0b0d9c 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias-rval.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias-rval.cc @@ -37,8 +37,6 @@ struct B : A A a; }; -void deletefunc(A* p) { delete p; } - // 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] // Aliasing constructors @@ -63,29 +61,33 @@ test01() void test02() { - std::shared_ptr<A> a(new A); + A* ptr = new A; + ptr->i = 100; + std::shared_ptr<A> a(ptr); std::shared_ptr<int> i1(std::move(a), &a->i); VERIFY( i1.use_count() == 1 ); - VERIFY( i1 != nullptr ); + VERIFY( *i1 == 100 ); VERIFY( a.use_count() == 0 ); VERIFY( a == nullptr ); std::shared_ptr<int> i2(i1); VERIFY( i2.use_count() == 2 ); - VERIFY( i2.get() == &a->i ); + VERIFY( i2.get() == &ptr->i ); } void test03() { std::shared_ptr<B> b1(new B); + b1->i = 100; + b1->a.i = 200; std::shared_ptr<B> b2(b1); std::shared_ptr<A> a1(std::move(b1), b1.get()); - std::shared_ptr<A> a2(b2, &b2->a); + std::shared_ptr<A> a2(std::move(b2), &b2->a); + VERIFY( a1.use_count() == 2 ); VERIFY( a2.use_count() == 2 ); - VERIFY( a1 != nullptr ); - VERIFY( a2 != nullptr ); - VERIFY( a1 != a2 ); + VERIFY( a1->i == 100 ); + VERIFY( a2->i == 200 ); VERIFY( b1.use_count() == 0 ); VERIFY( b2.use_count() == 0 ); VERIFY( b1 == nullptr ); diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc index 134a058..8dbb7af 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc @@ -36,8 +36,6 @@ struct B : A A a; }; -void deletefunc(A* p) { delete p; } - // 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] // Aliasing constructors |