[llvm-branch-commits] [libcxx] f63cdbc - [libc++][ranges] Fix `ranges::to` test.

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Aug 27 01:57:27 PDT 2023


Author: Konstantin Varlamov
Date: 2023-08-27T10:55:24+02:00
New Revision: f63cdbcc0cdccf14ac699207be6226b40b1751f8

URL: https://github.com/llvm/llvm-project/commit/f63cdbcc0cdccf14ac699207be6226b40b1751f8
DIFF: https://github.com/llvm/llvm-project/commit/f63cdbcc0cdccf14ac699207be6226b40b1751f8.diff

LOG: [libc++][ranges] Fix `ranges::to` test.

- Make a test for an internal concept libc++-only;
- Make sure that `size` and `capacity` in a test container return the
  same type on all platforms.

(cherry picked from commit 8b9a98661b780a5b50d1d6a1f822d25e0c454382)

Added: 
    

Modified: 
    libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp b/libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp
index 75f55bc420d0eb..03270f25fd92b2 100644
--- a/libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp
+++ b/libcxx/test/std/ranges/range.utility/range.utility.conv/to.pass.cpp
@@ -19,6 +19,7 @@
 #include <vector>
 #include "container.h"
 #include "test_iterators.h"
+#include "test_macros.h"
 #include "test_range.h"
 
 template <class Container, class Range, class... Args>
@@ -119,6 +120,7 @@ struct Fallback {
   constexpr void push_back(value_type) {}
   constexpr value_type* begin() { return &x; }
   constexpr value_type* end() { return &x; }
+  std::size_t size() const { return 0; }
 };
 
 struct CtrDirectOrFallback : Fallback {
@@ -180,7 +182,7 @@ struct Reservable : Fallback {
     reserve_called = true;
   }
 };
-static_assert(std::ranges::__reservable_container<Reservable<>>);
+LIBCPP_STATIC_ASSERT(std::ranges::__reservable_container<Reservable<>>);
 
 constexpr void test_constraints() {
   { // Case 1 -- construct directly from the range.


        


More information about the llvm-branch-commits mailing list