/Src/Dependencies/Boost/libs/unordered/test/unordered/at_tests.cpp

http://hadesmem.googlecode.com/ · C++ · 34 lines · 21 code · 10 blank · 3 comment · 2 complexity · 90c7237079e89c29cc4256402d00b90a MD5 · raw file

  1. // Copyright 2007-2009 Daniel James.
  2. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include "../helpers/prefix.hpp"
  5. #include <boost/unordered_map.hpp>
  6. #include "../helpers/test.hpp"
  7. #include <string>
  8. namespace at_tests {
  9. UNORDERED_AUTO_TEST(at_tests) {
  10. boost::unordered_map<std::string, int> x;
  11. typedef boost::unordered_map<std::string, int>::iterator iterator;
  12. x["one"] = 1;
  13. x["two"] = 2;
  14. BOOST_TEST(x.at("one") == 1);
  15. BOOST_TEST(x.at("two") == 2);
  16. try {
  17. x.at("three");
  18. BOOST_ERROR("Should have thrown.");
  19. }
  20. catch(std::out_of_range) {
  21. }
  22. }
  23. }
  24. RUN_TESTS()