| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 } | 665 } |
| 666 | 666 |
| 667 TEST(VectorTest, Optional) { | 667 TEST(VectorTest, Optional) { |
| 668 Optional<Vector<int>> vector; | 668 Optional<Vector<int>> vector; |
| 669 EXPECT_FALSE(vector); | 669 EXPECT_FALSE(vector); |
| 670 vector.emplace(3); | 670 vector.emplace(3); |
| 671 EXPECT_TRUE(vector); | 671 EXPECT_TRUE(vector); |
| 672 EXPECT_EQ(3u, vector->size()); | 672 EXPECT_EQ(3u, vector->size()); |
| 673 } | 673 } |
| 674 | 674 |
| 675 TEST(VectorTest, emplaceAppend) { | 675 TEST(VectorTest, emplace_back) { |
| 676 struct Item { | 676 struct Item { |
| 677 Item(int value1, int value2) : value1(value1), value2(value2) {} | 677 Item(int value1, int value2) : value1(value1), value2(value2) {} |
| 678 int value1; | 678 int value1; |
| 679 int value2; | 679 int value2; |
| 680 }; | 680 }; |
| 681 | 681 |
| 682 Vector<Item> vector; | 682 Vector<Item> vector; |
| 683 vector.emplaceAppend(1, 2); | 683 vector.emplace_back(1, 2); |
| 684 vector.emplaceAppend(3, 4); | 684 vector.emplace_back(3, 4); |
| 685 | 685 |
| 686 EXPECT_EQ(2u, vector.size()); | 686 EXPECT_EQ(2u, vector.size()); |
| 687 EXPECT_EQ(1, vector[0].value1); | 687 EXPECT_EQ(1, vector[0].value1); |
| 688 EXPECT_EQ(2, vector[0].value2); | 688 EXPECT_EQ(2, vector[0].value2); |
| 689 EXPECT_EQ(3, vector[1].value1); | 689 EXPECT_EQ(3, vector[1].value1); |
| 690 EXPECT_EQ(4, vector[1].value2); | 690 EXPECT_EQ(4, vector[1].value2); |
| 691 } | 691 } |
| 692 | 692 |
| 693 static_assert(VectorTraits<int>::canCopyWithMemcpy, | 693 static_assert(VectorTraits<int>::canCopyWithMemcpy, |
| 694 "int should be copied with memcopy."); | 694 "int should be copied with memcopy."); |
| 695 static_assert(VectorTraits<char>::canCopyWithMemcpy, | 695 static_assert(VectorTraits<char>::canCopyWithMemcpy, |
| 696 "char should be copied with memcpy."); | 696 "char should be copied with memcpy."); |
| 697 static_assert(VectorTraits<LChar>::canCopyWithMemcpy, | 697 static_assert(VectorTraits<LChar>::canCopyWithMemcpy, |
| 698 "LChar should be copied with memcpy."); | 698 "LChar should be copied with memcpy."); |
| 699 static_assert(VectorTraits<UChar>::canCopyWithMemcpy, | 699 static_assert(VectorTraits<UChar>::canCopyWithMemcpy, |
| 700 "UChar should be copied with memcpy."); | 700 "UChar should be copied with memcpy."); |
| 701 | 701 |
| 702 class UnknownType; | 702 class UnknownType; |
| 703 static_assert(VectorTraits<UnknownType*>::canCopyWithMemcpy, | 703 static_assert(VectorTraits<UnknownType*>::canCopyWithMemcpy, |
| 704 "Pointers should be copied with memcpy."); | 704 "Pointers should be copied with memcpy."); |
| 705 | 705 |
| 706 } // anonymous namespace | 706 } // anonymous namespace |
| 707 | 707 |
| 708 } // namespace WTF | 708 } // namespace WTF |
| OLD | NEW |