summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/iterators/iterator.primitives/iterator.traits
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
committerEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
commit5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch)
treeafde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/iterators/iterator.primitives/iterator.traits
parentf11e8eab527fba316c64112f6e05de1a79693a3e (diff)
downloadbcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz
bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/iterators/iterator.primitives/iterator.traits')
-rw-r--r--libcxx/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp35
-rw-r--r--libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp38
-rw-r--r--libcxx/test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp43
-rw-r--r--libcxx/test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp35
4 files changed, 151 insertions, 0 deletions
diff --git a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp
new file mode 100644
index 00000000000..f40754fd9da
--- /dev/null
+++ b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<const T*>
+// {
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef const T* pointer;
+// typedef const T& reference;
+// typedef random_access_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ typedef std::iterator_traits<const A*> It;
+ static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<It::value_type, A>::value), "");
+ static_assert((std::is_same<It::pointer, const A*>::value), "");
+ static_assert((std::is_same<It::reference, const A&>::value), "");
+ static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
diff --git a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
new file mode 100644
index 00000000000..e48e44b3777
--- /dev/null
+++ b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/empty.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class NotAnIterator>
+// struct iterator_traits
+// {
+// };
+
+#include <iterator>
+
+struct not_an_iterator
+{
+};
+
+template <class _Tp>
+struct has_value_type
+{
+private:
+ struct two {char lx; char lxx;};
+ template <class _Up> static two test(...);
+ template <class _Up> static char test(typename _Up::value_type* = 0);
+public:
+ static const bool value = sizeof(test<_Tp>(0)) == 1;
+};
+
+int main()
+{
+ typedef std::iterator_traits<not_an_iterator> It;
+ static_assert(!(has_value_type<It>::value), "");
+}
diff --git a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp
new file mode 100644
index 00000000000..38f7c0b6b83
--- /dev/null
+++ b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/iterator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class Iter>
+// struct iterator_traits
+// {
+// typedef typename Iter::difference_type difference_type;
+// typedef typename Iter::value_type value_type;
+// typedef typename Iter::pointer pointer;
+// typedef typename Iter::reference reference;
+// typedef typename Iter::iterator_category iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+struct test_iterator
+{
+ typedef int difference_type;
+ typedef A value_type;
+ typedef A* pointer;
+ typedef A& reference;
+ typedef std::forward_iterator_tag iterator_category;
+};
+
+int main()
+{
+ typedef std::iterator_traits<test_iterator> It;
+ static_assert((std::is_same<It::difference_type, int>::value), "");
+ static_assert((std::is_same<It::value_type, A>::value), "");
+ static_assert((std::is_same<It::pointer, A*>::value), "");
+ static_assert((std::is_same<It::iterator_category, std::forward_iterator_tag>::value), "");
+}
diff --git a/libcxx/test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp
new file mode 100644
index 00000000000..5a8fe60774e
--- /dev/null
+++ b/libcxx/test/std/iterators/iterator.primitives/iterator.traits/pointer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<T*>
+// {
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef T* pointer;
+// typedef T& reference;
+// typedef random_access_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ typedef std::iterator_traits<A*> It;
+ static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<It::value_type, A>::value), "");
+ static_assert((std::is_same<It::pointer, A*>::value), "");
+ static_assert((std::is_same<It::reference, A&>::value), "");
+ static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
OpenPOWER on IntegriCloud