]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/unittests/rsp-low-selftests.c
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / unittests / rsp-low-selftests.c
CommitLineData
21fe1c75
SM
1/* Unit tests for the rsp-low.c file.
2
e2882c85 3 Copyright (C) 2017-2018 Free Software Foundation, Inc.
21fe1c75
SM
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20#include "defs.h"
21#include "selftest.h"
22#include "common/rsp-low.h"
23
24namespace selftests {
25namespace rsp_low {
26
27/* Test the variant of hex2bin that returns a byte_vector. */
28
29static void test_hex2bin_byte_vector ()
30{
31 gdb::byte_vector bv;
32
33 /* Test an empty string. */
34 bv = hex2bin ("");
35 SELF_CHECK (bv.size () == 0);
36
37 /* Test a well-formated hex string. */
38 bv = hex2bin ("abcd01");
39 SELF_CHECK (bv.size () == 3);
40 SELF_CHECK (bv[0] == 0xab);
41 SELF_CHECK (bv[1] == 0xcd);
42 SELF_CHECK (bv[2] == 0x01);
43
44 /* Test an odd-length hex string. */
45 bv = hex2bin ("0123c");
46 SELF_CHECK (bv.size () == 2);
47 SELF_CHECK (bv[0] == 0x01);
48 SELF_CHECK (bv[1] == 0x23);
49}
50
51} /* namespace rsp_low */
52} /* namespace selftests */
53
54void
55_initialize_rsp_low_selftests ()
56{
57 selftests::register_test ("hex2bin_byte_vector",
58 selftests::rsp_low::test_hex2bin_byte_vector);
59}