| 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 | |
| 9 #include "wtf/text/StringBuffer.h" | 8 #include "wtf/text/StringBuffer.h" |
| 10 | 9 |
| 11 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
| 12 | 11 |
| 13 namespace { | 12 namespace WTF { |
| 14 | 13 |
| 15 | 14 TEST(StringBufferTest, Initial) |
| 16 TEST(StringBuffer, Initial) | |
| 17 { | 15 { |
| 18 StringBuffer<LChar> buf1; | 16 StringBuffer<LChar> buf1; |
| 19 EXPECT_EQ(0u, buf1.length()); | 17 EXPECT_EQ(0u, buf1.length()); |
| 20 EXPECT_FALSE(buf1.characters()); | 18 EXPECT_FALSE(buf1.characters()); |
| 21 | 19 |
| 22 StringBuffer<LChar> buf2(0); | 20 StringBuffer<LChar> buf2(0); |
| 23 EXPECT_EQ(0u, buf2.length()); | 21 EXPECT_EQ(0u, buf2.length()); |
| 24 EXPECT_FALSE(buf2.characters()); | 22 EXPECT_FALSE(buf2.characters()); |
| 25 | 23 |
| 26 StringBuffer<LChar> buf3(1); | 24 StringBuffer<LChar> buf3(1); |
| 27 EXPECT_EQ(1u, buf3.length()); | 25 EXPECT_EQ(1u, buf3.length()); |
| 28 EXPECT_TRUE(buf3.characters()); | 26 EXPECT_TRUE(buf3.characters()); |
| 29 } | 27 } |
| 30 | 28 |
| 31 TEST(StringBuffer, shrink) | 29 TEST(StringBufferTest, shrink) |
| 32 { | 30 { |
| 33 StringBuffer<LChar> buf(2); | 31 StringBuffer<LChar> buf(2); |
| 34 EXPECT_EQ(2u, buf.length()); | 32 EXPECT_EQ(2u, buf.length()); |
| 35 buf[0] = 'a'; | 33 buf[0] = 'a'; |
| 36 buf[1] = 'b'; | 34 buf[1] = 'b'; |
| 37 | 35 |
| 38 buf.shrink(1); | 36 buf.shrink(1); |
| 39 EXPECT_EQ(1u, buf.length()); | 37 EXPECT_EQ(1u, buf.length()); |
| 40 EXPECT_EQ('a', buf[0]); | 38 EXPECT_EQ('a', buf[0]); |
| 41 | 39 |
| 42 buf.shrink(0); | 40 buf.shrink(0); |
| 43 EXPECT_EQ(0u, buf.length()); | 41 EXPECT_EQ(0u, buf.length()); |
| 44 } | 42 } |
| 45 | 43 |
| 46 } // namespace | 44 } // namespace WTF |
| OLD | NEW |