]>
Commit | Line | Data |
---|---|---|
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 | ||
6 | #include "../helpers/prefix.hpp" | |
7 | #include <boost/unordered_map.hpp> | |
8 | #include "../helpers/postfix.hpp" | |
9 | ||
10 | #include "../helpers/test.hpp" | |
11 | #include <string> | |
12 | ||
13 | namespace at_tests { | |
14 | ||
15 | UNORDERED_AUTO_TEST(at_tests) { | |
16 | BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Create Map" << std::endl; | |
17 | ||
18 | boost::unordered_map<std::string, int> x; | |
19 | ||
20 | BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Add elements" << std::endl; | |
21 | ||
22 | x["one"] = 1; | |
23 | x["two"] = 2; | |
24 | ||
25 | BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Check existing elements" << std::endl; | |
26 | ||
27 | BOOST_TEST(x.at("one") == 1); | |
28 | BOOST_TEST(x.at("two") == 2); | |
29 | ||
30 | BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Check missing element" << std::endl; | |
31 | ||
32 | try { | |
33 | x.at("three"); | |
34 | BOOST_ERROR("Should have thrown."); | |
35 | } | |
36 | catch(std::out_of_range) { | |
37 | } | |
38 | ||
39 | BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Finished" << std::endl; | |
40 | } | |
41 | ||
42 | } | |
43 | ||
44 | RUN_TESTS() |