1 // Copyright 2018 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/fxcrt/cfx_widetextbuf.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace fxcrt {
10
TEST(WideTextBuf,EmptyBuf)11 TEST(WideTextBuf, EmptyBuf) {
12 CFX_WideTextBuf wtb;
13 EXPECT_EQ(nullptr, wtb.GetBuffer());
14 EXPECT_TRUE(wtb.AsStringView().IsEmpty());
15 EXPECT_TRUE(wtb.MakeString().IsEmpty());
16 }
17
TEST(WideTextBuf,OperatorLtLt)18 TEST(WideTextBuf, OperatorLtLt) {
19 CFX_WideTextBuf wtb;
20 wtb << 42 << 3.14 << "clams" << L"\u208c\u208e";
21 EXPECT_TRUE(wtb.MakeString() == L"423.14clams\u208c\u208e");
22 }
23
TEST(WideTextBuf,Deletion)24 TEST(WideTextBuf, Deletion) {
25 CFX_WideTextBuf wtb;
26 wtb << L"ABCDEFG";
27 EXPECT_TRUE(wtb.AsStringView().EqualsASCII("ABCDEFG"));
28
29 wtb.Delete(1, 3);
30 EXPECT_TRUE(wtb.AsStringView().EqualsASCII("AEFG"));
31
32 wtb.Delete(1, 0);
33 EXPECT_TRUE(wtb.AsStringView().EqualsASCII("AEFG"));
34
35 wtb.Delete(0, 2);
36 EXPECT_TRUE(wtb.AsStringView().EqualsASCII("FG"));
37
38 wtb.Delete(0, 2);
39 EXPECT_TRUE(wtb.AsStringView().EqualsASCII(""));
40
41 wtb.Delete(0, 0);
42 EXPECT_TRUE(wtb.AsStringView().EqualsASCII(""));
43 }
44
45 } // namespace fxcrt
46