Debian Codegraph @

unittest/gunit/innodb/lob/ut0plist.cc

raw
1 /*****************************************************************************
2
3 Copyright (c) 2016, 2026, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26 *****************************************************************************/
27
28 #include "lot0buf.h"
29 #include "lot0plist.h"
30
31 void basic_0() {
32 buf_block_t *block = btr_page_alloc();
33 byte *frame = buf_block_get_frame(block);
34
35 plist_base_node_t base(frame, frame);
36 base.init();
37
38 byte *ptr = frame + plist_base_node_t::SIZE;
39
40 for (ulint i = 0; i < 1; ++i) {
41 plist_node_t node(frame, ptr);
42 base.push_back(node);
43 ptr += plist_node_t::SIZE;
44 }
45
46 base.print_list(std::cout);
47 }
48
49 void test_00() {
50 buf_block_t *block = btr_page_alloc();
51 byte *frame = buf_block_get_frame(block);
52
53 plist_base_node_t base(frame, frame);
54 base.init();
55
56 byte *ptr = frame + plist_base_node_t::SIZE;
57
58 for (ulint i = 0; i < 5; ++i) {
59 plist_node_t node(frame, ptr);
60 base.push_back(node);
61 ptr += plist_node_t::SIZE;
62 }
63
64 base.print_list(std::cout);
65
66 plist_node_t first = base.get_first_node();
67 plist_node_t cur = first.get_next_node();
68 cur = cur.get_next_node();
69 base.remove(cur);
70 base.insert_before(first, cur);
71
72 std::cout << "-----" << std::endl;
73 base.print_list(std::cout);
74 }
75
76 void test_01() {
77 buf_block_t *block = btr_page_alloc();
78 byte *frame = buf_block_get_frame(block);
79
80 plist_base_node_t base(frame, frame);
81 base.init();
82
83 byte *ptr = frame + plist_base_node_t::SIZE;
84
85 for (ulint i = 0; i < 5; ++i) {
86 plist_node_t node(frame, ptr);
87 base.push_back(node);
88 ptr += plist_node_t::SIZE;
89 }
90
91 base.print_list(std::cout);
92
93 plist_node_t first = base.get_first_node();
94 plist_node_t last = base.get_last_node();
95 plist_node_t cur = first.get_next_node();
96 cur = cur.get_next_node();
97 base.remove(cur);
98 base.insert_before(last, cur);
99
100 std::cout << "-----" << std::endl;
101 base.print_list(std::cout);
102 }
103
104 int main() {
105 basic_0();
106 test_00();
107 test_01();
108 }