diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 |
commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/thread/thread.threads/thread.thread.class/thread.thread.id | |
parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) |
Notes
Diffstat (limited to 'test/std/thread/thread.threads/thread.thread.class/thread.thread.id')
7 files changed, 219 insertions, 0 deletions
diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp new file mode 100644 index 0000000000000..585f7ea98a030 --- /dev/null +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// <thread> + +// class thread::id + +// id& operator=(const id&) = default; + +#include <thread> +#include <cassert> + +int main() +{ + std::thread::id id0; + std::thread::id id1; + id1 = id0; + assert(id1 == id0); + id1 = std::this_thread::get_id(); + assert(id1 != id0); +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp new file mode 100644 index 0000000000000..e8c38016b2886 --- /dev/null +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// <thread> + +// class thread::id + +// id(const id&) = default; + +#include <thread> +#include <cassert> + +int main() +{ + std::thread::id id0; + std::thread::id id1 = id0; + assert(id1 == id0); +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp new file mode 100644 index 0000000000000..0037deb1dd655 --- /dev/null +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// <thread> + +// class thread::id + +// id(); + +#include <thread> +#include <cassert> + +int main() +{ + std::thread::id id; + assert(id == std::thread::id()); +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp new file mode 100644 index 0000000000000..6dd4c3ec4f570 --- /dev/null +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// <thread> + +// class thread::id + +// bool operator==(thread::id x, thread::id y); +// bool operator!=(thread::id x, thread::id y); + +#include <thread> +#include <cassert> + +int main() +{ + std::thread::id id0; + std::thread::id id1; + id1 = id0; + assert( (id1 == id0)); + assert(!(id1 != id0)); + id1 = std::this_thread::get_id(); + assert(!(id1 == id0)); + assert( (id1 != id0)); +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp new file mode 100644 index 0000000000000..de52b1d00cdf3 --- /dev/null +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// <thread> + +// class thread::id + +// bool operator< (thread::id x, thread::id y); +// bool operator<=(thread::id x, thread::id y); +// bool operator> (thread::id x, thread::id y); +// bool operator>=(thread::id x, thread::id y); + +#include <thread> +#include <cassert> + +int main() +{ + std::thread::id id0; + std::thread::id id1; + std::thread::id id2 = std::this_thread::get_id(); + assert(!(id0 < id1)); + assert( (id0 <= id1)); + assert(!(id0 > id1)); + assert( (id0 >= id1)); + assert(!(id0 == id2)); + if (id0 < id2) { + assert( (id0 <= id2)); + assert(!(id0 > id2)); + assert(!(id0 >= id2)); + } else { + assert(!(id0 <= id2)); + assert( (id0 > id2)); + assert( (id0 >= id2)); + } +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp new file mode 100644 index 0000000000000..126965fe3fc38 --- /dev/null +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// <thread> + +// class thread::id + +// template<class charT, class traits> +// basic_ostream<charT, traits>& +// operator<<(basic_ostream<charT, traits>& out, thread::id id); + +#include <thread> +#include <sstream> +#include <cassert> + +int main() +{ + std::thread::id id0 = std::this_thread::get_id(); + std::ostringstream os; + os << id0; +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp new file mode 100644 index 0000000000000..106c69e2e4a1f --- /dev/null +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads + +// <functional> + +// template <class T> +// struct hash +// : public unary_function<T, size_t> +// { +// size_t operator()(T val) const; +// }; + +// Not very portable + +#include <thread> +#include <cassert> + +int main() +{ + std::thread::id id1; + std::thread::id id2 = std::this_thread::get_id(); + typedef std::hash<std::thread::id> H; + static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" ); + static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + H h; + assert(h(id1) != h(id2)); +} |