diff options
Diffstat (limited to 'libcxx/test/std/depr/depr.auto.ptr')
22 files changed, 851 insertions, 0 deletions
diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/A.h b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/A.h new file mode 100644 index 00000000000..cc16abe06d7 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/A.h @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef A_H +#define A_H + +#include <cassert> + +class A +{ + int id_; +public: + explicit A(int id) : id_(id) {++count;} + A(const A& a) : id_(a.id_) {++count;} + ~A() {assert(id_ >= 0); id_ = -1; --count;} + + int id() const {return id_;} + + static int count; +}; + +int A::count = 0; + +#endif // A_H diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/AB.h b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/AB.h new file mode 100644 index 00000000000..b7ec9882a05 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/AB.h @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef AB_H +#define AB_H + +#include <cassert> + +class A +{ + int id_; +public: + explicit A(int id) : id_(id) {++count;} + A(const A& a) : id_(a.id_) {++count;} + virtual ~A() {assert(id_ >= 0); id_ = -1; --count;} + + static int count; +}; + +int A::count = 0; + +class B + : public A +{ +public: + explicit B(int id) : A(id) {++count;} + B(const B& a) : A(a) {++count;} + virtual ~B() {--count;} + + static int count; +}; + +int B::count = 0; + +#endif // AB_H diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp new file mode 100644 index 00000000000..88f0904abb3 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// auto_ptr& operator=(auto_ptr& a) throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p1 = new A(1); + const std::auto_ptr<A> ap1(p1); + A* p2 = new A(2); + std::auto_ptr<A> ap2(p2); + assert(A::count == 2); + assert(ap1.get() == p1); + assert(ap2.get() == p2); + std::auto_ptr<A>& apr = ap2 = ap1; + assert(&apr == &ap2); + assert(A::count == 1); + assert(ap1.get() == 0); + assert(ap2.get() == p1); + } + assert(A::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp new file mode 100644 index 00000000000..2c6acb5af12 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// auto_ptr& operator=(auto_ptr& a) throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p1 = new A(1); + std::auto_ptr<A> ap1(p1); + A* p2 = new A(2); + std::auto_ptr<A> ap2(p2); + assert(A::count == 2); + assert(ap1.get() == p1); + assert(ap2.get() == p2); + std::auto_ptr<A>& apr = ap2 = ap1; + assert(&apr == &ap2); + assert(A::count == 1); + assert(ap1.get() == 0); + assert(ap2.get() == p1); + } + assert(A::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp new file mode 100644 index 00000000000..d5f38c1e22b --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// auto_ptr(auto_ptr& a) throw(); + +#include <memory> +#include <cassert> + +#include "../AB.h" + +void +test() +{ + { + B* p = new B(1); + const std::auto_ptr<B> ap1(p); + std::auto_ptr<A> ap2(ap1); + assert(ap1.get() == 0); + assert(ap2.get() == p); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp new file mode 100644 index 00000000000..aeea7dec9e3 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// auto_ptr(auto_ptr& a) throw(); + +#include <memory> +#include <cassert> + +#include "../AB.h" + +void +test() +{ + { + B* p = new B(1); + std::auto_ptr<B> ap1(p); + std::auto_ptr<A> ap2(ap1); + assert(ap1.get() == 0); + assert(ap2.get() == p); + assert(A::count == 1); + assert(B::count == 1); + } + assert(A::count == 0); + assert(B::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp new file mode 100644 index 00000000000..be95d2c19de --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw(); + +#include <memory> +#include <cassert> + +#include "../AB.h" + +void +test() +{ + { + B* p1 = new B(1); + const std::auto_ptr<B> ap1(p1); + A* p2 = new A(2); + std::auto_ptr<A> ap2(p2); + assert(A::count == 2); + assert(B::count == 1); + assert(ap1.get() == p1); + assert(ap2.get() == p2); + std::auto_ptr<A>& apr = ap2 = ap1; + assert(&apr == &ap2); + assert(A::count == 1); + assert(B::count == 1); + assert(ap1.get() == 0); + assert(ap2.get() == p1); + } + assert(A::count == 0); + assert(B::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp new file mode 100644 index 00000000000..6809073c2d0 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw(); + +#include <memory> +#include <cassert> + +#include "../AB.h" + +void +test() +{ + { + B* p1 = new B(1); + std::auto_ptr<B> ap1(p1); + A* p2 = new A(2); + std::auto_ptr<A> ap2(p2); + assert(A::count == 2); + assert(B::count == 1); + assert(ap1.get() == p1); + assert(ap2.get() == p2); + std::auto_ptr<A>& apr = ap2 = ap1; + assert(&apr == &ap2); + assert(A::count == 1); + assert(B::count == 1); + assert(ap1.get() == 0); + assert(ap2.get() == p1); + } + assert(A::count == 0); + assert(B::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp new file mode 100644 index 00000000000..78423e518ba --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// auto_ptr(auto_ptr& a) throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + const std::auto_ptr<A> ap1(p); + std::auto_ptr<A> ap2(ap1); + assert(ap1.get() == 0); + assert(ap2.get() == p); + assert(A::count == 1); + } + assert(A::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp new file mode 100644 index 00000000000..27ba0e513e4 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// auto_ptr(auto_ptr& a) throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr<A> ap1(p); + std::auto_ptr<A> ap2(ap1); + assert(ap1.get() == 0); + assert(ap2.get() == p); + assert(A::count == 1); + } + assert(A::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp new file mode 100644 index 00000000000..54eb162f068 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// explicit auto_ptr(X* p =0) throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr<A> ap = p; + assert(ap.get() == p); + assert(A::count == 1); + } + assert(A::count == 0); + { + std::auto_ptr<A> ap; + assert(ap.get() == 0); + } +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp new file mode 100644 index 00000000000..e29ff2e7824 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// explicit auto_ptr(X* p =0) throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr<A> ap(p); + assert(ap.get() == p); + assert(A::count == 1); + } + assert(A::count == 0); + { + std::auto_ptr<A> ap; + assert(ap.get() == 0); + } +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp new file mode 100644 index 00000000000..6f53581af42 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// auto_ptr& operator=(auto_ptr_ref<X> r) throw() + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p1 = new A(1); + std::auto_ptr<A> ap1(p1); + std::auto_ptr_ref<A> apr = ap1; + std::auto_ptr<A> ap2(new A(2)); + ap2 = apr; + assert(A::count == 1); + assert(ap2.get() == p1); + assert(ap1.get() == 0); + } + assert(A::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp new file mode 100644 index 00000000000..375780527cf --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// auto_ptr(auto_ptr_ref<X> r) throw(); + +#include <memory> +#include <cassert> + +#include "../AB.h" + +void +test() +{ + { + B* p1 = new B(1); + std::auto_ptr<B> ap1(p1); + std::auto_ptr_ref<A> apr = ap1; + std::auto_ptr<A> ap2(apr); + assert(ap2.get() == p1); + assert(ap1.get() == 0); + } + assert(A::count == 0); + assert(B::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp new file mode 100644 index 00000000000..00c0f6d30ca --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// template<class Y> operator auto_ptr<Y>() throw(); + +#include <memory> +#include <cassert> + +#include "../AB.h" + +std::auto_ptr<B> +source() +{ + return std::auto_ptr<B>(new B(1)); +} + +void +test() +{ + std::auto_ptr<A> ap2(source()); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp new file mode 100644 index 00000000000..f61a28e84d4 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// template<class Y> operator auto_ptr_ref<Y>() throw(); + +#include <memory> +#include <cassert> + +#include "../AB.h" + +void +test() +{ + B* p1 = new B(1); + std::auto_ptr<B> ap1(p1); + std::auto_ptr_ref<A> apr = ap1; + delete p1; +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp new file mode 100644 index 00000000000..fce9332df84 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// X& operator*() const throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr<A> ap(p); + assert(ap->id() == 1); + *ap = A(3); + assert(ap->id() == 3); + } + assert(A::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp new file mode 100644 index 00000000000..dd5669563e3 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// X& operator*() const throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + const std::auto_ptr<A> ap(p); + assert((*ap).id() == 1); + *ap = A(3); + assert((*ap).id() == 3); + } + assert(A::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp new file mode 100644 index 00000000000..5860eb41114 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// X* release() throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr<A> ap(p); + A* p2 = ap.release(); + assert(p2 == p); + assert(ap.get() == 0); + delete p; + } + assert(A::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp new file mode 100644 index 00000000000..cdbdd73ab72 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> class auto_ptr; + +// void reset(X* p=0) throw(); + +#include <memory> +#include <cassert> + +#include "../A.h" + +void +test() +{ + { + A* p = new A(1); + std::auto_ptr<A> ap(p); + ap.reset(); + assert(ap.get() == 0); + assert(A::count == 0); + } + assert(A::count == 0); + { + A* p = new A(1); + std::auto_ptr<A> ap(p); + ap.reset(p); + assert(ap.get() == p); + assert(A::count == 1); + } + assert(A::count == 0); + { + A* p = new A(1); + std::auto_ptr<A> ap(p); + A* p2 = new A(2); + ap.reset(p2); + assert(ap.get() == p2); + assert(A::count == 1); + } + assert(A::count == 0); +} + +int main() +{ + test(); +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp new file mode 100644 index 00000000000..2d1c2af8062 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <memory> + +// template <class X> +// class auto_ptr +// { +// public: +// typedef X element_type; +// ... +// }; + +#include <memory> +#include <type_traits> + +template <class T> +void +test() +{ + static_assert((std::is_same<typename std::auto_ptr<T>::element_type, T>::value), ""); +} + +int main() +{ + test<int>(); + test<double>(); + test<void>(); + std::auto_ptr<void> p; +} diff --git a/libcxx/test/std/depr/depr.auto.ptr/nothing_to_do.pass.cpp b/libcxx/test/std/depr/depr.auto.ptr/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/depr/depr.auto.ptr/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} |