From c9a75c816c9da070f4e3336927ce0f02f0ea91eb Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 5 Oct 2016 17:04:36 +0000 Subject: [PATCH] Fix build due to comparison of std::pairs. llvm-svn: 283342 --- unittests/ADT/STLExtrasTest.cpp | 36 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/unittests/ADT/STLExtrasTest.cpp b/unittests/ADT/STLExtrasTest.cpp index e5ac1800d2f..849b6f1d097 100644 --- a/unittests/ADT/STLExtrasTest.cpp +++ b/unittests/ADT/STLExtrasTest.cpp @@ -43,26 +43,28 @@ TEST(STLExtrasTest, EnumerateLValue) { // Test that a simple LValue can be enumerated and gives correct results with // multiple types, including the empty container. std::vector foo = {'a', 'b', 'c'}; - std::vector> CharResults; + typedef std::pair CharPairType; + std::vector CharResults; for (auto X : llvm::enumerate(foo)) { CharResults.emplace_back(X.Index, X.Value); } ASSERT_EQ(3u, CharResults.size()); - EXPECT_EQ(std::make_pair(0u, 'a'), CharResults[0]); - EXPECT_EQ(std::make_pair(1u, 'b'), CharResults[1]); - EXPECT_EQ(std::make_pair(2u, 'c'), CharResults[2]); + EXPECT_EQ(CharPairType(0u, 'a'), CharResults[0]); + EXPECT_EQ(CharPairType(1u, 'b'), CharResults[1]); + EXPECT_EQ(CharPairType(2u, 'c'), CharResults[2]); // Test a const range of a different type. - std::vector> IntResults; + typedef std::pair IntPairType; + std::vector IntResults; const std::vector bar = {1, 2, 3}; for (auto X : llvm::enumerate(bar)) { IntResults.emplace_back(X.Index, X.Value); } ASSERT_EQ(3u, IntResults.size()); - EXPECT_EQ(std::make_pair(0u, 1), IntResults[0]); - EXPECT_EQ(std::make_pair(1u, 2), IntResults[1]); - EXPECT_EQ(std::make_pair(2u, 3), IntResults[2]); + EXPECT_EQ(IntPairType(0u, 1), IntResults[0]); + EXPECT_EQ(IntPairType(1u, 2), IntResults[1]); + EXPECT_EQ(IntPairType(2u, 3), IntResults[2]); // Test an empty range. IntResults.clear(); @@ -88,7 +90,8 @@ TEST(STLExtrasTest, EnumerateModifyLValue) { TEST(STLExtrasTest, EnumerateRValueRef) { // Test that an rvalue can be enumerated. - std::vector> Results; + typedef std::pair PairType; + std::vector Results; auto Enumerator = llvm::enumerate(std::vector{1, 2, 3}); @@ -97,16 +100,17 @@ TEST(STLExtrasTest, EnumerateRValueRef) { } ASSERT_EQ(3u, Results.size()); - EXPECT_EQ(std::make_pair(0u, 1), Results[0]); - EXPECT_EQ(std::make_pair(1u, 2), Results[1]); - EXPECT_EQ(std::make_pair(2u, 3), Results[2]); + EXPECT_EQ(PairType(0u, 1), Results[0]); + EXPECT_EQ(PairType(1u, 2), Results[1]); + EXPECT_EQ(PairType(2u, 3), Results[2]); } TEST(STLExtrasTest, EnumerateModifyRValue) { // Test that when enumerating an rvalue, modification still works (even if // this isn't terribly useful, it at least shows that we haven't snuck an // extra const in there somewhere. - std::vector> Results; + typedef std::pair PairType; + std::vector Results; for (auto X : llvm::enumerate(std::vector{'1', '2', '3'})) { ++X.Value; @@ -114,9 +118,9 @@ TEST(STLExtrasTest, EnumerateModifyRValue) { } ASSERT_EQ(3u, Results.size()); - EXPECT_EQ(std::make_pair(0u, '2'), Results[0]); - EXPECT_EQ(std::make_pair(1u, '3'), Results[1]); - EXPECT_EQ(std::make_pair(2u, '4'), Results[2]); + EXPECT_EQ(PairType(0u, '2'), Results[0]); + EXPECT_EQ(PairType(1u, '3'), Results[1]); + EXPECT_EQ(PairType(2u, '4'), Results[2]); } template struct CanMove {};