diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-08-09 22:35:47 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-08-09 22:35:47 +0000 |
commit | f63d5fa236b4d49dabaed7f237c1ec91cd36e203 (patch) | |
tree | ab8a0558c5be429753a1c7c7df99ee0b62ffd702 /libcxx/test/containers | |
parent | 1abc1a5e14a95cb8164aa5e5d63cb67d69f37c06 (diff) | |
download | bcm5719-llvm-f63d5fa236b4d49dabaed7f237c1ec91cd36e203.tar.gz bcm5719-llvm-f63d5fa236b4d49dabaed7f237c1ec91cd36e203.zip |
Add some extra checks to the MoveOnly test class to ensure it is not constructed or assigned from in a moved-from state.
Some tests were constructing it with 0, so use -1 as the invalid state
instead.
Reviewers: Marshall Clow
Differential Revision: http://reviews.llvm.org/D4095
llvm-svn: 215301
Diffstat (limited to 'libcxx/test/containers')
-rw-r--r-- | libcxx/test/containers/MoveOnly.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libcxx/test/containers/MoveOnly.h b/libcxx/test/containers/MoveOnly.h index e4d9f649560..96eef95913c 100644 --- a/libcxx/test/containers/MoveOnly.h +++ b/libcxx/test/containers/MoveOnly.h @@ -22,11 +22,17 @@ class MoveOnly int data_; public: - MoveOnly(int data = 1) : data_(data) {} - MoveOnly(MoveOnly&& x) - : data_(x.data_) {x.data_ = 0;} - MoveOnly& operator=(MoveOnly&& x) - {data_ = x.data_; x.data_ = 0; return *this;} + MoveOnly(int data = 0) : data_(data) { assert(data != -1); } + MoveOnly(MoveOnly &&x) : data_(x.data_) { + assert(x.data_ != -1); + x.data_ = -1; + } + MoveOnly &operator=(MoveOnly &&x) { + assert(x.data_ != -1); + data_ = x.data_; + x.data_ = -1; + return *this; + } int get() const {return data_;} |