llvm.org GIT mirror llvm / 1acf70e
[ADT] Update SmallVectorTest.EmplaceBack tests after rL356312 rL356312 changed the return type of emplace_back from void to reference. Update the tests to check the behavior. Reviewers: dblaikie Reviewed By: dblaikie Subscribers: dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59809 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356980 91177308-0d34-0410-b5e6-96231b3b80d8 Fangrui Song 4 months ago
1 changed file(s) with 42 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
907907 EmplaceableArg<3> A3(true);
908908 {
909909 SmallVector V;
910 V.emplace_back();
910 Emplaceable &back = V.emplace_back();
911 EXPECT_TRUE(&back == &V.back());
911912 EXPECT_TRUE(V.size() == 1);
912 EXPECT_TRUE(V.back().State == ES_Emplaced);
913 EXPECT_TRUE(V.back().A0.State == EAS_Defaulted);
914 EXPECT_TRUE(V.back().A1.State == EAS_Defaulted);
915 EXPECT_TRUE(V.back().A2.State == EAS_Defaulted);
916 EXPECT_TRUE(V.back().A3.State == EAS_Defaulted);
913 EXPECT_TRUE(back.State == ES_Emplaced);
914 EXPECT_TRUE(back.A0.State == EAS_Defaulted);
915 EXPECT_TRUE(back.A1.State == EAS_Defaulted);
916 EXPECT_TRUE(back.A2.State == EAS_Defaulted);
917 EXPECT_TRUE(back.A3.State == EAS_Defaulted);
917918 }
918919 {
919920 SmallVector V;
920 V.emplace_back(std::move(A0));
921 Emplaceable &back = V.emplace_back(std::move(A0));
922 EXPECT_TRUE(&back == &V.back());
921923 EXPECT_TRUE(V.size() == 1);
922 EXPECT_TRUE(V.back().State == ES_Emplaced);
923 EXPECT_TRUE(V.back().A0.State == EAS_RValue);
924 EXPECT_TRUE(V.back().A1.State == EAS_Defaulted);
925 EXPECT_TRUE(V.back().A2.State == EAS_Defaulted);
926 EXPECT_TRUE(V.back().A3.State == EAS_Defaulted);
924 EXPECT_TRUE(back.State == ES_Emplaced);
925 EXPECT_TRUE(back.A0.State == EAS_RValue);
926 EXPECT_TRUE(back.A1.State == EAS_Defaulted);
927 EXPECT_TRUE(back.A2.State == EAS_Defaulted);
928 EXPECT_TRUE(back.A3.State == EAS_Defaulted);
927929 }
928930 {
929931 SmallVector V;
930 V.emplace_back(A0);
932 Emplaceable &back = V.emplace_back(A0);
933 EXPECT_TRUE(&back == &V.back());
931934 EXPECT_TRUE(V.size() == 1);
932 EXPECT_TRUE(V.back().State == ES_Emplaced);
933 EXPECT_TRUE(V.back().A0.State == EAS_LValue);
934 EXPECT_TRUE(V.back().A1.State == EAS_Defaulted);
935 EXPECT_TRUE(V.back().A2.State == EAS_Defaulted);
936 EXPECT_TRUE(V.back().A3.State == EAS_Defaulted);
935 EXPECT_TRUE(back.State == ES_Emplaced);
936 EXPECT_TRUE(back.A0.State == EAS_LValue);
937 EXPECT_TRUE(back.A1.State == EAS_Defaulted);
938 EXPECT_TRUE(back.A2.State == EAS_Defaulted);
939 EXPECT_TRUE(back.A3.State == EAS_Defaulted);
937940 }
938941 {
939942 SmallVector V;
940 V.emplace_back(A0, A1);
943 Emplaceable &back = V.emplace_back(A0, A1);
944 EXPECT_TRUE(&back == &V.back());
941945 EXPECT_TRUE(V.size() == 1);
942 EXPECT_TRUE(V.back().State == ES_Emplaced);
943 EXPECT_TRUE(V.back().A0.State == EAS_LValue);
944 EXPECT_TRUE(V.back().A1.State == EAS_LValue);
945 EXPECT_TRUE(V.back().A2.State == EAS_Defaulted);
946 EXPECT_TRUE(V.back().A3.State == EAS_Defaulted);
946 EXPECT_TRUE(back.State == ES_Emplaced);
947 EXPECT_TRUE(back.A0.State == EAS_LValue);
948 EXPECT_TRUE(back.A1.State == EAS_LValue);
949 EXPECT_TRUE(back.A2.State == EAS_Defaulted);
950 EXPECT_TRUE(back.A3.State == EAS_Defaulted);
947951 }
948952 {
949953 SmallVector V;
950 V.emplace_back(std::move(A0), std::move(A1));
954 Emplaceable &back = V.emplace_back(std::move(A0), std::move(A1));
955 EXPECT_TRUE(&back == &V.back());
951956 EXPECT_TRUE(V.size() == 1);
952 EXPECT_TRUE(V.back().State == ES_Emplaced);
953 EXPECT_TRUE(V.back().A0.State == EAS_RValue);
954 EXPECT_TRUE(V.back().A1.State == EAS_RValue);
955 EXPECT_TRUE(V.back().A2.State == EAS_Defaulted);
956 EXPECT_TRUE(V.back().A3.State == EAS_Defaulted);
957 EXPECT_TRUE(back.State == ES_Emplaced);
958 EXPECT_TRUE(back.A0.State == EAS_RValue);
959 EXPECT_TRUE(back.A1.State == EAS_RValue);
960 EXPECT_TRUE(back.A2.State == EAS_Defaulted);
961 EXPECT_TRUE(back.A3.State == EAS_Defaulted);
957962 }
958963 {
959964 SmallVector V;
960 V.emplace_back(std::move(A0), A1, std::move(A2), A3);
965 Emplaceable &back = V.emplace_back(std::move(A0), A1, std::move(A2), A3);
966 EXPECT_TRUE(&back == &V.back());
961967 EXPECT_TRUE(V.size() == 1);
962 EXPECT_TRUE(V.back().State == ES_Emplaced);
963 EXPECT_TRUE(V.back().A0.State == EAS_RValue);
964 EXPECT_TRUE(V.back().A1.State == EAS_LValue);
965 EXPECT_TRUE(V.back().A2.State == EAS_RValue);
966 EXPECT_TRUE(V.back().A3.State == EAS_LValue);
968 EXPECT_TRUE(back.State == ES_Emplaced);
969 EXPECT_TRUE(back.A0.State == EAS_RValue);
970 EXPECT_TRUE(back.A1.State == EAS_LValue);
971 EXPECT_TRUE(back.A2.State == EAS_RValue);
972 EXPECT_TRUE(back.A3.State == EAS_LValue);
967973 }
968974 {
969975 SmallVector V;