Skip to content

[libc++] Move a bunch of tests from libcxx/test/libcxx to libcxx/test/std #150199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ TEST_CONSTEXPR_CXX26 bool test() {
test<std::forward_list<long>>();
test<std::forward_list<double>>();

{ // Ensure that the result of operator== is converted to bool
// See LWG4135.
struct Bool {
Bool() = default;
Bool(const Bool&) = delete;
operator bool() const { return true; }
};

struct Int {
Bool& operator==(Int) const {
static Bool b;
return b;
}
};

std::forward_list<Int> l;
std::erase(l, Int{});
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
}

void test_ctor_under_alloc() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
#if TEST_STD_VER >= 11
{
using C = TCT::vector<>;
using It = forward_iterator<int*>;
Expand All @@ -155,6 +155,35 @@ void test_ctor_under_alloc() {
}
}
#endif
// FIXME: This is mostly the same test as above, just worse. They should be merged.
{
typedef std::vector<int, cpp03_allocator<int> > C;
typedef C::allocator_type Alloc;
{
Alloc::construct_called = false;
C v(arr1, arr1 + 1);
assert(Alloc::construct_called);
}
{
Alloc::construct_called = false;
C v(arr2, arr2 + 3);
assert(Alloc::construct_called);
}
}
{
typedef std::vector<int, cpp03_overload_allocator<int> > C;
typedef C::allocator_type Alloc;
{
Alloc::construct_called = false;
C v(arr1, arr1 + 1);
assert(Alloc::construct_called);
}
{
Alloc::construct_called = false;
C v(arr2, arr2 + 3);
assert(Alloc::construct_called);
}
}
}

// In C++03, you can't instantiate a template with a local type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
}

void test_ctor_under_alloc() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
#if TEST_STD_VER >= 11
{
using C = TCT::vector<>;
using It = forward_iterator<int*>;
Expand Down Expand Up @@ -173,6 +173,37 @@ void test_ctor_under_alloc() {
}
}
#endif
// FIXME: This is mostly the same test as above, just worse. They should be merged.
{
typedef std::vector<int, cpp03_allocator<int> > C;
typedef C::allocator_type Alloc;
Alloc a;
{
Alloc::construct_called = false;
C v(arr1, arr1 + 1, a);
assert(Alloc::construct_called);
}
{
Alloc::construct_called = false;
C v(arr2, arr2 + 3, a);
assert(Alloc::construct_called);
}
}
{
typedef std::vector<int, cpp03_overload_allocator<int> > C;
typedef C::allocator_type Alloc;
Alloc a;
{
Alloc::construct_called = false;
C v(arr1, arr1 + 1, a);
assert(Alloc::construct_called);
}
{
Alloc::construct_called = false;
C v(arr2, arr2 + 3, a);
assert(Alloc::construct_called);
}
}
}

TEST_CONSTEXPR_CXX20 bool test() {
Expand Down
Loading