Skip to content

Commit

Permalink
Update libcxx/unord.set
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Dec 16, 2023
1 parent 3d45c9d commit 615306b
Show file tree
Hide file tree
Showing 41 changed files with 788 additions and 1,059 deletions.
47 changes: 15 additions & 32 deletions test/sources/libcxx/unord.set/bucket.pass.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
Expand All @@ -19,19 +18,10 @@

// size_type bucket(const key_type& __k) const;

#ifdef _LIBCPP_DEBUG
//#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif

//#include <unordered_set>
//#include <cassert>

//#include "min_allocator.h"

void main()
int main(int, char**)
{
{
typedef unordered_set<int, LibcppIntHash> C;
typedef std::unordered_set<int> C;
typedef int P;
P a[] =
{
Expand All @@ -43,15 +33,14 @@ void main()
P(2)
};
const C c(std::begin(a), std::end(a));
size_t bc = c.bucket_count();
std::size_t bc = c.bucket_count();
assert(bc >= 5);
for (size_t i = 0; i < 13; ++i)
assert(c.bucket(static_cast<int>(i)) == i % bc);
for (std::size_t i = 0; i < 13; ++i)
LIBCPP_ASSERT(c.bucket(i) == i % bc);
}
//#if __cplusplus >= 201103L
#ifdef LIBCPP_TEST_MIN_ALLOCATOR
#if TEST_STD_VER >= 11
{
typedef unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef int P;
P a[] =
{
Expand All @@ -63,18 +52,12 @@ void main()
P(2)
};
const C c(std::begin(a), std::end(a));
size_t bc = c.bucket_count();
std::size_t bc = c.bucket_count();
assert(bc >= 5);
for (size_t i = 0; i < 13; ++i)
assert(c.bucket(i) == i % bc);
}
#endif
#if _LIBCPP_DEBUG_LEVEL >= 1
{
typedef unordered_set<int> C;
C c;
LIBCPP_CATCH(c.bucket(3));
//assert(false);
for (std::size_t i = 0; i < 13; ++i)
LIBCPP_ASSERT(c.bucket(i) == i % bc);
}
#endif

return 0;
}
41 changes: 15 additions & 26 deletions test/sources/libcxx/unord.set/bucket_count.pass.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
Expand All @@ -19,23 +18,15 @@

// size_type bucket_count() const;

//#include <unordered_set>
//#include <cassert>

//#include "min_allocator.h"

void main()
int main(int, char**)
{
{
typedef unordered_set<int> C;
typedef C::const_iterator I;
typedef int P;
typedef std::unordered_set<int> C;
const C c;
assert(c.bucket_count() == 0);
LIBCPP_ASSERT(c.bucket_count() == 0);
}
{
typedef unordered_set<int> C;
typedef C::const_iterator I;
typedef std::unordered_set<int> C;
typedef int P;
P a[] =
{
Expand All @@ -49,20 +40,16 @@ void main()
P(80)
};
const C c(std::begin(a), std::end(a));
assert(c.bucket_count() >= 11);
assert(c.bucket_count() >= 8);
}
//#if __cplusplus >= 201103L
#ifdef LIBCPP_TEST_MIN_ALLOCATOR
#if TEST_STD_VER >= 11
{
typedef unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef C::const_iterator I;
typedef int P;
typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
const C c;
assert(c.bucket_count() == 0);
LIBCPP_ASSERT(c.bucket_count() == 0);
}
{
typedef unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef C::const_iterator I;
typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef int P;
P a[] =
{
Expand All @@ -76,7 +63,9 @@ void main()
P(80)
};
const C c(std::begin(a), std::end(a));
assert(c.bucket_count() >= 11);
assert(c.bucket_count() >= 8);
}
#endif

return 0;
}
55 changes: 19 additions & 36 deletions test/sources/libcxx/unord.set/bucket_size.pass.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
Expand All @@ -19,19 +18,10 @@

// size_type bucket_size(size_type n) const

#ifdef _LIBCPP_DEBUG
//#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif

//#include <unordered_set>
//#include <cassert>

//#include "min_allocator.h"

