Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
widetext_buffer_unittest.cpp
Go to the documentation of this file.
1// Copyright 2018 The PDFium Authors
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/widetext_buffer.h"
6
7#include <utility>
8
9#include "testing/gtest/include/gtest/gtest.h"
10
11namespace fxcrt {
12
13TEST(WideTextBuffer, EmptyBuf) {
14 WideTextBuffer wtb;
15 EXPECT_TRUE(wtb.GetWideSpan().empty());
16 EXPECT_TRUE(wtb.AsStringView().IsEmpty());
17 EXPECT_TRUE(wtb.MakeString().IsEmpty());
18}
19
20TEST(WideTextBuffer, OperatorLtLt) {
21 WideTextBuffer wtb;
22 wtb << "clams" << L"\u208c\u208e";
23 EXPECT_EQ(wtb.MakeString(), L"clams\u208c\u208e");
24}
25
26TEST(WideTextBuffer, Deletion) {
27 WideTextBuffer wtb;
28 wtb << L"ABCDEFG";
29 EXPECT_TRUE(wtb.AsStringView().EqualsASCII("ABCDEFG"));
30
31 wtb.Delete(1, 3);
32 EXPECT_TRUE(wtb.AsStringView().EqualsASCII("AEFG"));
33
34 wtb.Delete(1, 0);
35 EXPECT_TRUE(wtb.AsStringView().EqualsASCII("AEFG"));
36
37 wtb.Delete(0, 2);
38 EXPECT_TRUE(wtb.AsStringView().EqualsASCII("FG"));
39
40 wtb.Delete(0, 2);
41 EXPECT_TRUE(wtb.AsStringView().EqualsASCII(""));
42
43 wtb.Delete(0, 0);
44 EXPECT_TRUE(wtb.AsStringView().EqualsASCII(""));
45}
46
47TEST(WideTextBuffer, Move) {
48 WideTextBuffer wtb;
49 wtb << "clams";
50 EXPECT_EQ(wtb.MakeString(), L"clams");
51
52 WideTextBuffer wtb2(std::move(wtb));
53 EXPECT_EQ(wtb.MakeString(), L"");
54 EXPECT_EQ(wtb2.MakeString(), L"clams");
55
56 WideTextBuffer wtb3;
57 wtb3 = std::move(wtb2);
58 EXPECT_EQ(wtb2.MakeString(), L"");
59 EXPECT_EQ(wtb3.MakeString(), L"clams");
60}
61
62} // namespace fxcrt
bool IsEmpty() const
Definition widestring.h:118
pdfium::span< wchar_t > GetWideSpan()
WideString MakeString() const
WideStringView AsStringView() const
TEST(WideTextBuffer, EmptyBuf)