Skip to content

Commit

Permalink
Update libcxx tests
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Jan 5, 2024
1 parent 6fa0555 commit cc0fe8c
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/sources/LibcxxTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "libcxx/Support.h"

#include "../../include/momo/Version.h"
#include "../../include/momo/ObjectManager.h"

#include <iostream>
Expand Down
3 changes: 3 additions & 0 deletions test/sources/libcxx/Support.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
#include <cfloat>
#include <string>
#include <cmath>
#include <optional>

//#define LIBCPP_HAS_BAD_NEWS_FOR_MOMO

#define TEST_STD_VER 20

#undef _LIBCPP_VERSION //?

#include "support/test_macros.h"

#include "support/MoveOnly.h"
Expand Down
4 changes: 4 additions & 0 deletions test/sources/libcxx/map/map.cons/deduct.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,17 @@ int main(int, char**)
ASSERT_SAME_TYPE(decltype(m1), momo::stdish::map<int, int>);

#if !defined(TEST_GCC) && !defined(TEST_CLANG)
#if MOMO_VERSION_MAJOR > 3
using value_type = std::pair<const int, int>;
momo::stdish::map m2{{value_type{1, 2}, {3, 4}}, std::less<int>()};
ASSERT_SAME_TYPE(decltype(m2), momo::stdish::map<int, int>);
#endif
#endif
}

#if MOMO_VERSION_MAJOR > 3
AssociativeContainerDeductionGuidesSfinaeAway<momo::stdish::map, momo::stdish::map<int, long>>();
#endif

return 0;
}
4 changes: 4 additions & 0 deletions test/sources/libcxx/map/map.cons/deduct_const.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ int main(int, char**)
assert(std::equal(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
}

#if MOMO_VERSION_MAJOR > 3
{
momo::stdish::map m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, std::greater<int>());

ASSERT_SAME_TYPE(decltype(m), momo::stdish::map<int, long, std::greater<int>>);
const PC expected_m[] = { {INT_MAX,1L}, {3,1L}, {2,2L}, {1, 1L} };
assert(std::equal(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
}
#endif

{
momo::stdish::map m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, std::greater<int>(), test_allocator<PC>(0, 43));
Expand All @@ -91,6 +93,7 @@ int main(int, char**)
assert(m.get_allocator().get_id() == 43);
}

#if MOMO_VERSION_MAJOR > 3
{
momo::stdish::map m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, test_allocator<PC>(0, 45));

Expand All @@ -99,6 +102,7 @@ int main(int, char**)
assert(std::equal(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
assert(m.get_allocator().get_id() == 45);
}
#endif
#endif

return 0;
Expand Down
4 changes: 4 additions & 0 deletions test/sources/libcxx/multimap/multimap.cons/deduct.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,17 @@ int main(int, char**)
ASSERT_SAME_TYPE(decltype(m1), momo::stdish::multimap<int, int>);

#if !defined(TEST_GCC) && !defined(TEST_CLANG)
#if MOMO_VERSION_MAJOR > 3
using value_type = std::pair<const int, int>;
momo::stdish::multimap m2{{value_type{1, 2}, {3, 4}}, std::less<int>()};
ASSERT_SAME_TYPE(decltype(m2), momo::stdish::multimap<int, int>);
#endif
#endif
}

#if MOMO_VERSION_MAJOR > 3
AssociativeContainerDeductionGuidesSfinaeAway<momo::stdish::multimap, momo::stdish::multimap<int, long>>();
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,15 @@ int main(int, char**)
assert(std::equal(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
}

#if MOMO_VERSION_MAJOR > 3
{
momo::stdish::multimap m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, std::greater<int>());

ASSERT_SAME_TYPE(decltype(m), momo::stdish::multimap<int, long, std::greater<int>>);
const PC expected_m[] = { {INT_MAX,1L}, {3,1L}, {2,2L}, {1,1L}, {1,1L} };
assert(std::equal(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
}
#endif

{
momo::stdish::multimap m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, std::greater<int>(), test_allocator<PC>(0, 43));
Expand All @@ -91,6 +93,7 @@ int main(int, char**)
assert(m.get_allocator().get_id() == 43);
}

#if MOMO_VERSION_MAJOR > 3
{
momo::stdish::multimap m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, test_allocator<PC>(0, 45));

Expand All @@ -99,6 +102,7 @@ int main(int, char**)
assert(std::equal(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
assert(m.get_allocator().get_id() == 45);
}
#endif
#endif

return 0;
Expand Down
2 changes: 2 additions & 0 deletions test/sources/libcxx/set/set.cons/deduct.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ int main(int, char **) {
assert(s.size() == 2);
}

#if MOMO_VERSION_MAJOR > 3
AssociativeContainerDeductionGuidesSfinaeAway<momo::stdish::set, momo::stdish::set<int>>();
#endif

return 0;
}
2 changes: 2 additions & 0 deletions test/sources/libcxx/unord.map/unord.map.cnstr/deduct.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ int main(int, char**)
ASSERT_SAME_TYPE(decltype(m2), momo::stdish::unordered_map<int, int>);
}

#if MOMO_VERSION_MAJOR > 3
UnorderedContainerDeductionGuidesSfinaeAway<momo::stdish::unordered_map, momo::stdish::unordered_map<int, long>>();
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ int main(int, char**)
assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
}

