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 10 matching lines...) Expand all Loading... |
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 | 27 |
28 #include "wtf/HashSet.h" | 28 #include "wtf/HashSet.h" |
29 #include "wtf/OwnPtr.h" | 29 #include "wtf/OwnPtr.h" |
30 #include "wtf/PassOwnPtr.h" | 30 #include "wtf/PassOwnPtr.h" |
| 31 #include "wtf/text/WTFString.h" |
31 #include "wtf/Vector.h" | 32 #include "wtf/Vector.h" |
32 #include <gtest/gtest.h> | 33 #include <gtest/gtest.h> |
33 | 34 |
34 namespace { | 35 namespace { |
35 | 36 |
36 TEST(VectorTest, Basic) | 37 TEST(VectorTest, Basic) |
37 { | 38 { |
38 Vector<int> intVector; | 39 Vector<int> intVector; |
39 EXPECT_TRUE(intVector.isEmpty()); | 40 EXPECT_TRUE(intVector.isEmpty()); |
40 EXPECT_EQ(0ul, intVector.size()); | 41 EXPECT_EQ(0ul, intVector.size()); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 EXPECT_EQ(1u, vectorA.size()); | 277 EXPECT_EQ(1u, vectorA.size()); |
277 EXPECT_EQ(1, vectorA.at(0).get()); | 278 EXPECT_EQ(1, vectorA.at(0).get()); |
278 EXPECT_EQ(3u, vectorB.size()); | 279 EXPECT_EQ(3u, vectorB.size()); |
279 EXPECT_EQ(2, vectorB.at(0).get()); | 280 EXPECT_EQ(2, vectorB.at(0).get()); |
280 EXPECT_EQ(3, vectorB.at(1).get()); | 281 EXPECT_EQ(3, vectorB.at(1).get()); |
281 EXPECT_EQ(4, vectorB.at(2).get()); | 282 EXPECT_EQ(4, vectorB.at(2).get()); |
282 | 283 |
283 vectorB.swap(vectorA); | 284 vectorB.swap(vectorA); |
284 } | 285 } |
285 | 286 |
| 287 class Comparable { |
| 288 }; |
| 289 bool operator==(const Comparable& a, const Comparable& b) { return true; } |
| 290 |
| 291 template<typename T> void compare() |
| 292 { |
| 293 EXPECT_TRUE(Vector<T>() == Vector<T>()); |
| 294 EXPECT_FALSE(Vector<T>(1) == Vector<T>(0)); |
| 295 EXPECT_FALSE(Vector<T>() == Vector<T>(1)); |
| 296 EXPECT_TRUE(Vector<T>(1) == Vector<T>(1)); |
| 297 } |
| 298 |
| 299 TEST(VectorTest, Compare) |
| 300 { |
| 301 compare<int>(); |
| 302 compare<Comparable>(); |
| 303 compare<WTF::String>(); |
| 304 } |
286 } // namespace | 305 } // namespace |
OLD | NEW |