diff options
Diffstat (limited to 'libcxx/test/containers/sequences')
6 files changed, 238 insertions, 1 deletions
diff --git a/libcxx/test/containers/sequences/array/begin.pass.cpp b/libcxx/test/containers/sequences/array/begin.pass.cpp index 3ee929468c0..9cba0d6fceb 100644 --- a/libcxx/test/containers/sequences/array/begin.pass.cpp +++ b/libcxx/test/containers/sequences/array/begin.pass.cpp @@ -20,7 +20,8 @@ int main() typedef double T; typedef std::array<T, 3> C; C c = {1, 2, 3.5}; - C::iterator i = c.begin(); + C::iterator i; + i = c.begin(); assert(*i == 1); assert(&*i == c.data()); *i = 5.5; diff --git a/libcxx/test/containers/sequences/deque/iterators.pass.cpp b/libcxx/test/containers/sequences/deque/iterators.pass.cpp new file mode 100644 index 00000000000..7e38b86489f --- /dev/null +++ b/libcxx/test/containers/sequences/deque/iterators.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. +// +//===----------------------------------------------------------------------===// + +// <deque> + +// Test nested types and default template args: + +// template <class T, class Allocator = allocator<T> > +// class deque; + +// iterator, const_iterator + +#include <deque> +#include <iterator> +#include <cassert> + +int main() +{ + typedef std::deque<int> C; + C c; + C::iterator i; + i = c.begin(); + C::const_iterator j; + j = c.cbegin(); + assert(i == j); +} diff --git a/libcxx/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp b/libcxx/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp index bb25bbd6c90..e27e34bc5b5 100644 --- a/libcxx/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp +++ b/libcxx/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp @@ -67,5 +67,6 @@ int main() typedef int T; typedef std::forward_list<T> C; C::iterator i; + C::const_iterator j; } } diff --git a/libcxx/test/containers/sequences/list/iterators.pass.cpp b/libcxx/test/containers/sequences/list/iterators.pass.cpp new file mode 100644 index 00000000000..a53e977df9c --- /dev/null +++ b/libcxx/test/containers/sequences/list/iterators.pass.cpp @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <list> + +// iterator begin(); +// iterator end(); +// const_iterator begin() const; +// const_iterator end() const; +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include <list> +#include <cassert> +#include <iterator> + +int main() +{ + { + typedef int T; + typedef std::list<T> C; + C c; + C::iterator i = c.begin(); + C::iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef int T; + typedef std::list<T> C; + const C c; + C::const_iterator i = c.begin(); + C::const_iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef int T; + typedef std::list<T> C; + C c; + C::const_iterator i = c.cbegin(); + C::const_iterator j = c.cend(); + assert(std::distance(i, j) == 0); + assert(i == j); + assert(i == c.end()); + } + { + typedef int T; + typedef std::list<T> C; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(std::begin(t), std::end(t)); + C::iterator i = c.begin(); + assert(*i == 0); + ++i; + assert(*i == 1); + *i = 10; + assert(*i == 10); + assert(std::distance(c.begin(), c.end()) == 10); + } + { + typedef int T; + typedef std::list<T> C; + C::iterator i; + C::const_iterator j; + } +} diff --git a/libcxx/test/containers/sequences/vector.bool/iterators.pass.cpp b/libcxx/test/containers/sequences/vector.bool/iterators.pass.cpp new file mode 100644 index 00000000000..45b524c424a --- /dev/null +++ b/libcxx/test/containers/sequences/vector.bool/iterators.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <vector> + +// iterator begin(); +// iterator end(); +// const_iterator begin() const; +// const_iterator end() const; +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include <vector> +#include <cassert> +#include <iterator> + +int main() +{ + { + typedef bool T; + typedef std::vector<T> C; + C c; + C::iterator i = c.begin(); + C::iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef bool T; + typedef std::vector<T> C; + const C c; + C::const_iterator i = c.begin(); + C::const_iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef bool T; + typedef std::vector<T> C; + C c; + C::const_iterator i = c.cbegin(); + C::const_iterator j = c.cend(); + assert(std::distance(i, j) == 0); + assert(i == j); + assert(i == c.end()); + } + { + typedef bool T; + typedef std::vector<T> C; + C::iterator i; + C::const_iterator j; + } +} diff --git a/libcxx/test/containers/sequences/vector/iterators.pass.cpp b/libcxx/test/containers/sequences/vector/iterators.pass.cpp new file mode 100644 index 00000000000..9ebd20bd6bb --- /dev/null +++ b/libcxx/test/containers/sequences/vector/iterators.pass.cpp @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <vector> + +// iterator begin(); +// iterator end(); +// const_iterator begin() const; +// const_iterator end() const; +// const_iterator cbegin() const; +// const_iterator cend() const; + +#include <vector> +#include <cassert> +#include <iterator> + +int main() +{ + { + typedef int T; + typedef std::vector<T> C; + C c; + C::iterator i = c.begin(); + C::iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef int T; + typedef std::vector<T> C; + const C c; + C::const_iterator i = c.begin(); + C::const_iterator j = c.end(); + assert(std::distance(i, j) == 0); + assert(i == j); + } + { + typedef int T; + typedef std::vector<T> C; + C c; + C::const_iterator i = c.cbegin(); + C::const_iterator j = c.cend(); + assert(std::distance(i, j) == 0); + assert(i == j); + assert(i == c.end()); + } + { + typedef int T; + typedef std::vector<T> C; + const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + C c(std::begin(t), std::end(t)); + C::iterator i = c.begin(); + assert(*i == 0); + ++i; + assert(*i == 1); + *i = 10; + assert(*i == 10); + assert(std::distance(c.begin(), c.end()) == 10); + } + { + typedef int T; + typedef std::vector<T> C; + C::iterator i; + C::const_iterator j; + } +} |

