]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/unordered_set/insert/set_single.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / unordered_set / insert / set_single.cc
CommitLineData
8868286e 1// { dg-options "-std=gnu++11" }
73e1eac5 2
f1717362 3// Copyright (C) 2010-2016 Free Software Foundation, Inc.
73e1eac5 4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License along
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
19
20// Single-element insert
21
22#include <string>
23#include <iterator>
24#include <unordered_set>
25#include <testsuite_hooks.h>
26
27void test01()
28{
29 bool test __attribute__((unused)) = true;
30
31 typedef std::unordered_set<std::string> Set;
32 Set s;
33 VERIFY(s.empty());
34
35 std::pair<Set::iterator, bool> p = s.insert("abcde");
36 VERIFY(p.second);
37 VERIFY(s.size() == 1);
38 VERIFY(std::distance(s.begin(), s.end()) == 1);
39 VERIFY(p.first == s.begin());
40 VERIFY(*p.first == "abcde");
41}
42
43void test02()
44{
45 bool test __attribute__((unused)) = true;
46
47 typedef std::unordered_set<std::string> Set;
48 Set s;
49 VERIFY(s.empty());
50
51 std::pair<Set::iterator, bool> p1 = s.insert("abcde");
52 std::pair<Set::iterator, bool> p2 = s.insert("abcde");
53 VERIFY(p1.second);
54 VERIFY(!p2.second);
55 VERIFY(s.size() == 1);
56 VERIFY(p1.first == p2.first);
57 VERIFY(*p1.first == "abcde");
58}
59
60int main()
61{
62 test01();
63 test02();
64 return 0;
65}