| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 691 |
| 692 TEST(VectorTest, Optional) | 692 TEST(VectorTest, Optional) |
| 693 { | 693 { |
| 694 Optional<Vector<int>> vector; | 694 Optional<Vector<int>> vector; |
| 695 EXPECT_FALSE(vector); | 695 EXPECT_FALSE(vector); |
| 696 vector.emplace(3); | 696 vector.emplace(3); |
| 697 EXPECT_TRUE(vector); | 697 EXPECT_TRUE(vector); |
| 698 EXPECT_EQ(3u, vector->size()); | 698 EXPECT_EQ(3u, vector->size()); |
| 699 } | 699 } |
| 700 | 700 |
| 701 TEST(VectorTest, emplaceAppend) |
| 702 { |
| 703 struct Item { |
| 704 Item(int value1, int value2) : value1(value1), value2(value2) {} |
| 705 int value1; |
| 706 int value2; |
| 707 }; |
| 708 |
| 709 Vector<Item> vector; |
| 710 vector.emplaceAppend(1, 2); |
| 711 vector.emplaceAppend(3, 4); |
| 712 |
| 713 EXPECT_EQ(2u, vector.size()); |
| 714 EXPECT_EQ(1, vector[0].value1); |
| 715 EXPECT_EQ(2, vector[0].value2); |
| 716 EXPECT_EQ(3, vector[1].value1); |
| 717 EXPECT_EQ(4, vector[1].value2); |
| 718 } |
| 719 |
| 701 static_assert(VectorTraits<int>::canCopyWithMemcpy, "int should be copied with m
emcopy."); | 720 static_assert(VectorTraits<int>::canCopyWithMemcpy, "int should be copied with m
emcopy."); |
| 702 static_assert(VectorTraits<char>::canCopyWithMemcpy, "char should be copied with
memcpy."); | 721 static_assert(VectorTraits<char>::canCopyWithMemcpy, "char should be copied with
memcpy."); |
| 703 static_assert(VectorTraits<LChar>::canCopyWithMemcpy, "LChar should be copied wi
th memcpy."); | 722 static_assert(VectorTraits<LChar>::canCopyWithMemcpy, "LChar should be copied wi
th memcpy."); |
| 704 static_assert(VectorTraits<UChar>::canCopyWithMemcpy, "UChar should be copied wi
th memcpy."); | 723 static_assert(VectorTraits<UChar>::canCopyWithMemcpy, "UChar should be copied wi
th memcpy."); |
| 705 | 724 |
| 706 class UnknownType; | 725 class UnknownType; |
| 707 static_assert(VectorTraits<UnknownType*>::canCopyWithMemcpy, "Pointers should be
copied with memcpy."); | 726 static_assert(VectorTraits<UnknownType*>::canCopyWithMemcpy, "Pointers should be
copied with memcpy."); |
| 708 | 727 |
| 709 } // anonymous namespace | 728 } // anonymous namespace |
| 710 | 729 |
| 711 } // namespace WTF | 730 } // namespace WTF |
| OLD | NEW |