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