Fix unique_ptr.runtime tests for null inputs. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276587 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
class Deleter
|
||||
{
|
||||
int state_;
|
||||
@@ -36,9 +38,18 @@ int main()
|
||||
Deleter d;
|
||||
assert(d.state() == 0);
|
||||
{
|
||||
std::unique_ptr<int[], Deleter&> p(nullptr, d);
|
||||
assert(p.get() == 0);
|
||||
assert(&p.get_deleter() == &d);
|
||||
}
|
||||
#if defined(_LIBCPP_VERSION)
|
||||
{
|
||||
// The standard only requires the constructor accept nullptr, but libc++
|
||||
// also supports the literal 0.
|
||||
std::unique_ptr<int[], Deleter&> p(0, d);
|
||||
assert(p.get() == 0);
|
||||
assert(&p.get_deleter() == &d);
|
||||
}
|
||||
#endif
|
||||
assert(d.state() == 0);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,9 @@ int main()
|
||||
assert(A::count == 0);
|
||||
|
||||
{ // LWG#2520 says that nullptr is a valid input as well as null
|
||||
#ifdef _LIBCPP_VERSION
|
||||
std::unique_ptr<A[], Deleter<A[]> > s1(NULL, Deleter<A[]>());
|
||||
#endif
|
||||
std::unique_ptr<A[], Deleter<A[]> > s2(nullptr, Deleter<A[]>());
|
||||
}
|
||||
assert(A::count == 0);
|
||||
|
||||
Reference in New Issue
Block a user