void main()
int main(int, char**)
{
{
typedef unordered_set<int, LibcppIntHash> C;
typedef std::unordered_set<int> C;
typedef int P;
P a[] =
{
Expand All @@ -44,16 +34,15 @@ void main()
};
const C c(std::begin(a), std::end(a));
assert(c.bucket_count() >= 5);
assert(c.bucket_size(0) == 0);
assert(c.bucket_size(1) == 1);
assert(c.bucket_size(2) == 1);
assert(c.bucket_size(3) == 1);
assert(c.bucket_size(4) == 1);
LIBCPP_ASSERT(c.bucket_size(0) == 0);
LIBCPP_ASSERT(c.bucket_size(1) == 1);
LIBCPP_ASSERT(c.bucket_size(2) == 1);
LIBCPP_ASSERT(c.bucket_size(3) == 1);
LIBCPP_ASSERT(c.bucket_size(4) == 1);
}
//#if __cplusplus >= 201103L
#ifdef LIBCPP_TEST_MIN_ALLOCATOR
#if TEST_STD_VER >= 11
{
typedef unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef int P;
P a[] =
{
Expand All @@ -66,19 +55,13 @@ void main()
};
const C c(std::begin(a), std::end(a));
assert(c.bucket_count() >= 5);
assert(c.bucket_size(0) == 0);
assert(c.bucket_size(1) == 1);
assert(c.bucket_size(2) == 1);
assert(c.bucket_size(3) == 1);
assert(c.bucket_size(4) == 1);
}
#endif
#if _LIBCPP_DEBUG_LEVEL >= 1
{
typedef unordered_set<int> C;
C c;
LIBCPP_CATCH(c.bucket_size(3));
//assert(false);
LIBCPP_ASSERT(c.bucket_size(0) == 0);
LIBCPP_ASSERT(c.bucket_size(1) == 1);
LIBCPP_ASSERT(c.bucket_size(2) == 1);
LIBCPP_ASSERT(c.bucket_size(3) == 1);
LIBCPP_ASSERT(c.bucket_size(4) == 1);
}
#endif

return 0;
}
27 changes: 12 additions & 15 deletions test/sources/libcxx/unord.set/clear.pass.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
Expand All @@ -17,17 +16,12 @@
// class Alloc = allocator<Value>>
// class unordered_set

// void clear()

//#include <unordered_set>
//#include <cassert>
// void clear() noexcept;

//#include "min_allocator.h"

void main()
int main(int, char**)
{
{
typedef unordered_set<int> C;
typedef std::unordered_set<int> C;
typedef int P;
P a[] =
{
Expand All @@ -39,13 +33,13 @@ void main()
P(2)
};
C c(a, a + sizeof(a)/sizeof(a[0]));
ASSERT_NOEXCEPT(c.clear());
c.clear();
assert(c.size() == 0);
}
//#if __cplusplus >= 201103L
#ifdef LIBCPP_TEST_MIN_ALLOCATOR
#if TEST_STD_VER >= 11
{
typedef unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef int P;
P a[] =
{
Expand All @@ -57,8 +51,11 @@ void main()
P(2)
};
C c(a, a + sizeof(a)/sizeof(a[0]));
ASSERT_NOEXCEPT(c.clear());
c.clear();
assert(c.size() == 0);
}
#endif

return 0;
}
11 changes: 5 additions & 6 deletions test/sources/libcxx/unord.set/contains.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

// UNSUPPORTED: c++03, c++11, c++14, c++17

//#include <cassert>
//#include <unordered_set>

// <unordered_set>

// bool contains(const key_type& x) const;
Expand All @@ -32,10 +29,12 @@ void test(B bad, Vals... args) {

struct E { int a = 1; double b = 1; char c = 1; };

void main()
int main(int, char**)
{
{
test<unordered_set<int>, int>(14, 10, 11, 12, 13);
test<unordered_set<char>, char>('e', 'a', 'b', 'c', 'd');
test<std::unordered_set<int>, int>(14, 10, 11, 12, 13);
test<std::unordered_set<char>, char>('e', 'a', 'b', 'c', 'd');
}

return 0;
}
23 changes: 9 additions & 14 deletions test/sources/libcxx/unord.set/count.pass.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
Expand All @@ -19,15 +18,10 @@

// size_type count(const key_type& k) const;

//#include <unordered_set>
//#include <cassert>

//#include "min_allocator.h"

void main()
int main(int, char**)
{
{
typedef unordered_set<int> C;
typedef std::unordered_set<int> C;
typedef int P;
P a[] =
{
Expand All @@ -47,10 +41,9 @@ void main()
assert(c.count(50) == 1);
assert(c.count(5) == 0);
}
//#if __cplusplus >= 201103L
#ifdef LIBCPP_TEST_MIN_ALLOCATOR
#if TEST_STD_VER >= 11
{
typedef unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
typedef int P;
P a[] =
{
Expand All @@ -71,4 +64,6 @@ void main()
assert(c.count(5) == 0);
}
#endif

return 0;
}
Loading

0 comments on commit 615306b

Please sign in to comment.