[libcxx] r323719 - Add tests to make sure that <string_view> provides std::size/data/empty in C++17 mode. This is LWG#3009, coming up for a vote in JAX - but we already do it, just don't have tests
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 29 16:47:43 PST 2018
Author: marshall
Date: Mon Jan 29 16:47:43 2018
New Revision: 323719
URL: http://llvm.org/viewvc/llvm-project?rev=323719&view=rev
Log:
Add tests to make sure that <string_view> provides std::size/data/empty in C++17 mode. This is LWG#3009, coming up for a vote in JAX - but we already do it, just don't have tests
Modified:
libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp
libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp
libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp
libcxx/trunk/test/std/strings/string.view/string.view.access/data.pass.cpp
libcxx/trunk/test/std/strings/string.view/string.view.capacity/capacity.pass.cpp
Modified: libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp?rev=323719&r1=323718&r2=323719&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.container/data.pass.cpp Mon Jan 29 16:47:43 2018
@@ -23,6 +23,10 @@
#include "test_macros.h"
+#if TEST_STD_VER > 14
+#include <string_view>
+#endif
+
template<typename C>
void test_const_container( const C& c )
{
@@ -72,6 +76,12 @@ int main()
test_const_container ( a );
test_const_container ( il );
+#if TEST_STD_VER > 14
+ std::string_view sv{"ABC"};
+ test_container ( sv );
+ test_const_container ( sv );
+#endif
+
static constexpr int arrA [] { 1, 2, 3 };
test_const_array ( arrA );
}
Modified: libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp?rev=323719&r1=323718&r2=323719&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.container/empty.pass.cpp Mon Jan 29 16:47:43 2018
@@ -23,6 +23,10 @@
#include "test_macros.h"
+#if TEST_STD_VER > 14
+#include <string_view>
+#endif
+
template<typename C>
void test_const_container( const C& c )
{
@@ -74,6 +78,12 @@ int main()
test_const_container ( a );
test_const_container ( il );
+#if TEST_STD_VER > 14
+ std::string_view sv{"ABC"};
+ test_container ( sv );
+ test_const_container ( sv );
+#endif
+
static constexpr int arrA [] { 1, 2, 3 };
test_const_array ( arrA );
}
Modified: libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp?rev=323719&r1=323718&r2=323719&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.container/size.pass.cpp Mon Jan 29 16:47:43 2018
@@ -22,6 +22,11 @@
#include "test_macros.h"
+#if TEST_STD_VER > 14
+#include <string_view>
+#endif
+
+
template<typename C>
void test_const_container( const C& c )
{
@@ -65,7 +70,6 @@ int main()
std::list<int> l; l.push_back(2);
std::array<int, 1> a; a[0] = 3;
std::initializer_list<int> il = { 4 };
-
test_container ( v );
test_container ( l );
test_container ( a );
@@ -76,6 +80,12 @@ int main()
test_const_container ( a );
test_const_container ( il );
+#if TEST_STD_VER > 14
+ std::string_view sv{"ABC"};
+ test_container ( sv );
+ test_const_container ( sv );
+#endif
+
static constexpr int arrA [] { 1, 2, 3 };
test_const_array ( arrA );
}
Modified: libcxx/trunk/test/std/strings/string.view/string.view.access/data.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.access/data.pass.cpp?rev=323719&r1=323718&r2=323719&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/string.view/string.view.access/data.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/string.view/string.view.access/data.pass.cpp Mon Jan 29 16:47:43 2018
@@ -22,6 +22,10 @@ void test ( const CharT *s, size_t len )
std::basic_string_view<CharT> sv ( s, len );
assert ( sv.length() == len );
assert ( sv.data() == s );
+#if TEST_STD_VER > 14
+// make sure we pick up std::data, too!
+ assert ( sv.data() == std::data(sv));
+#endif
}
int main () {
Modified: libcxx/trunk/test/std/strings/string.view/string.view.capacity/capacity.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.capacity/capacity.pass.cpp?rev=323719&r1=323718&r2=323719&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/string.view/string.view.capacity/capacity.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/string.view/string.view.capacity/capacity.pass.cpp Mon Jan 29 16:47:43 2018
@@ -55,6 +55,11 @@ void test2 ( const CharT *s, size_t len
assert ( sv1.empty() == (len == 0));
assert ( sv1.size() == sv1.length());
assert ( sv1.max_size() > sv1.size());
+#if TEST_STD_VER > 14
+// make sure we pick up std::size, too!
+ assert ( sv1.size() == std::size(sv1));
+ assert ( sv1.empty() == std::empty(sv1));
+#endif
}
}
More information about the cfe-commits
mailing list