Changeset 323ae805 in mainline
- Timestamp:
- 2018-07-05T21:41:24Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cf51eae
- Parents:
- 46c7668
- git-author:
- Dzejrou <dzejrou@…> (2018-05-14 23:46:21)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:24)
- Location:
- uspace/lib/cpp
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/Makefile
r46c7668 r323ae805 65 65 src/internal/test/tuple.cpp \ 66 66 src/internal/test/unordered_map.cpp \ 67 src/internal/test/unordered_set.cpp \ 67 68 src/internal/test/vector.cpp 68 69 -
uspace/lib/cpp/include/internal/test/test.hpp
r46c7668 r323ae805 102 102 return true; 103 103 } 104 105 template<class Iterator, class Container> 106 void test_contains(const char* tname, Iterator first, 107 Iterator last, const Container& cont) 108 { 109 if (!assert_contains(first, last, cont)) 110 { 111 report(false, tname); 112 ++failed_; 113 ok_ = false; 114 } 115 else 116 { 117 report(true, tname); 118 ++succeeded_; 119 } 120 } 121 122 template<class Iterator1, class Iterator2, class Container> 123 void test_contains_multi(const char* tname, Iterator1 first1, 124 Iterator1 last1, Iterator2 first2, 125 const Container& cont) 126 { 127 if (!assert_contains_multi(first1, last1, first2, cont)) 128 { 129 report(false, tname); 130 ++failed_; 131 ok_ = false; 132 } 133 else 134 { 135 report(true, tname); 136 ++succeeded_; 137 } 138 } 139 140 template<class Iterator, class Container> 141 bool assert_contains(Iterator first, Iterator last, const Container& cont) 142 { 143 while (first != last) 144 { 145 if (cont.find(*first++) == cont.end()) 146 return false; 147 } 148 149 return true; 150 } 151 152 template<class Iterator1, class Iterator2, class Container> 153 bool assert_contains_multi(Iterator1 first1, Iterator1 last1, 154 Iterator2 first2, const Container& cont) 155 { 156 while (first1 != last1) 157 { 158 if (cont.count(*first1++) != *first2++) 159 return false; 160 } 161 162 return true; 163 } 104 164 }; 105 165 } -
uspace/lib/cpp/include/internal/test/tests.hpp
r46c7668 r323ae805 207 207 void test_emplace_insert(); 208 208 void test_multi(); 209 210 template<class Iterator, class Container> 211 void test_contains(const char* tname, Iterator first, 212 Iterator last, const Container& cont) 213 { 214 if (!assert_contains(first, last, cont)) 215 { 216 report(false, tname); 217 ++failed_; 218 ok_ = false; 219 } 220 else 221 { 222 report(true, tname); 223 ++succeeded_; 224 } 225 } 226 227 template<class Iterator1, class Iterator2, class Container> 228 void test_contains_multi(const char* tname, Iterator1 first1, 229 Iterator1 last1, Iterator2 first2, 230 const Container& cont) 231 { 232 if (!assert_contains_multi(first1, last1, first2, cont)) 233 { 234 report(false, tname); 235 ++failed_; 236 ok_ = false; 237 } 238 else 239 { 240 report(true, tname); 241 ++succeeded_; 242 } 243 } 244 245 template<class Iterator, class Container> 246 bool assert_contains(Iterator first, Iterator last, const Container& cont) 247 { 248 while (first != last) 249 { 250 if (cont.find(*first++) == cont.end()) 251 return false; 252 } 253 254 return true; 255 } 256 257 template<class Iterator1, class Iterator2, class Container> 258 bool assert_contains_multi(Iterator1 first1, Iterator1 last1, 259 Iterator2 first2, const Container& cont) 260 { 261 while (first1 != last1) 262 { 263 if (cont.count(*first1++) != *first2++) 264 return false; 265 } 266 267 return true; 268 } 209 }; 210 211 class unordered_set_test: public test_suite 212 { 213 public: 214 bool run(bool) override; 215 const char* name() override; 216 217 private: 218 void test_constructors_and_assignment(); 219 void test_emplace_insert(); 220 void test_multi(); 269 221 }; 270 222 }
Note:
See TracChangeset
for help on using the changeset viewer.