diff options
author | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2010-05-11 19:42:16 +0000 |
commit | 3e519524c118651123eecf60c2bbc5d65ad9bac3 (patch) | |
tree | b2dd4168cfe448920a602cd7d2e40f95da187153 /libcxx/test/containers/associative/multimap/iterator.pass.cpp | |
parent | 9132c59d43b6c590c9bb33496eebf9f192d6857a (diff) | |
download | bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.tar.gz bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.zip |
libcxx initial import
llvm-svn: 103490
Diffstat (limited to 'libcxx/test/containers/associative/multimap/iterator.pass.cpp')
-rw-r--r-- | libcxx/test/containers/associative/multimap/iterator.pass.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/libcxx/test/containers/associative/multimap/iterator.pass.cpp b/libcxx/test/containers/associative/multimap/iterator.pass.cpp new file mode 100644 index 00000000000..70b95f5b8ee --- /dev/null +++ b/libcxx/test/containers/associative/multimap/iterator.pass.cpp @@ -0,0 +1,120 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class multimap + +// iterator begin(); +// const_iterator begin() const; +// iterator end(); +// const_iterator end() const; +// +// reverse_iterator rbegin(); +// const_reverse_iterator rbegin() const; +// reverse_iterator rend(); +// const_reverse_iterator rend() const; +// +// const_iterator cbegin() const; +// const_iterator cend() const; +// const_reverse_iterator crbegin() const; +// const_reverse_iterator crend() const; + +#include <map> +#include <cassert> + +int main() +{ + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + V(4, 1), + V(4, 1.5), + V(4, 2), + V(5, 1), + V(5, 1.5), + V(5, 2), + V(6, 1), + V(6, 1.5), + V(6, 2), + V(7, 1), + V(7, 1.5), + V(7, 2), + V(8, 1), + V(8, 1.5), + V(8, 2) + }; + std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + std::multimap<int, double>::iterator i = m.begin(); + std::multimap<int, double>::const_iterator k = i; + assert(i == k); + for (int j = 1; j <= 8; ++j) + for (double d = 1; d <= 2; d += .5, ++i) + { + assert(i->first == j); + assert(i->second == d); + i->second = 2.5; + assert(i->second == 2.5); + } + } + { + typedef std::pair<const int, double> V; + V ar[] = + { + V(1, 1), + V(1, 1.5), + V(1, 2), + V(2, 1), + V(2, 1.5), + V(2, 2), + V(3, 1), + V(3, 1.5), + V(3, 2), + V(4, 1), + V(4, 1.5), + V(4, 2), + V(5, 1), + V(5, 1.5), + V(5, 2), + V(6, 1), + V(6, 1.5), + V(6, 2), + V(7, 1), + V(7, 1.5), + V(7, 2), + V(8, 1), + V(8, 1.5), + V(8, 2) + }; + const std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0])); + assert(std::distance(m.begin(), m.end()) == m.size()); + assert(std::distance(m.cbegin(), m.cend()) == m.size()); + assert(std::distance(m.rbegin(), m.rend()) == m.size()); + assert(std::distance(m.crbegin(), m.crend()) == m.size()); + std::multimap<int, double>::const_iterator i = m.begin(); + for (int j = 1; j <= 8; ++j) + for (double d = 1; d <= 2; d += .5, ++i) + { + assert(i->first == j); + assert(i->second == d); + } + } +} |