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
zip_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2024 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
<
stdint
.
h
>
6
7
#
include
"core/fxcrt/span.h"
8
#
include
"core/fxcrt/zip.h"
9
#
include
"testing/gmock/include/gmock/gmock.h"
10
#
include
"testing/gtest/include/gtest/gtest.h"
11
12
using
::testing::ElementsAreArray;
13
14
namespace
fxcrt
{
15
16
TEST
(
Zip
,
EmptyZip
) {
17
pdfium
::
span
<
const
int
>
nothing
;
18
int
stuff
[] = {1, 2, 3};
19
20
auto
zip_nothing_nothing
=
Zip
(
nothing
,
nothing
);
21
EXPECT_EQ
(
zip_nothing_nothing
.
begin
(),
zip_nothing_nothing
.
end
());
22
23
auto
zip_nothing_stuff
=
Zip
(
nothing
,
stuff
);
24
EXPECT_EQ
(
zip_nothing_stuff
.
begin
(),
zip_nothing_stuff
.
end
());
25
26
auto
zip_nothing_nothing_nothing
=
Zip
(
nothing
,
nothing
,
nothing
);
27
EXPECT_EQ
(
zip_nothing_nothing_nothing
.
begin
(),
28
zip_nothing_nothing_nothing
.
end
());
29
30
auto
zip_nothing_nothing_stuff
=
Zip
(
nothing
,
nothing
,
stuff
);
31
EXPECT_EQ
(
zip_nothing_nothing_stuff
.
begin
(),
zip_nothing_nothing_stuff
.
end
());
32
33
auto
zip_nothing_stuff_stuff
=
Zip
(
nothing
,
stuff
,
stuff
);
34
EXPECT_EQ
(
zip_nothing_stuff_stuff
.
begin
(),
zip_nothing_stuff_stuff
.
end
());
35
}
36
37
TEST
(
Zip
,
ActualZip
) {
38
const
int
stuff
[] = {1, 2, 3};
39
const
int
expected
[] = {1, 2, 3, 0};
40
int
output
[4] = {};
41
42
for
(
auto
[
in
,
out
] :
Zip
(
stuff
,
output
)) {
43
out
=
in
;
44
}
45
EXPECT_THAT
(
output
,
ElementsAreArray
(
expected
));
46
}
47
48
TEST
(
Zip
,
ActualZip3
) {
49
const
int
stuff1
[] = {1, 2, 3};
50
const
int
stuff2
[] = {4, 5, 6};
51
const
int
expected
[] = {5, 7, 9, 0};
52
int
output
[4] = {};
53
54
for
(
auto
[
in1
,
in2
,
out
] :
Zip
(
stuff1
,
stuff2
,
output
)) {
55
out
=
in1
+
in2
;
56
}
57
EXPECT_THAT
(
output
,
ElementsAreArray
(
expected
));
58
}
59
60
TEST
(
Zip
,
BadArgumentsZip
) {
61
pdfium
::
span
<
const
int
>
nothing
;
62
int
stuff
[] = {1, 2, 3};
63
64
EXPECT_DEATH
(
Zip
(
stuff
,
nothing
),
".*"
);
65
}
66
67
TEST
(
Zip
,
BadArgumentsZip3
) {
68
pdfium
::
span
<
const
int
>
nothing
;
69
int
stuff
[] = {1, 2, 3};
70
71
EXPECT_DEATH
(
Zip
(
stuff
,
stuff
,
nothing
),
".*"
);
72
}
73
74
}
// namespace fxcrt
fxcrt
Definition
stl_util.h:17
fxcrt::TEST
TEST(ByteOrder, FromLE16)
Definition
byteorder_unittest.cpp:22
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcrt
zip_unittest.cpp
Generated on
for Qt by
1.14.0