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

Unified Diff: Source/wtf/text/StringBufferTest.cpp

Issue 520723002: Stop inlining StringBuffer<CharType>::shrink(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: StringBuffer::shrink(). Warnings signed 0 compared to unsigned length. Created 6 years, 4 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
« no previous file with comments | « Source/wtf/text/StringBuffer.h ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/text/StringBufferTest.cpp
diff --git a/Source/wtf/text/StringBufferTest.cpp b/Source/wtf/text/StringBufferTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4a309732619128636896058c3eb1772a74b1261b
--- /dev/null
+++ b/Source/wtf/text/StringBufferTest.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2014 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 "config.h"
+
+#include "wtf/text/StringBuffer.h"
+
+#include <gtest/gtest.h>
+
+namespace {
+
+
+TEST(StringBuffer, Initial)
+{
+ StringBuffer<LChar> buf1;
+ EXPECT_EQ(0u, buf1.length());
+ EXPECT_FALSE(buf1.characters());
+
+ StringBuffer<LChar> buf2(0);
+ EXPECT_EQ(0u, buf2.length());
+ EXPECT_FALSE(buf2.characters());
+
+ StringBuffer<LChar> buf3(1);
+ EXPECT_EQ(1u, buf3.length());
+ EXPECT_TRUE(buf3.characters());
+}
+
+TEST(StringBuffer, shrink)
+{
+ StringBuffer<LChar> buf(2);
+ EXPECT_EQ(2u, buf.length());
+ buf[0] = 'a';
+ buf[1] = 'b';
+
+ buf.shrink(1);
+ EXPECT_EQ(1u, buf.length());
+ EXPECT_EQ('a', buf[0]);
+
+ buf.shrink(0);
+ EXPECT_EQ(0u, buf.length());
+}
+
+} // namespace
« no previous file with comments | « Source/wtf/text/StringBuffer.h ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698