]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/unordered/test/unordered/at_tests.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / unordered / test / unordered / at_tests.cpp
CommitLineData
7c673cae
FG
1
2// Copyright 2007-2009 Daniel James.
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
b32b8144 6// clang-format off
7c673cae
FG
7#include "../helpers/prefix.hpp"
8#include <boost/unordered_map.hpp>
9#include "../helpers/postfix.hpp"
b32b8144 10// clang-format on
7c673cae
FG
11
12#include "../helpers/test.hpp"
13#include <string>
14
15namespace at_tests {
16
b32b8144 17 UNORDERED_AUTO_TEST (at_tests) {
7c673cae
FG
18 BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Create Map" << std::endl;
19
20 boost::unordered_map<std::string, int> x;
b32b8144
FG
21 boost::unordered_map<std::string, int> const& x_const(x);
22
23 BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Check empty container" << std::endl;
24
25 try {
26 x.at("one");
27 BOOST_ERROR("Should have thrown.");
28 } catch (std::out_of_range) {
29 }
30
31 try {
32 x_const.at("one");
33 BOOST_ERROR("Should have thrown.");
34 } catch (std::out_of_range) {
35 }
7c673cae
FG
36
37 BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Add elements" << std::endl;
38
39 x["one"] = 1;
40 x["two"] = 2;
41
42 BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Check existing elements" << std::endl;
43
44 BOOST_TEST(x.at("one") == 1);
45 BOOST_TEST(x.at("two") == 2);
b32b8144
FG
46 BOOST_TEST(x_const.at("one") == 1);
47 BOOST_TEST(x_const.at("two") == 2);
7c673cae
FG
48
49 BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Check missing element" << std::endl;
50
51 try {
b32b8144
FG
52 x.at("three");
53 BOOST_ERROR("Should have thrown.");
54 } catch (std::out_of_range) {
7c673cae 55 }
b32b8144
FG
56
57 try {
58 x_const.at("three");
59 BOOST_ERROR("Should have thrown.");
60 } catch (std::out_of_range) {
7c673cae
FG
61 }
62
63 BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Finished" << std::endl;
b32b8144 64 }
7c673cae
FG
65}
66
67RUN_TESTS()