Skip to content

Commit 4b01850

Browse files
committed
Add test case
1 parent ed72061 commit 4b01850

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

llvm/unittests/ADT/STLExtrasTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,11 @@ TEST(STLExtrasTest, SumOf) {
16781678
static_assert(std::is_same_v<decltype(sum_of(V2), 1.0), double>);
16791679
EXPECT_EQ(sum_of(V2), 7.0f);
16801680
EXPECT_EQ(sum_of(V2, 1.0f), 8.0f);
1681+
1682+
// Make sure that for a const argument the return value is non-const.
1683+
const std::vector<float> V3 = {1.0f, 2.0f};
1684+
static_assert(std::is_same_v<decltype(sum_of(V3)), float>);
1685+
EXPECT_EQ(sum_of(V3), 3.0f);
16811686
}
16821687

16831688
TEST(STLExtrasTest, ProductOf) {
@@ -1697,6 +1702,11 @@ TEST(STLExtrasTest, ProductOf) {
16971702
static_assert(std::is_same_v<decltype(product_of(V2), 1.0), double>);
16981703
EXPECT_EQ(product_of(V2), 8.0f);
16991704
EXPECT_EQ(product_of(V2, 4.0f), 32.0f);
1705+
1706+
// Make sure that for a const argument the return value is non-const.
1707+
const std::vector<float> V3 = {1.0f, 2.0f};
1708+
static_assert(std::is_same_v<decltype(product_of(V3)), float>);
1709+
EXPECT_EQ(product_of(V3), 2.0f);
17001710
}
17011711

17021712
struct Foo;

0 commit comments

Comments
 (0)