Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/Source/wtf/FunctionalTest.cpp

Issue 2494333002: Replace wrapUnique(new T(args)) by makeUnique<T>(args) in Blink (Closed)
Patch Set: Drop redundant WTF:: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 std::unique_ptr<Function<int(class A*, int)>> unboundFunction2 = 311 std::unique_ptr<Function<int(class A*, int)>> unboundFunction2 =
312 bind(&A::addF); 312 bind(&A::addF);
313 EXPECT_EQ(25, (*unboundFunction2)(&a, 15)); 313 EXPECT_EQ(25, (*unboundFunction2)(&a, 15));
314 std::unique_ptr<Function<int(int)>> objectBoundFunction2 = 314 std::unique_ptr<Function<int(int)>> objectBoundFunction2 =
315 bind(&A::addF, unretained(&a)); 315 bind(&A::addF, unretained(&a));
316 EXPECT_EQ(25, (*objectBoundFunction2)(15)); 316 EXPECT_EQ(25, (*objectBoundFunction2)(15));
317 } 317 }
318 318
319 TEST(FunctionalTest, MemberFunctionBindByUniquePtr) { 319 TEST(FunctionalTest, MemberFunctionBindByUniquePtr) {
320 std::unique_ptr<Function<int()>> function1 = 320 std::unique_ptr<Function<int()>> function1 =
321 WTF::bind(&A::f, wrapUnique(new A(10))); 321 WTF::bind(&A::f, makeUnique<A>(10));
322 EXPECT_EQ(10, (*function1)()); 322 EXPECT_EQ(10, (*function1)());
323 } 323 }
324 324
325 TEST(FunctionalTest, MemberFunctionBindByPassedUniquePtr) { 325 TEST(FunctionalTest, MemberFunctionBindByPassedUniquePtr) {
326 std::unique_ptr<Function<int()>> function1 = 326 std::unique_ptr<Function<int()>> function1 =
327 WTF::bind(&A::f, passed(wrapUnique(new A(10)))); 327 WTF::bind(&A::f, passed(makeUnique<A>(10)));
328 EXPECT_EQ(10, (*function1)()); 328 EXPECT_EQ(10, (*function1)());
329 } 329 }
330 330
331 class Number : public RefCounted<Number> { 331 class Number : public RefCounted<Number> {
332 public: 332 public:
333 static PassRefPtr<Number> create(int value) { 333 static PassRefPtr<Number> create(int value) {
334 return adoptRef(new Number(value)); 334 return adoptRef(new Number(value));
335 } 335 }
336 336
337 ~Number() { m_value = 0; } 337 ~Number() { m_value = 0; }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 584
585 obj.revokeAll(); 585 obj.revokeAll();
586 EXPECT_TRUE(bound->isCancelled()); 586 EXPECT_TRUE(bound->isCancelled());
587 (*bound)(); 587 (*bound)();
588 EXPECT_EQ(1, counter); 588 EXPECT_EQ(1, counter);
589 } 589 }
590 590
591 } // anonymous namespace 591 } // anonymous namespace
592 592
593 } // namespace WTF 593 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/FilePrintStream.cpp ('k') | third_party/WebKit/Source/wtf/HashMapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698