forked from OSchip/llvm-project
Fix failing unique_ptr tests.
When I was refactoring the unique_ptr.single.ctor tests I added a test deleter, 'NCDeleter', to deleter.h. Other tests that include deleter.h redefine the NCDeleter type causing test failures. llvm-svn: 243733
This commit is contained in:
parent
7138765d45
commit
32ad52170c
|
@ -32,22 +32,6 @@ struct A
|
|||
|
||||
int A::count = 0;
|
||||
|
||||
class NCDeleter
|
||||
{
|
||||
int state_;
|
||||
|
||||
NCDeleter(NCDeleter&);
|
||||
NCDeleter& operator=(NCDeleter&);
|
||||
public:
|
||||
|
||||
NCDeleter() : state_(5) {}
|
||||
|
||||
int state() const {return state_;}
|
||||
void set_state(int s) {state_ = s;}
|
||||
|
||||
void operator()(A* p) {delete [] p;}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
@ -71,10 +55,10 @@ int main()
|
|||
}
|
||||
assert(A::count == 0);
|
||||
{
|
||||
NCDeleter d;
|
||||
std::unique_ptr<A[], NCDeleter&> s(new A[3], d);
|
||||
NCDeleter<A[]> d;
|
||||
std::unique_ptr<A[], NCDeleter<A[]>&> s(new A[3], d);
|
||||
A* p = s.get();
|
||||
std::unique_ptr<A[], NCDeleter&> s2 = std::move(s);
|
||||
std::unique_ptr<A[], NCDeleter<A[]>&> s2 = std::move(s);
|
||||
assert(s2.get() == p);
|
||||
assert(s.get() == 0);
|
||||
assert(A::count == 3);
|
||||
|
|
|
@ -31,21 +31,6 @@ struct A
|
|||
|
||||
int A::count = 0;
|
||||
|
||||
class NCDeleter
|
||||
{
|
||||
int state_;
|
||||
|
||||
NCDeleter(NCDeleter&);
|
||||
NCDeleter& operator=(NCDeleter&);
|
||||
public:
|
||||
|
||||
NCDeleter() : state_(5) {}
|
||||
|
||||
int state() const {return state_;}
|
||||
void set_state(int s) {state_ = s;}
|
||||
|
||||
void operator()(A* p) {delete [] p;}
|
||||
};
|
||||
|
||||
std::unique_ptr<A[]>
|
||||
source1()
|
||||
|
@ -67,14 +52,14 @@ void sink2(std::unique_ptr<A[], Deleter<A[]> > p)
|
|||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<A[], NCDeleter&>
|
||||
std::unique_ptr<A[], NCDeleter<A[]>&>
|
||||
source3()
|
||||
{
|
||||
static NCDeleter d;
|
||||
return std::unique_ptr<A[], NCDeleter&>(new A[3], d);
|
||||
static NCDeleter<A[]> d;
|
||||
return std::unique_ptr<A[], NCDeleter<A[]>&>(new A[3], d);
|
||||
}
|
||||
|
||||
void sink3(std::unique_ptr<A[], NCDeleter&> p)
|
||||
void sink3(std::unique_ptr<A[], NCDeleter<A[]>&> p)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue