CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
test
common
test_pugixml.cpp
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#include "
test.h
"
8
#include <
pugixml/pugixml.hpp
>
9
10
using namespace
pugi
;
11
12
TEST
(pugixml, null_pointer_dereference_insert_move_before) {
13
// Create an empty node (without root, _root = nullptr)
14
xml_node
empty_node;
15
ASSERT_FALSE(empty_node);
16
17
// Create a valid document
18
xml_document
doc;
19
xml_node
root = doc.
append_child
(
"root"
);
20
xml_node
child1 = root.
append_child
(
"child1"
);
21
xml_node
child2 = root.
append_child
(
"child2"
);
22
23
// Attempt insert_move_before from an empty node
24
// Before the patch this would crash, now it should return an empty xml_node
25
xml_node
result = empty_node.
insert_move_before
(child2, child1);
26
27
// Verify it returns an empty node without crashing
28
EXPECT_FALSE(result);
29
}
30
31
TEST
(pugixml, null_pointer_dereference_insert_move_after) {
32
// Create an empty node
33
xml_node
empty_node;
34
35
// Create a valid document
36
xml_document
doc;
37
xml_node
root = doc.
append_child
(
"root"
);
38
xml_node
child1 = root.
append_child
(
"child1"
);
39
xml_node
child2 = root.
append_child
(
"child2"
);
40
41
// Attempt insert_move_after from an empty node
42
xml_node
result = empty_node.
insert_move_after
(child2, child1);
43
44
// Verify it returns an empty node without crashing
45
EXPECT_FALSE(result);
46
}
47
48
TEST
(pugixml, null_pointer_dereference_insert_child_before) {
49
// Create an empty node
50
xml_node
empty_node;
51
52
// Create a valid document
53
xml_document
doc;
54
xml_node
root = doc.
append_child
(
"root"
);
55
xml_node
child = root.
append_child
(
"child"
);
56
57
// Attempt insert_child_before from an empty node
58
xml_node
result = empty_node.
insert_child_before
(
node_element
, child);
59
60
// Verify it returns an empty node without crashing
61
EXPECT_FALSE(result);
62
}
63
64
TEST
(pugixml, null_pointer_dereference_insert_child_after) {
65
// Create an empty node
66
xml_node
empty_node;
67
68
// Create a valid document
69
xml_document
doc;
70
xml_node
root = doc.
append_child
(
"root"
);
71
xml_node
child = root.
append_child
(
"child"
);
72
73
// Attempt insert_child_after from an empty node
74
xml_node
result = empty_node.
insert_child_after
(
node_element
, child);
75
76
// Verify it returns an empty node without crashing
77
EXPECT_FALSE(result);
78
}
79
80
TEST
(pugixml, null_pointer_dereference_insert_copy_before) {
81
// Create an empty node
82
xml_node
empty_node;
83
84
// Create a valid document
85
xml_document
doc;
86
xml_node
root = doc.
append_child
(
"root"
);
87
xml_node
child = root.
append_child
(
"child"
);
88
xml_node
proto = root.
append_child
(
"proto"
);
89
90
// Attempt insert_copy_before from an empty node
91
xml_node
result = empty_node.
insert_copy_before
(proto, child);
92
93
// Verify it returns an empty node without crashing
94
EXPECT_FALSE(result);
95
}
96
97
TEST
(pugixml, null_pointer_dereference_insert_copy_after) {
98
// Create an empty node
99
xml_node
empty_node;
100
101
// Create a valid document
102
xml_document
doc;
103
xml_node
root = doc.
append_child
(
"root"
);
104
xml_node
child = root.
append_child
(
"child"
);
105
xml_node
proto = root.
append_child
(
"proto"
);
106
107
// Attempt insert_copy_after from an empty node
108
xml_node
result = empty_node.
insert_copy_after
(proto, child);
109
110
// Verify it returns an empty node without crashing
111
EXPECT_FALSE(result);
112
}
pugi::xml_document
Definition
pugixml.hpp:997
pugi::xml_node
Definition
pugixml.hpp:451
pugi::xml_node::append_child
xml_node append_child(xml_node_type type=node_element)
Definition
pugixml.cpp:5792
pugi::xml_node::insert_move_after
xml_node insert_move_after(const xml_node &moved, const xml_node &node)
Definition
pugixml.cpp:6000
pugi::xml_node::insert_child_after
xml_node insert_child_after(xml_node_type type, const xml_node &node)
Definition
pugixml.cpp:5844
pugi::xml_node::insert_copy_after
xml_attribute insert_copy_after(const xml_attribute &proto, const xml_attribute &attr)
Definition
pugixml.cpp:5756
pugi::xml_node::insert_move_before
xml_node insert_move_before(const xml_node &moved, const xml_node &node)
Definition
pugixml.cpp:6018
pugi::xml_node::insert_copy_before
xml_attribute insert_copy_before(const xml_attribute &proto, const xml_attribute &attr)
Definition
pugixml.cpp:5774
pugi::xml_node::insert_child_before
xml_node insert_child_before(xml_node_type type, const xml_node &node)
Definition
pugixml.cpp:5826
pugi
Definition
ControllerParser.h:9
pugi::node_element
@ node_element
Definition
pugixml.hpp:144
pugixml.hpp
test.h
TEST
TEST(agents_types, road_option_values_match_python)
Definition
test_agents.cpp:40
Generated by
1.18.0