| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 362 } |
| 363 EXPECT_EQ( | 363 EXPECT_EQ( |
| 364 V("0:17. explicit constructor", "1:17. move constructor (from 0:17)", | 364 V("0:17. explicit constructor", "1:17. move constructor (from 0:17)", |
| 365 "0:17. destructor", "2:42. explicit constructor", "---", | 365 "0:17. destructor", "2:42. explicit constructor", "---", |
| 366 "3:42. move constructor (from 2:42)", | 366 "3:42. move constructor (from 2:42)", |
| 367 "1:42. operator= move (from 3:42)", "3:42. destructor", "---", | 367 "1:42. operator= move (from 3:42)", "3:42. destructor", "---", |
| 368 "2:42. destructor", "1:42. destructor"), | 368 "2:42. destructor", "1:42. destructor"), |
| 369 *log); | 369 *log); |
| 370 } | 370 } |
| 371 | 371 |
| 372 TEST(OptionalTest, TestResetEmpty) { |
| 373 auto log = Logger::Setup(); |
| 374 { |
| 375 Optional<Logger> x; |
| 376 x.reset(); |
| 377 } |
| 378 EXPECT_EQ(V(), *log); |
| 379 } |
| 380 |
| 381 TEST(OptionalTest, TestResetFull) { |
| 382 auto log = Logger::Setup(); |
| 383 { |
| 384 Optional<Logger> x(Logger(17)); |
| 385 log->push_back("---"); |
| 386 x.reset(); |
| 387 log->push_back("---"); |
| 388 } |
| 389 EXPECT_EQ( |
| 390 V("0:17. explicit constructor", "1:17. move constructor (from 0:17)", |
| 391 "0:17. destructor", "---", "1:17. destructor", "---"), |
| 392 *log); |
| 393 } |
| 394 |
| 372 TEST(OptionalTest, TestDereference) { | 395 TEST(OptionalTest, TestDereference) { |
| 373 auto log = Logger::Setup(); | 396 auto log = Logger::Setup(); |
| 374 { | 397 { |
| 375 Optional<Logger> x(Logger(42)); | 398 Optional<Logger> x(Logger(42)); |
| 376 const auto& y = x; | 399 const auto& y = x; |
| 377 log->push_back("---"); | 400 log->push_back("---"); |
| 378 x->Foo(); | 401 x->Foo(); |
| 379 y->Foo(); | 402 y->Foo(); |
| 380 std::move(x)->Foo(); | 403 std::move(x)->Foo(); |
| 381 std::move(y)->Foo(); | 404 std::move(y)->Foo(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 "2:17. copy constructor (from 0:17)", | 486 "2:17. copy constructor (from 0:17)", |
| 464 "3:42. copy constructor (from 1:42)", | 487 "3:42. copy constructor (from 1:42)", |
| 465 "4:17. copy constructor (from 0:17)", "---", "swap 2:42, 3:17", | 488 "4:17. copy constructor (from 0:17)", "---", "swap 2:42, 3:17", |
| 466 "5:17. move constructor (from 4:17)", "4:17. destructor", "---", | 489 "5:17. move constructor (from 4:17)", "4:17. destructor", "---", |
| 467 "5:17. destructor", "3:17. destructor", "2:42. destructor", | 490 "5:17. destructor", "3:17. destructor", "2:42. destructor", |
| 468 "1:42. destructor", "0:17. destructor"), | 491 "1:42. destructor", "0:17. destructor"), |
| 469 *log); | 492 *log); |
| 470 } | 493 } |
| 471 | 494 |
| 472 } // namespace rtc | 495 } // namespace rtc |
| OLD | NEW |