@@ -719,6 +719,66 @@ TEST(SetTest, LazyZipWithStdVector)
719719 EXPECT_EQ (expected, zipped);
720720}
721721
722+ TEST (SetTest, LazySourceCanOutliveFunctionalSet)
723+ {
724+ lazy_set<int > lazy_numbers;
725+ {
726+ const set<int > numbers ({1 , 2 , 3 , 4 });
727+ lazy_numbers = numbers
728+ .lazy ()
729+ .filter ([](const int & value) {
730+ return value > 2 ;
731+ });
732+ }
733+
734+ EXPECT_EQ (set<int >({3 , 4 }), lazy_numbers.get ());
735+ }
736+
737+ TEST (SetTest, LazySourceCanStartFromTemporaryFunctionalSet)
738+ {
739+ const auto lazy_numbers = set<int >({1 , 2 , 3 , 4 })
740+ .lazy ()
741+ .map <int >([](const int & value) {
742+ return value * 2 ;
743+ });
744+
745+ EXPECT_EQ (set<int >({2 , 4 , 6 , 8 }), lazy_numbers.get ());
746+ }
747+
748+ TEST (SetTest, LazyZipWithTemporaryFunctionalSet)
749+ {
750+ const set<int > ages ({25 , 45 , 30 , 63 });
751+
752+ const auto lazy_zipped = ages
753+ .lazy ()
754+ .zip (set<std::string>({" Jake" , " Bob" , " Michael" , " Philipp" }));
755+
756+ const auto expected = set<std::pair<int , std::string>>({
757+ std::pair<int , std::string>(25 , " Bob" ),
758+ std::pair<int , std::string>(30 , " Jake" ),
759+ std::pair<int , std::string>(45 , " Michael" ),
760+ std::pair<int , std::string>(63 , " Philipp" ),
761+ });
762+ EXPECT_EQ (expected, lazy_zipped.get ());
763+ }
764+
765+ TEST (SetTest, LazyZipWithTemporaryStdSet)
766+ {
767+ const set<int > ages ({25 , 45 , 30 , 63 });
768+
769+ const auto lazy_zipped = ages
770+ .lazy ()
771+ .zip (std::set<std::string>({" Jake" , " Bob" , " Michael" , " Philipp" }));
772+
773+ const auto expected = set<std::pair<int , std::string>>({
774+ std::pair<int , std::string>(25 , " Bob" ),
775+ std::pair<int , std::string>(30 , " Jake" ),
776+ std::pair<int , std::string>(45 , " Michael" ),
777+ std::pair<int , std::string>(63 , " Philipp" ),
778+ });
779+ EXPECT_EQ (expected, lazy_zipped.get ());
780+ }
781+
722782TEST (SetTest, LazyZipWithLazyVector)
723783{
724784 const set<int > ages ({25 , 45 , 30 , 63 });
@@ -849,6 +909,17 @@ TEST(SetTest, LazyDifferenceWithLazySet)
849909 EXPECT_EQ (6 , map_call_count);
850910}
851911
912+ TEST (SetTest, LazyDifferenceWithTemporaryFunctionalSet)
913+ {
914+ const set<int > set1 ({1 , 2 , 3 , 5 , 7 , 8 , 10 });
915+
916+ const auto lazy_diff = set1
917+ .lazy ()
918+ .difference_with (set<int >({2 , 5 , 7 , 10 , 15 , 17 }));
919+
920+ EXPECT_EQ (set<int >({1 , 3 , 8 }), lazy_diff.get ());
921+ }
922+
852923TEST (SetTest, LazyUnionWithFunctionalSet)
853924{
854925 const set<int > set1 ({1 , 2 , 3 , 5 , 7 , 8 , 10 });
@@ -909,6 +980,17 @@ TEST(SetTest, LazyUnionWithLazySet)
909980 EXPECT_EQ (6 , map_call_count);
910981}
911982
983+ TEST (SetTest, LazyUnionWithTemporaryFunctionalSet)
984+ {
985+ const set<int > set1 ({1 , 2 , 3 , 5 , 7 , 8 , 10 });
986+
987+ const auto lazy_combined = set1
988+ .lazy ()
989+ .union_with (set<int >({2 , 5 , 7 , 10 , 15 , 17 }));
990+
991+ EXPECT_EQ (set<int >({1 , 2 , 3 , 5 , 7 , 8 , 10 , 15 , 17 }), lazy_combined.get ());
992+ }
993+
912994TEST (SetTest, LazyIntersectionWithFunctionalSet)
913995{
914996 const set<int > set1 ({1 , 2 , 3 , 5 , 7 , 8 , 10 });
@@ -968,3 +1050,14 @@ TEST(SetTest, LazyIntersectionWithLazySet)
9681050 EXPECT_EQ (set<int >({3 , 5 , 7 , 10 }), intersection);
9691051 EXPECT_EQ (6 , map_call_count);
9701052}
1053+
1054+ TEST (SetTest, LazyIntersectionWithTemporaryFunctionalSet)
1055+ {
1056+ const set<int > set1 ({1 , 2 , 3 , 5 , 7 , 8 , 10 });
1057+
1058+ const auto lazy_intersection = set1
1059+ .lazy ()
1060+ .intersect_with (set<int >({2 , 5 , 7 , 10 , 15 , 17 }));
1061+
1062+ EXPECT_EQ (set<int >({2 , 5 , 7 , 10 }), lazy_intersection.get ());
1063+ }
0 commit comments