1 /* Self tests for unpack_field_as_long
3 Copyright (C) 2018-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "gdbsupport/selftest.h"
21 #include "selftest-arch.h"
24 #include "arch-utils.h"
30 unpack_field_as_long_tests (struct gdbarch
*arch
)
33 const struct builtin_type
*bt
= builtin_type (arch
);
34 struct type
*struct_type
= arch_composite_type (arch
, "<<selftest>>",
37 append_composite_type_field (struct_type
, "field0", bt
->builtin_int8
);
38 append_composite_type_field_aligned (struct_type
, "field1",
39 bt
->builtin_uint32
, 4);
41 memset (buffer
, 0, sizeof (buffer
));
43 if (gdbarch_byte_order (arch
) == BFD_ENDIAN_BIG
)
48 SELF_CHECK (unpack_field_as_long (struct_type
, buffer
, 0) == -1);
49 SELF_CHECK (unpack_field_as_long (struct_type
, buffer
, 1) == 23);
55 void _initialize_unpack_selftests ();
57 _initialize_unpack_selftests ()
59 selftests::register_test_foreach_arch
60 ("unpack_field_as_long", selftests::unpack::unpack_field_as_long_tests
);