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
fx_memory_wrappers_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2019 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/fx_memory_wrappers.h"
6
7
#
include
<
memory
>
8
#
include
<
sstream
>
9
#
include
<
string
>
10
#
include
<
vector
>
11
12
#
include
"build/build_config.h"
13
#
include
"testing/gtest/include/gtest/gtest.h"
14
15
namespace
{
16
17
struct
OnlyNumbers {
18
int
x;
19
int
y;
20
};
21
22
}
// namespace
23
24
FX_DATA_PARTITION_EXCEPTION
(OnlyNumbers);
25
26
TEST
(
fxcrt
,
FxFreeDeleter
) {
27
std
::unique_ptr<
int
,
FxFreeDeleter
> empty(
nullptr
);
28
std
::unique_ptr<
int
,
FxFreeDeleter
> thing(FX_Alloc(
int
, 1));
29
std
::unique_ptr<
int
,
FxFreeDeleter
> several(FX_Alloc(
int
, 100));
30
EXPECT_FALSE(empty);
31
EXPECT_TRUE(thing);
32
EXPECT_TRUE(several);
33
}
34
35
TEST
(
fxcrt
,
FxAllocAllocator
) {
36
// Let ASAN sanity check some simple operations.
37
std::vector<
int
, FxAllocAllocator<
int
>> vec;
38
vec.push_back(42);
39
vec.reserve(100);
40
vec.resize(20);
41
vec[11] = 42;
42
43
std::vector<
int
, FxAllocAllocator<
int
>> vec2 = vec;
44
vec =
std
::move(vec2);
45
vec2.resize(0);
46
vec2.push_back(42);
47
}
48
49
TEST
(
fxcrt
,
FxStringAllocator
) {
50
// Let ASAN sanity check some simple operations.
51
std::basic_ostringstream<
char
, std::char_traits<
char
>,
52
FxStringAllocator<
char
>>
53
str;
54
str <<
'B'
;
55
str <<
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
;
56
str <<
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
;
57
str <<
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
;
58
str << 42.0f;
59
}
60
61
TEST
(
fxcrt
,
FxAllocAllocatorStructException
) {
62
std::vector<OnlyNumbers, FxAllocAllocator<OnlyNumbers>> vec;
63
vec.push_back({42, 73});
64
EXPECT_EQ(vec.back().x, 42);
65
EXPECT_EQ(vec.back().y, 73);
66
}
TEST
TEST(FXCRYPT, MD5GenerateEmtpyData)
Definition
fx_crypt_unittest.cpp:45
FX_DATA_PARTITION_EXCEPTION
#define FX_DATA_PARTITION_EXCEPTION(T)
Definition
fx_memory_wrappers.h:26
TEST
TEST(fxcrt, FxFreeDeleter)
Definition
fx_memory_wrappers_unittest.cpp:26
std
Definition
qfloat16.h:493
FxFreeDeleter
Definition
fx_memory_wrappers.h:15
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcrt
fx_memory_wrappers_unittest.cpp
Generated on Thu Nov 14 2024 00:58:46 for Qt by
1.12.0