summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert')
-rw-r--r--libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/1.cc77
-rw-r--r--libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/2.cc77
-rw-r--r--libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/22102.cc140
-rw-r--r--libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/3.cc77
-rw-r--r--libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/4.cc78
5 files changed, 449 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/1.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/1.cc
new file mode 100644
index 000000000..f07e97d7d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/1.cc
@@ -0,0 +1,77 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <iterator>
+#include <map>
+#include <testsuite_hooks.h>
+#include <testsuite_rvalref.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::rvalstruct;
+
+ typedef std::multimap<int, rvalstruct> Map;
+ typedef std::pair<const int, rvalstruct> Pair;
+
+ Map m;
+ VERIFY( m.empty() );
+
+ Map::iterator i = m.insert(Pair(1, rvalstruct(3)));
+ VERIFY( m.size() == 1 );
+ VERIFY( std::distance(m.begin(), m.end()) == 1 );
+ VERIFY( i == m.begin() );
+ VERIFY( i->first == 1 );
+ VERIFY( (i->second).val == 3 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::rvalstruct;
+
+ typedef std::multimap<int, rvalstruct> Map;
+ typedef std::pair<const int, rvalstruct> Pair;
+
+ Map m;
+ VERIFY( m.empty() );
+
+ m.insert(Pair(2, rvalstruct(3)));
+ m.insert(Pair(2, rvalstruct(7)));
+
+ VERIFY( m.size() == 2 );
+ VERIFY( std::distance(m.begin(), m.end()) == 2 );
+
+ Map::iterator i1 = m.begin();
+ Map::iterator i2 = i1;
+ ++i2;
+
+ VERIFY( i1->first == 2 );
+ VERIFY( i2->first == 2 );
+ VERIFY( (i1->second).val == 3 && (i2->second).val == 7 );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/2.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/2.cc
new file mode 100644
index 000000000..56453cade
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/2.cc
@@ -0,0 +1,77 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <iterator>
+#include <map>
+#include <testsuite_hooks.h>
+#include <testsuite_rvalref.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::rvalstruct;
+
+ typedef std::multimap<rvalstruct, rvalstruct> Map;
+ typedef std::pair<rvalstruct, rvalstruct> Pair;
+
+ Map m;
+ VERIFY( m.empty() );
+
+ Map::iterator i = m.insert(Pair(rvalstruct(1), rvalstruct(3)));
+ VERIFY( m.size() == 1 );
+ VERIFY( std::distance(m.begin(), m.end()) == 1 );
+ VERIFY( i == m.begin() );
+ VERIFY( (i->first).val == 1 );
+ VERIFY( (i->second).val == 3 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::rvalstruct;
+
+ typedef std::multimap<rvalstruct, rvalstruct> Map;
+ typedef std::pair<rvalstruct, rvalstruct> Pair;
+
+ Map m;
+ VERIFY( m.empty() );
+
+ m.insert(Pair(rvalstruct(2), rvalstruct(3)));
+ m.insert(Pair(rvalstruct(2), rvalstruct(7)));
+
+ VERIFY( m.size() == 2 );
+ VERIFY( std::distance(m.begin(), m.end()) == 2 );
+
+ Map::iterator i1 = m.begin();
+ Map::iterator i2 = i1;
+ ++i2;
+
+ VERIFY( (i1->first).val == 2 );
+ VERIFY( (i2->first).val == 2 );
+ VERIFY( (i1->second).val == 3 && (i2->second).val == 7 );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/22102.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/22102.cc
new file mode 100644
index 000000000..e89251962
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/22102.cc
@@ -0,0 +1,140 @@
+// 2006-01-07 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.3.2 Class template multimap
+
+#include <map>
+#include <testsuite_hooks.h>
+
+// libstdc++/22102
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::multimap<int, int> Mmap;
+ typedef Mmap::value_type value_type;
+ typedef Mmap::iterator iterator;
+
+ Mmap mm1;
+
+ const iterator it1 = mm1.insert(value_type(0, 0));
+ const iterator it2 = mm1.insert(value_type(1, 1));
+ const iterator it3 = mm1.insert(value_type(2, 2));
+
+ const value_type vt1(2, 1);
+ const iterator it4 = mm1.insert(it1, vt1);
+ iterator it5 = it4;
+ iterator it6 = it4;
+ VERIFY( mm1.size() == 4 );
+ VERIFY( *it4 == vt1 );
+ VERIFY( ++it5 == it3 );
+ VERIFY( --it6 == it2 );
+ VERIFY( *it5 == *it3 );
+ VERIFY( *it6 == *it2 );
+
+ const value_type vt2(2, 0);
+ const iterator it7 = mm1.insert(mm1.begin(), vt2);
+ iterator it8 = it7;
+ iterator it9 = it7;
+ VERIFY( mm1.size() == 5 );
+ VERIFY( *it7 == vt2 );
+ VERIFY( ++it8 == it4 );
+ VERIFY( --it9 == it2 );
+ VERIFY( *it8 == *it4 );
+ VERIFY( *it9 == *it2 );
+
+ const value_type vt3(2, -1);
+ const iterator it10 = mm1.insert(it1, vt3);
+ iterator it11 = it10;
+ iterator it12 = it10;
+ VERIFY( mm1.size() == 6 );
+ VERIFY( *it10 == vt3 );
+ VERIFY( ++it11 == it7 );
+ VERIFY( --it12 == it2 );
+ VERIFY( *it11 == *it7 );
+ VERIFY( *it12 == *it2 );
+
+ const value_type vt4(0, 1);
+ const iterator it13 = mm1.insert(it10, vt4);
+ iterator it14 = it13;
+ iterator it15 = it13;
+ VERIFY( mm1.size() == 7 );
+ VERIFY( *it13 == vt4 );
+ VERIFY( ++it14 == it2 );
+ VERIFY( --it15 == it1 );
+ VERIFY( *it14 == *it2 );
+ VERIFY( *it15 == *it1 );
+
+ const value_type vt5(1, 0);
+ const iterator it16 = mm1.insert(it13, vt5);
+ iterator it17 = it16;
+ iterator it18 = it16;
+ VERIFY( mm1.size() == 8 );
+ VERIFY( *it16 == vt5 );
+ VERIFY( ++it17 == it2 );
+ VERIFY( --it18 == it13 );
+ VERIFY( *it17 == *it2 );
+ VERIFY( *it18 == *it13 );
+
+ const value_type vt6(0, -1);
+ const iterator it19 = mm1.insert(it1, vt6);
+ iterator it20 = it19;
+ VERIFY( mm1.size() == 9 );
+ VERIFY( *it19 == vt6 );
+ VERIFY( it19 == mm1.begin() );
+ VERIFY( ++it20 == it1 );
+ VERIFY( *it20 == *it1 );
+
+ const value_type vt7(3, 3);
+ const iterator it21 = mm1.insert(it19, vt7);
+ iterator it22 = it21;
+ iterator it23 = it21;
+ VERIFY( mm1.size() == 10 );
+ VERIFY( *it21 == vt7 );
+ VERIFY( ++it22 == mm1.end() );
+ VERIFY( --it23 == it3 );
+ VERIFY( *it23 == *it3 );
+
+ const value_type vt8(2, 3);
+ const iterator it24 = mm1.insert(mm1.end(), vt8);
+ iterator it25 = it24;
+ iterator it26 = it24;
+ VERIFY( mm1.size() == 11 );
+ VERIFY( *it24 == vt8 );
+ VERIFY( ++it25 == it21 );
+ VERIFY( --it26 == it3 );
+ VERIFY( *it25 == *it21 );
+ VERIFY( *it26 == *it3 );
+
+ const value_type vt9(3, 2);
+ const iterator it27 = mm1.insert(it3, vt9);
+ iterator it28 = it27;
+ iterator it29 = it27;
+ VERIFY( mm1.size() == 12 );
+ VERIFY( *it27 == vt9 );
+ VERIFY( ++it28 == it21 );
+ VERIFY( --it29 == it24 );
+ VERIFY( *it28 == *it21 );
+ VERIFY( *it29 == *it24 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/3.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/3.cc
new file mode 100644
index 000000000..dddd8c885
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/3.cc
@@ -0,0 +1,77 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <iterator>
+#include <map>
+#include <testsuite_hooks.h>
+#include <testsuite_rvalref.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::rvalstruct;
+
+ typedef std::multimap<int, rvalstruct> Map;
+ typedef std::pair<const int, rvalstruct> Pair;
+
+ Map m;
+ VERIFY( m.empty() );
+
+ Map::iterator i = m.insert(m.begin(), Pair(1, rvalstruct(3)));
+ VERIFY( m.size() == 1 );
+ VERIFY( std::distance(m.begin(), m.end()) == 1 );
+ VERIFY( i == m.begin() );
+ VERIFY( i->first == 1 );
+ VERIFY( (i->second).val == 3 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::rvalstruct;
+
+ typedef std::multimap<int, rvalstruct> Map;
+ typedef std::pair<const int, rvalstruct> Pair;
+
+ Map m;
+ VERIFY( m.empty() );
+
+ Map::iterator i0 = m.insert(m.begin(), Pair(2, rvalstruct(3)));
+ m.insert(i0, Pair(2, rvalstruct(7)));
+
+ VERIFY( m.size() == 2 );
+ VERIFY( std::distance(m.begin(), m.end()) == 2 );
+
+ Map::iterator i1 = m.begin();
+ Map::iterator i2 = i1;
+ ++i2;
+
+ VERIFY( i1->first == 2 );
+ VERIFY( i2->first == 2 );
+ VERIFY( (i1->second).val == 7 && (i2->second).val == 3 );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/4.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/4.cc
new file mode 100644
index 000000000..a53852cc1
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/4.cc
@@ -0,0 +1,78 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <iterator>
+#include <map>
+#include <testsuite_hooks.h>
+#include <testsuite_rvalref.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::rvalstruct;
+
+ typedef std::multimap<rvalstruct, rvalstruct> Map;
+ typedef std::pair<rvalstruct, rvalstruct> Pair;
+
+ Map m;
+ VERIFY( m.empty() );
+
+ Map::iterator i = m.insert(m.begin(),
+ Pair(rvalstruct(1), rvalstruct(3)));
+ VERIFY( m.size() == 1 );
+ VERIFY( std::distance(m.begin(), m.end()) == 1 );
+ VERIFY( i == m.begin() );
+ VERIFY( (i->first).val == 1 );
+ VERIFY( (i->second).val == 3 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::rvalstruct;
+
+ typedef std::multimap<rvalstruct, rvalstruct> Map;
+ typedef std::pair<rvalstruct, rvalstruct> Pair;
+
+ Map m;
+ VERIFY( m.empty() );
+
+ Map::iterator i0 = m.insert(Pair(rvalstruct(2), rvalstruct(3)));
+ m.insert(i0, Pair(rvalstruct(2), rvalstruct(7)));
+
+ VERIFY( m.size() == 2 );
+ VERIFY( std::distance(m.begin(), m.end()) == 2 );
+
+ Map::iterator i1 = m.begin();
+ Map::iterator i2 = i1;
+ ++i2;
+
+ VERIFY( (i1->first).val == 2 );
+ VERIFY( (i2->first).val == 2 );
+ VERIFY( (i1->second).val == 7 && (i2->second).val == 3 );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}