| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/optional.h" | 5 #include "base/optional.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 void swap(TestObject& lhs, TestObject& rhs) { | 82 void swap(TestObject& lhs, TestObject& rhs) { |
| 83 lhs.Swap(&rhs); | 83 lhs.Swap(&rhs); |
| 84 } | 84 } |
| 85 | 85 |
| 86 class NonTriviallyDestructible { | 86 class NonTriviallyDestructible { |
| 87 ~NonTriviallyDestructible() {} | 87 ~NonTriviallyDestructible() {} |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 } // anonymous namespace | 90 } // anonymous namespace |
| 91 | 91 |
| 92 static_assert(is_trivially_destructible<Optional<int>>::value, | 92 static_assert(std::is_trivially_destructible<Optional<int>>::value, |
| 93 "OptionalIsTriviallyDestructible"); | 93 "OptionalIsTriviallyDestructible"); |
| 94 | 94 |
| 95 static_assert( | 95 static_assert( |
| 96 !is_trivially_destructible<Optional<NonTriviallyDestructible>>::value, | 96 !std::is_trivially_destructible<Optional<NonTriviallyDestructible>>::value, |
| 97 "OptionalIsTriviallyDestructible"); | 97 "OptionalIsTriviallyDestructible"); |
| 98 | 98 |
| 99 TEST(OptionalTest, DefaultConstructor) { | 99 TEST(OptionalTest, DefaultConstructor) { |
| 100 { | 100 { |
| 101 constexpr Optional<float> o; | 101 constexpr Optional<float> o; |
| 102 EXPECT_FALSE(o); | 102 EXPECT_FALSE(o); |
| 103 } | 103 } |
| 104 | 104 |
| 105 { | 105 { |
| 106 Optional<std::string> o; | 106 Optional<std::string> o; |
| (...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 | 1337 |
| 1338 TEST(OptionalTest, Reset_NoOp) { | 1338 TEST(OptionalTest, Reset_NoOp) { |
| 1339 Optional<int> a; | 1339 Optional<int> a; |
| 1340 EXPECT_FALSE(a.has_value()); | 1340 EXPECT_FALSE(a.has_value()); |
| 1341 | 1341 |
| 1342 a.reset(); | 1342 a.reset(); |
| 1343 EXPECT_FALSE(a.has_value()); | 1343 EXPECT_FALSE(a.has_value()); |
| 1344 } | 1344 } |
| 1345 | 1345 |
| 1346 } // namespace base | 1346 } // namespace base |
| OLD | NEW |