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

Side by Side Diff: base/optional_unittest.cc

Issue 2434253003: Make base::Optional constructor constexpr. (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « base/optional.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 } // anonymous namespace 90 } // anonymous namespace
91 91
92 static_assert(is_trivially_destructible<Optional<int>>::value, 92 static_assert(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 !is_trivially_destructible<Optional<NonTriviallyDestructible>>::value,
97 "OptionalIsTriviallyDestructible"); 97 "OptionalIsTriviallyDestructible");
98 98
99 static_assert(!base::Optional<bool>(), "OptionalHasConstexprConstructor");
danakj 2016/10/21 21:05:01 Can you add tests for the other constructors as we
alshabalin 2016/10/21 22:36:05 Done (partially). Reading http://en.cppreference.c
100
99 TEST(OptionalTest, DefaultConstructor) { 101 TEST(OptionalTest, DefaultConstructor) {
100 { 102 {
101 Optional<float> o; 103 Optional<float> o;
102 EXPECT_FALSE(o); 104 EXPECT_FALSE(o);
103 } 105 }
104 106
105 { 107 {
106 Optional<std::string> o; 108 Optional<std::string> o;
107 EXPECT_FALSE(o); 109 EXPECT_FALSE(o);
108 } 110 }
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 1339
1338 TEST(OptionalTest, Reset_NoOp) { 1340 TEST(OptionalTest, Reset_NoOp) {
1339 Optional<int> a; 1341 Optional<int> a;
1340 EXPECT_FALSE(a.has_value()); 1342 EXPECT_FALSE(a.has_value());
1341 1343
1342 a.reset(); 1344 a.reset();
1343 EXPECT_FALSE(a.has_value()); 1345 EXPECT_FALSE(a.has_value());
1344 } 1346 }
1345 1347
1346 } // namespace base 1348 } // namespace base
OLDNEW
« no previous file with comments | « base/optional.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698