[libcxx-commits] [PATCH] D119329: [libc++] Prepare string.modifiers tests for constexpr

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Feb 9 08:58:05 PST 2022


Quuxplusone added inline comments.


================
Comment at: libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp:1833
+template <class S, class SV>
+void test() {
+  test0<S, SV>();
----------------
philnik wrote:
> ldionne wrote:
> > Instead, can you do
> > 
> > ```
> > template <class S, class V>
> > _LIBCPP_CONSTEXPR_AFTER_CXX17 void tests() {
> >   test0<S, SV>();
> >   // ...
> >   test31<S, SV>();
> > }
> > 
> > bool check_all() {
> >   tests<std::string, std::string_view>();
> > #if TEST_STD_VER >= 11
> >   tests<std::basic_string<char, std::char_traits<char>, min_allocator<char>>,
> >         std::basic_string_view<char, std::char_traits<char>>>();
> > #endif
> >   return true;
> > }
> > 
> > int main() {
> >   check_all();
> > #if TEST_STD_VER > 17
> >   static_assert(check_all());
> > #endif
> > }
> > ```
> > 
> > You can also tweak `test31` to be templated like the other ones, I think you only need to use the `SV()` macro and friends in it.
> I can't, because you can "only" do about 1 million steps during constant evaluation. If everything is in a single `static_assert()` that limit is reached. I can of course make test 31 a template.
FWIW, a quick skim did not enlighten me as to why we need exactly these 32 opaquely numbered test cases here. What's the purpose of each of these tests? Can we get the "length" of this test down below a million simply by improving it?
I see we might want to test every possible cell in the matrix (short,long) x (0,1,3,n-1,n,n+1) x (short,long) x (0,1,3,n-1,n,n+1) x (0,1,2,3,4,n-1,n,n+1) but even that's only 1152 different test cases, and we've got 1843 //lines// in the left-hand file here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119329/new/

https://reviews.llvm.org/D119329



More information about the libcxx-commits mailing list