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

Unified Diff: base/memory/awesome_ptr_unittest.cc

Issue 10790149: Add awesome_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address shess's comments. Add unittests and fix readability issue with single gotos. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« base/memory/awesome_ptr.h ('K') | « base/memory/awesome_ptr.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/awesome_ptr_unittest.cc
diff --git a/base/memory/awesome_ptr_unittest.cc b/base/memory/awesome_ptr_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5dc1f0a5aa8553f2821ca2df0eca74394c1e7900
--- /dev/null
+++ b/base/memory/awesome_ptr_unittest.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/awesome_ptr.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace base {
+
+TEST(AwesomePtrTest, Create) {
+ const char* c = "hi mom.";
+ awesome_ptr<const char> ptr(c);
+}
+
+TEST(AwesomePtrTest, PointerFunctionality) {
Avi (use Gerrit) 2012/07/24 20:52:14 This tests the bool conversion, so I'd expect it t
awong 2012/07/24 20:56:53 Doh! cut/paste error.
+ const char* c = "point to me.";
+ awesome_ptr<const char> ptr(c);
+ EXPECT_TRUE(c || ptr); // Yep. Boolean conversion compiles.
+}
+
+TEST(AwesomePtrTest, BoolFunctionality) {
Avi (use Gerrit) 2012/07/24 20:52:14 ...so this would need to be called something else.
awong 2012/07/24 20:56:53 fixed.
+ const char* c = "its so so true.";
+ awesome_ptr<const char> ptr(c);
+ EXPECT_EQ(c, c); // Yep. Pointers are indeed reflexively equal.
+}
+
+TEST(AwesomePtrTest, Awesome) {
+ const char* c = "can't stop this awesome.";
+ awesome_ptr<const char> ptr(c);
+ EXPECT_TRUE("this is awesome.");
+}
+} // namespace base
« base/memory/awesome_ptr.h ('K') | « base/memory/awesome_ptr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698