| 426 | |
| 427 | template <size_t N> |
| 428 | void CheckCopy(bool expect_overflow) { |
| 429 | IntVectorType<N> ints = MakeVector<N>({4, 5, 6, 7, 8}); |
| 430 | |
| 431 | IntVectorType<N> copied_ints(ints); |
| 432 | ASSERT_EQ(copied_ints.size(), 5); |
| 433 | ASSERT_EQ(ints.size(), 5); |
| 434 | EXPECT_THAT(copied_ints, ElementsAre(4, 5, 6, 7, 8)); |
| 435 | EXPECT_THAT(ints, ElementsAre(4, 5, 6, 7, 8)); |
| 436 | ASSERT_EQ(UsesStaticStorage(copied_ints), !expect_overflow); |
| 437 | |
| 438 | IntVectorType<N> copied_copied_ints = copied_ints; |
| 439 | ASSERT_EQ(copied_copied_ints.size(), 5); |
| 440 | ASSERT_EQ(copied_ints.size(), 5); |
| 441 | EXPECT_THAT(copied_copied_ints, ElementsAre(4, 5, 6, 7, 8)); |
| 442 | EXPECT_THAT(copied_ints, ElementsAre(4, 5, 6, 7, 8)); |
| 443 | |
| 444 | auto copy_into = [](const IntVectorType<N>& src, IntVectorType<N>* dest) { |
| 445 | *dest = src; |
| 446 | }; |
| 447 | |
| 448 | // Copy into itself |
| 449 | // (avoiding the trivial form `copied_copied_ints = copied_copied_ints` |
| 450 | // that would produce a clang warning) |
| 451 | copy_into(copied_copied_ints, &copied_copied_ints); |
| 452 | ASSERT_EQ(copied_copied_ints.size(), 5); |
| 453 | EXPECT_THAT(copied_copied_ints, ElementsAre(4, 5, 6, 7, 8)); |
| 454 | } |
| 455 | |
| 456 | template <bool IsMoveOnly = Param::IsMoveOnly()> |
| 457 | void TestCopy(enable_if_t<!IsMoveOnly>* = 0) { |
nothing calls this directly
no test coverage detected