• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
11 // UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
12 // MODULES_DEFINES: _LIBCPP_DEBUG=1
13 // MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
14 
15 // Can't test the system lib because this test enables debug mode
16 // UNSUPPORTED: with_system_cxx_lib
17 
18 // test container debugging
19 
20 #define _LIBCPP_DEBUG 1
21 #define _LIBCPP_DEBUG_USE_EXCEPTIONS
22 #include <unordered_map>
23 #include <unordered_set>
24 #include <utility>
25 #include <cassert>
26 #include "debug_mode_helper.h"
27 
28 using namespace IteratorDebugChecks;
29 
30 template <class Container, ContainerType CT>
31 struct UnorderedContainerChecks : BasicContainerChecks<Container, CT> {
32   using Base = BasicContainerChecks<Container, CT>;
33   using value_type = typename Container::value_type;
34   using iterator = typename Container::iterator;
35   using const_iterator = typename Container::const_iterator;
36   using traits = std::iterator_traits<iterator>;
37   using category = typename traits::iterator_category;
38 
39   using Base::makeContainer;
40 public:
runUnorderedContainerChecks41   static void run() {
42     Base::run();
43     try {
44      // FIXME
45     } catch (...) {
46       assert(false && "uncaught debug exception");
47     }
48   }
49 private:
50 
51 };
52 
main()53 int main()
54 {
55   using SetAlloc = test_allocator<int>;
56   using MapAlloc = test_allocator<std::pair<const int, int>>;
57   {
58     UnorderedContainerChecks<
59         std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, MapAlloc>,
60         CT_UnorderedMap>::run();
61     UnorderedContainerChecks<
62         std::unordered_set<int, std::hash<int>, std::equal_to<int>, SetAlloc>,
63         CT_UnorderedSet>::run();
64     UnorderedContainerChecks<
65         std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, MapAlloc>,
66         CT_UnorderedMultiMap>::run();
67     UnorderedContainerChecks<
68         std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, SetAlloc>,
69         CT_UnorderedMultiSet>::run();
70   }
71 }
72