| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "config.h" | 7 #include "config.h" |
| 8 #include "wtf/text/StringBuffer.h" | 8 #include "wtf/text/StringBuffer.h" |
| 9 | 9 |
| 10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
| 11 | 11 |
| 12 namespace WTF { | 12 namespace WTF { |
| 13 | 13 |
| 14 TEST(StringBufferTest, Initial) | 14 TEST(StringBufferTest, Initial) { |
| 15 { | 15 StringBuffer<LChar> buf1; |
| 16 StringBuffer<LChar> buf1; | 16 EXPECT_EQ(0u, buf1.length()); |
| 17 EXPECT_EQ(0u, buf1.length()); | 17 EXPECT_FALSE(buf1.characters()); |
| 18 EXPECT_FALSE(buf1.characters()); | |
| 19 | 18 |
| 20 StringBuffer<LChar> buf2(0); | 19 StringBuffer<LChar> buf2(0); |
| 21 EXPECT_EQ(0u, buf2.length()); | 20 EXPECT_EQ(0u, buf2.length()); |
| 22 EXPECT_FALSE(buf2.characters()); | 21 EXPECT_FALSE(buf2.characters()); |
| 23 | 22 |
| 24 StringBuffer<LChar> buf3(1); | 23 StringBuffer<LChar> buf3(1); |
| 25 EXPECT_EQ(1u, buf3.length()); | 24 EXPECT_EQ(1u, buf3.length()); |
| 26 EXPECT_TRUE(buf3.characters()); | 25 EXPECT_TRUE(buf3.characters()); |
| 27 } | 26 } |
| 28 | 27 |
| 29 TEST(StringBufferTest, shrink) | 28 TEST(StringBufferTest, shrink) { |
| 30 { | 29 StringBuffer<LChar> buf(2); |
| 31 StringBuffer<LChar> buf(2); | 30 EXPECT_EQ(2u, buf.length()); |
| 32 EXPECT_EQ(2u, buf.length()); | 31 buf[0] = 'a'; |
| 33 buf[0] = 'a'; | 32 buf[1] = 'b'; |
| 34 buf[1] = 'b'; | |
| 35 | 33 |
| 36 buf.shrink(1); | 34 buf.shrink(1); |
| 37 EXPECT_EQ(1u, buf.length()); | 35 EXPECT_EQ(1u, buf.length()); |
| 38 EXPECT_EQ('a', buf[0]); | 36 EXPECT_EQ('a', buf[0]); |
| 39 | 37 |
| 40 buf.shrink(0); | 38 buf.shrink(0); |
| 41 EXPECT_EQ(0u, buf.length()); | 39 EXPECT_EQ(0u, buf.length()); |
| 42 } | 40 } |
| 43 | 41 |
| 44 } // namespace WTF | 42 } // namespace WTF |
| OLD | NEW |