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 // <set> 11 12 // class multiset 13 14 // size_type count(const key_type& k) const; 15 16 #include <set> 17 #include <cassert> 18 19 #include "test_macros.h" 20 #include "min_allocator.h" 21 #include "private_constructor.hpp" 22 23 int main() 24 { 25 { 26 typedef int V; 27 typedef std::multiset<int> M; 28 { 29 typedef M::size_type R; 30 V ar[] = 31 { 32 5, 33 5, 34 5, 35 5, 36 7, 37 7, 38 7, 39 9, 40 9 41 }; 42 const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); 43 R r = m.count(4); 44 assert(r == 0); 45 r = m.count(5); 46 assert(r == 4); 47 r = m.count(6); 48 assert(r == 0); 49 r = m.count(7); 50 assert(r == 3); 51 r = m.count(8); 52 assert(r == 0); 53 r = m.count(9); 54 assert(r == 2); 55 r = m.count(10); 56 assert(r == 0); 57 } 58 } 59 #if TEST_STD_VER >= 11 60 { 61 typedef int V; 62 typedef std::multiset<int, std::less<int>, min_allocator<int>> M; 63 { 64 typedef M::size_type R; 65 V ar[] = 66 { 67 5, 68 5, 69 5, 70 5, 71 7, 72 7, 73 7, 74 9, 75 9 76 }; 77 const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); 78 R r = m.count(4); 79 assert(r == 0); 80 r = m.count(5); 81 assert(r == 4); 82 r = m.count(6); 83 assert(r == 0); 84 r = m.count(7); 85 assert(r == 3); 86 r = m.count(8); 87 assert(r == 0); 88 r = m.count(9); 89 assert(r == 2); 90 r = m.count(10); 91 assert(r == 0); 92 } 93 } 94 #endif 95 #if TEST_STD_VER > 11 96 { 97 typedef int V; 98 typedef std::multiset<int, std::less<>> M; 99 typedef M::size_type R; 100 V ar[] = 101 { 102 5, 103 5, 104 5, 105 5, 106 7, 107 7, 108 7, 109 9, 110 9 111 }; 112 const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); 113 R r = m.count(4); 114 assert(r == 0); 115 r = m.count(5); 116 assert(r == 4); 117 r = m.count(6); 118 assert(r == 0); 119 r = m.count(7); 120 assert(r == 3); 121 r = m.count(8); 122 assert(r == 0); 123 r = m.count(9); 124 assert(r == 2); 125 r = m.count(10); 126 assert(r == 0); 127 } 128 129 { 130 typedef PrivateConstructor V; 131 typedef std::multiset<V, std::less<>> M; 132 typedef M::size_type R; 133 134 M m; 135 m.insert ( V::make ( 5 )); 136 m.insert ( V::make ( 5 )); 137 m.insert ( V::make ( 5 )); 138 m.insert ( V::make ( 5 )); 139 m.insert ( V::make ( 7 )); 140 m.insert ( V::make ( 7 )); 141 m.insert ( V::make ( 7 )); 142 m.insert ( V::make ( 9 )); 143 m.insert ( V::make ( 9 )); 144 145 R r = m.count(4); 146 assert(r == 0); 147 r = m.count(5); 148 assert(r == 4); 149 r = m.count(6); 150 assert(r == 0); 151 r = m.count(7); 152 assert(r == 3); 153 r = m.count(8); 154 assert(r == 0); 155 r = m.count(9); 156 assert(r == 2); 157 r = m.count(10); 158 assert(r == 0); 159 } 160 #endif 161 } 162