@@ -464,6 +464,76 @@ constexpr void test_sequence_insert_range(Validate validate) {
464464 }
465465}
466466
467+ // https://llvm.org/PR159943
468+ template <class Container , class Iter , class Sent , class Validate >
469+ constexpr void test_sequence_insert_range_decay (Validate validate) {
470+ using T = Container::value_type;
471+ using D = Container::difference_type;
472+ auto get_pos = [](auto & c, auto & test_case) { return std::ranges::next (c.begin (), static_cast <D>(test_case.index )); };
473+
474+ auto test = [&](auto & test_case) {
475+ Container c (test_case.initial .begin (), test_case.initial .end ());
476+ auto in = wrap_input_decay<Iter, Sent>(test_case.input );
477+ auto pos = get_pos (c, test_case);
478+
479+ auto result = c.insert_range (pos, in);
480+ assert (result == get_pos (c, test_case));
481+ validate (c);
482+ return std::ranges::equal (c, test_case.expected );
483+ };
484+
485+ { // Empty container.
486+ // empty_c.insert_range(end, empty_range)
487+ assert (test (EmptyContainer_EmptyRange<T>));
488+ // empty_c.insert_range(end, one_element_range)
489+ assert (test (EmptyContainer_OneElementRange<T>));
490+ // empty_c.insert_range(end, mid_range)
491+ assert (test (EmptyContainer_MidRange<T>));
492+ }
493+
494+ { // One-element container.
495+ // one_element_c.insert_range(begin, empty_range)
496+ assert (test (OneElementContainer_Begin_EmptyRange<T>));
497+ // one_element_c.insert_range(end, empty_range)
498+ assert (test (OneElementContainer_End_EmptyRange<T>));
499+ // one_element_c.insert_range(begin, one_element_range)
500+ assert (test (OneElementContainer_Begin_OneElementRange<T>));
501+ // one_element_c.insert_range(end, one_element_range)
502+ assert (test (OneElementContainer_End_OneElementRange<T>));
503+ // one_element_c.insert_range(begin, mid_range)
504+ assert (test (OneElementContainer_Begin_MidRange<T>));
505+ // one_element_c.insert_range(end, mid_range)
506+ assert (test (OneElementContainer_End_MidRange<T>));
507+ }
508+
509+ { // Full container.
510+ // full_container.insert_range(begin, empty_range)
511+ assert (test (FullContainer_Begin_EmptyRange<T>));
512+ // full_container.insert_range(mid, empty_range)
513+ assert (test (FullContainer_Mid_EmptyRange<T>));
514+ // full_container.insert_range(end, empty_range)
515+ assert (test (FullContainer_End_EmptyRange<T>));
516+ // full_container.insert_range(begin, one_element_range)
517+ assert (test (FullContainer_Begin_OneElementRange<T>));
518+ // full_container.insert_range(end, one_element_range)
519+ assert (test (FullContainer_Mid_OneElementRange<T>));
520+ // full_container.insert_range(end, one_element_range)
521+ assert (test (FullContainer_End_OneElementRange<T>));
522+ // full_container.insert_range(begin, mid_range)
523+ assert (test (FullContainer_Begin_MidRange<T>));
524+ // full_container.insert_range(mid, mid_range)
525+ assert (test (FullContainer_Mid_MidRange<T>));
526+ // full_container.insert_range(end, mid_range)
527+ assert (test (FullContainer_End_MidRange<T>));
528+ // full_container.insert_range(begin, long_range)
529+ assert (test (FullContainer_Begin_LongRange<T>));
530+ // full_container.insert_range(mid, long_range)
531+ assert (test (FullContainer_Mid_LongRange<T>));
532+ // full_container.insert_range(end, long_range)
533+ assert (test (FullContainer_End_LongRange<T>));
534+ }
535+ }
536+
467537template <class Container , class Iter , class Sent , class Validate >
468538constexpr void test_sequence_prepend_range (Validate validate) {
469539 using T = typename Container::value_type;
@@ -507,6 +577,50 @@ constexpr void test_sequence_prepend_range(Validate validate) {
507577 }
508578}
509579
580+ // https://llvm.org/PR159943
581+ template <class Container , class Iter , class Sent , class Validate >
582+ constexpr void test_sequence_prepend_range_decay (Validate validate) {
583+ using T = Container::value_type;
584+
585+ auto test = [&](auto & test_case) {
586+ Container c (test_case.initial .begin (), test_case.initial .end ());
587+ auto in = wrap_input_decay<Iter, Sent>(test_case.input );
588+
589+ c.prepend_range (in);
590+ validate (c);
591+ return std::ranges::equal (c, test_case.expected );
592+ };
593+
594+ { // Empty container.
595+ // empty_c.prepend_range(empty_range)
596+ assert (test (EmptyContainer_EmptyRange<T>));
597+ // empty_c.prepend_range(one_element_range)
598+ assert (test (EmptyContainer_OneElementRange<T>));
599+ // empty_c.prepend_range(mid_range)
600+ assert (test (EmptyContainer_MidRange<T>));
601+ }
602+
603+ { // One-element container.
604+ // one_element_c.prepend_range(empty_range)
605+ assert (test (OneElementContainer_Begin_EmptyRange<T>));
606+ // one_element_c.prepend_range(one_element_range)
607+ assert (test (OneElementContainer_Begin_OneElementRange<T>));
608+ // one_element_c.prepend_range(mid_range)
609+ assert (test (OneElementContainer_Begin_MidRange<T>));
610+ }
611+
612+ { // Full container.
613+ // full_container.prepend_range(empty_range)
614+ assert (test (FullContainer_Begin_EmptyRange<T>));
615+ // full_container.prepend_range(one_element_range)
616+ assert (test (FullContainer_Begin_OneElementRange<T>));
617+ // full_container.prepend_range(mid_range)
618+ assert (test (FullContainer_Begin_MidRange<T>));
619+ // full_container.prepend_range(long_range)
620+ assert (test (FullContainer_Begin_LongRange<T>));
621+ }
622+ }
623+
510624template <class Container , class Iter , class Sent , class Validate >
511625constexpr void test_sequence_append_range (Validate validate) {
512626 using T = typename Container::value_type;
@@ -550,6 +664,50 @@ constexpr void test_sequence_append_range(Validate validate) {
550664 }
551665}
552666
667+ // https://llvm.org/PR159943
668+ template <class Container , class Iter , class Sent , class Validate >
669+ constexpr void test_sequence_append_range_decay (Validate validate) {
670+ using T = Container::value_type;
671+
672+ auto test = [&](auto & test_case) {
673+ Container c (test_case.initial .begin (), test_case.initial .end ());
674+ auto in = wrap_input_decay<Iter, Sent>(test_case.input );
675+
676+ c.append_range (in);
677+ validate (c);
678+ return std::ranges::equal (c, test_case.expected );
679+ };
680+
681+ { // Empty container.
682+ // empty_c.append_range(empty_range)
683+ assert (test (EmptyContainer_EmptyRange<T>));
684+ // empty_c.append_range(one_element_range)
685+ assert (test (EmptyContainer_OneElementRange<T>));
686+ // empty_c.append_range(mid_range)
687+ assert (test (EmptyContainer_MidRange<T>));
688+ }
689+
690+ { // One-element container.
691+ // one_element_c.append_range(empty_range)
692+ assert (test (OneElementContainer_End_EmptyRange<T>));
693+ // one_element_c.append_range(one_element_range)
694+ assert (test (OneElementContainer_End_OneElementRange<T>));
695+ // one_element_c.append_range(mid_range)
696+ assert (test (OneElementContainer_End_MidRange<T>));
697+ }
698+
699+ { // Full container.
700+ // full_container.append_range(empty_range)
701+ assert (test (FullContainer_End_EmptyRange<T>));
702+ // full_container.append_range(one_element_range)
703+ assert (test (FullContainer_End_OneElementRange<T>));
704+ // full_container.append_range(mid_range)
705+ assert (test (FullContainer_End_MidRange<T>));
706+ // full_container.append_range(long_range)
707+ assert (test (FullContainer_End_LongRange<T>));
708+ }
709+ }
710+
553711template <class Container , class Iter , class Sent , class Validate >
554712constexpr void test_sequence_assign_range (Validate validate) {
555713 using T = typename Container::value_type;
@@ -605,6 +763,62 @@ constexpr void test_sequence_assign_range(Validate validate) {
605763 }
606764}
607765
766+ // https://llvm.org/PR159943
767+ template <class Container , class Iter , class Sent , class Validate >
768+ constexpr void test_sequence_assign_range_decay (Validate validate) {
769+ using T = Container::value_type;
770+
771+ auto & initial_empty = EmptyContainer_EmptyRange<T>.initial ;
772+ auto & initial_one_element = OneElementContainer_Begin_EmptyRange<T>.initial ;
773+ auto & initial_full = FullContainer_Begin_EmptyRange<T>.initial ;
774+ auto & input_empty = FullContainer_Begin_EmptyRange<T>.input ;
775+ auto & input_one_element = FullContainer_Begin_OneElementRange<T>.input ;
776+ auto & input_mid_range = FullContainer_Begin_MidRange<T>.input ;
777+ auto & input_long_range = FullContainer_Begin_LongRange<T>.input ;
778+
779+ auto test = [&](auto & initial, auto & input) {
780+ Container c (initial.begin (), initial.end ());
781+ auto in = wrap_input_decay<Iter, Sent>(input);
782+
783+ c.assign_range (in);
784+ validate (c);
785+ return std::ranges::equal (c, input);
786+ };
787+
788+ { // Empty container.
789+ // empty_container.assign_range(empty_range)
790+ assert (test (initial_empty, input_empty));
791+ // empty_container.assign_range(one_element_range)
792+ assert (test (initial_empty, input_one_element));
793+ // empty_container.assign_range(mid_range)
794+ assert (test (initial_empty, input_mid_range));
795+ // empty_container.assign_range(long_range)
796+ assert (test (initial_empty, input_long_range));
797+ }
798+
799+ { // One-element container.
800+ // one_element_container.assign_range(empty_range)
801+ assert (test (initial_one_element, input_empty));
802+ // one_element_container.assign_range(one_element_range)
803+ assert (test (initial_one_element, input_one_element));
804+ // one_element_container.assign_range(mid_range)
805+ assert (test (initial_one_element, input_mid_range));
806+ // one_element_container.assign_range(long_range)
807+ assert (test (initial_one_element, input_long_range));
808+ }
809+
810+ { // Full container.
811+ // full_container.assign_range(empty_range)
812+ assert (test (initial_full, input_empty));
813+ // full_container.assign_range(one_element_range)
814+ assert (test (initial_full, input_one_element));
815+ // full_container.assign_range(mid_range)
816+ assert (test (initial_full, input_mid_range));
817+ // full_container.assign_range(long_range)
818+ assert (test (initial_full, input_long_range));
819+ }
820+ }
821+
608822// Move-only types.
609823
610824template <template <class ...> class Container >
0 commit comments