brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · b4a640d Raw
70 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <unordered_map>10 11// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,12//           class Alloc = allocator<pair<const Key, T>>>13// class unordered_multimap14 15// size_type bucket(const key_type& __k) const;16 17#include <unordered_map>18#include <string>19#include <cassert>20#include <iterator>21 22#include "test_macros.h"23#include "min_allocator.h"24 25int main(int, char**) {26  {27    typedef std::unordered_multimap<int, std::string> C;28    typedef std::pair<int, std::string> P;29    P a[] = {30        P(1, "one"),31        P(2, "two"),32        P(3, "three"),33        P(4, "four"),34        P(1, "four"),35        P(2, "four"),36    };37    const C c(std::begin(a), std::end(a));38    std::size_t bc = c.bucket_count();39    assert(bc >= 7);40    for (std::size_t i = 0; i < 13; ++i)41      LIBCPP_ASSERT(c.bucket(i) == i % bc);42  }43#if TEST_STD_VER >= 1144  {45    typedef std::unordered_multimap<int,46                                    std::string,47                                    std::hash<int>,48                                    std::equal_to<int>,49                                    min_allocator<std::pair<const int, std::string>>>50        C;51    typedef std::pair<int, std::string> P;52    P a[] = {53        P(1, "one"),54        P(2, "two"),55        P(3, "three"),56        P(4, "four"),57        P(1, "four"),58        P(2, "four"),59    };60    const C c(std::begin(a), std::end(a));61    std::size_t bc = c.bucket_count();62    assert(bc >= 7);63    for (std::size_t i = 0; i < 13; ++i)64      LIBCPP_ASSERT(c.bucket(i) == i % bc);65  }66#endif67 68  return 0;69}70