#if MOMO_VERSION_MAJOR > 3
{
momo::stdish::unordered_map m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, 42, std::hash<long long>());
ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_map<int, long, std::hash<long long>>);
Expand All @@ -125,6 +126,7 @@ int main(int, char**)
ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_map<int, long, std::hash<long long>, std::equal_to<>>);
assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
}
#endif

{
momo::stdish::unordered_map m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, 42, std::hash<long long>(), std::equal_to<>(), test_allocator<PC>(0, 44));
Expand All @@ -149,6 +151,7 @@ int main(int, char**)
assert(m.get_allocator().get_id() == 46);
}

#if MOMO_VERSION_MAJOR > 3
{
momo::stdish::unordered_map m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, 42, test_allocator<PC>(0, 47));
ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_map<int, long, momo::HashCoder<int>, std::equal_to<int>, test_allocator<PC>>);
Expand All @@ -162,6 +165,7 @@ int main(int, char**)
assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
assert(m.get_allocator().get_id() == 48);
}
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ int main(int, char**)
ASSERT_SAME_TYPE(decltype(m2), momo::stdish::unordered_multimap<int, int>);
}

#if MOMO_VERSION_MAJOR > 3
UnorderedContainerDeductionGuidesSfinaeAway<momo::stdish::unordered_multimap, momo::stdish::unordered_multimap<int, long>>();
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ int main(int, char**)
assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
}

#if MOMO_VERSION_MAJOR > 3
{
momo::stdish::unordered_multimap m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, 42, std::hash<long long>());
ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_multimap<int, long, std::hash<long long>>);
Expand All @@ -125,6 +126,7 @@ int main(int, char**)
ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_multimap<int, long, std::hash<long long>, std::equal_to<>>);
assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
}
#endif

{
momo::stdish::unordered_multimap m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, 42, std::hash<long long>(), std::equal_to<>(), test_allocator<PC>(0, 44));
Expand All @@ -149,6 +151,7 @@ int main(int, char**)
assert(m.get_allocator().get_id() == 46);
}

#if MOMO_VERSION_MAJOR > 3
{
momo::stdish::unordered_multimap m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, 42, test_allocator<PC>(0, 47));
ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_multimap<int, long, momo::HashCoder<int>, std::equal_to<int>, test_allocator<PC>>);
Expand All @@ -162,6 +165,7 @@ int main(int, char**)
assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m)));
assert(m.get_allocator().get_id() == 48);
}
#endif

return 0;
}
2 changes: 2 additions & 0 deletions test/sources/libcxx/unord.set/unord.set.cnstr/deduct.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ int main(int, char**)
}

#if !(defined(TEST_MSVC) && _MSC_VER < 1930) && !(defined(TEST_GCC) && __GNUC__ < 11)
#if MOMO_VERSION_MAJOR > 3
UnorderedContainerDeductionGuidesSfinaeAway<std::unordered_set, std::unordered_set<int>>();
#endif
#endif

return 0;
Expand Down
2 changes: 2 additions & 0 deletions test/sources/libcxx/vector/vector.cons/deduct.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ TEST_CONSTEXPR_CXX20 bool tests() {
}
}

#if MOMO_VERSION_MAJOR > 3
SequenceContainerDeductionGuidesSfinaeAway<momo::stdish::vector, momo::stdish::vector<int>>();
#endif

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ int main(int, char**)
typedef std::vector<MoveOnly, some_alloc2<MoveOnly>> C;
static_assert( std::is_nothrow_move_assignable<C>::value, "");
}
#if MOMO_VERSION_MAJOR > 3
{ // POCMA false, is_always_equal false
typedef std::vector<MoveOnly, some_alloc3<MoveOnly>> C;
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
}
#endif
#endif

return 0;
Expand Down

0 comments on commit cc0fe8c

Please sign in to comment.