GDB (xrefs)
Loading...
Searching...
No Matches
gdb
unittests
child-path-selftests.c
Go to the documentation of this file.
1
/* Self tests for child_path for GDB, the GNU debugger.
2
3
Copyright (C) 2019-2023 Free Software Foundation, Inc.
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 "gdbsupport/pathstuff.h"
22
#include "gdbsupport/selftest.h"
23
24
namespace
selftests
{
25
namespace
child_path {
26
27
/* Verify the result of a single child_path test. */
28
29
static
bool
30
child_path_check
(
const
char
*parent,
const
char
*child,
const
char
*expected)
31
{
32
const
char
*result = ::child_path (parent, child);
33
if
(result == NULL || expected == NULL)
34
return
result == expected;
35
return
strcmp (result, expected) == 0;
36
}
37
38
/* Test child_path. */
39
40
static
void
41
test
()
42
{
43
SELF_CHECK (
child_path_check
(
"/one"
,
"/two"
, NULL));
44
SELF_CHECK (
child_path_check
(
"/one"
,
"/one"
, NULL));
45
SELF_CHECK (
child_path_check
(
"/one"
,
"/one/"
, NULL));
46
SELF_CHECK (
child_path_check
(
"/one"
,
"/one//"
, NULL));
47
SELF_CHECK (
child_path_check
(
"/one"
,
"/one/two"
,
"two"
));
48
SELF_CHECK (
child_path_check
(
"/one/"
,
"/two"
, NULL));
49
SELF_CHECK (
child_path_check
(
"/one/"
,
"/one"
, NULL));
50
SELF_CHECK (
child_path_check
(
"/one/"
,
"/one/"
, NULL));
51
SELF_CHECK (
child_path_check
(
"/one/"
,
"/one//"
, NULL));
52
SELF_CHECK (
child_path_check
(
"/one/"
,
"/one/two"
,
"two"
));
53
SELF_CHECK (
child_path_check
(
"/one/"
,
"/one//two"
,
"two"
));
54
SELF_CHECK (
child_path_check
(
"/one/"
,
"/one//two/"
,
"two/"
));
55
SELF_CHECK (
child_path_check
(
"/one"
,
"/onetwo"
, NULL));
56
SELF_CHECK (
child_path_check
(
"/one"
,
"/onetwo/three"
, NULL));
57
}
58
59
}
60
}
61
62
void
_initialize_child_path_selftests
();
63
void
64
_initialize_child_path_selftests
()
65
{
66
selftests::register_test (
"child_path"
,
67
selftests::child_path::test
);
68
}
69
_initialize_child_path_selftests
void _initialize_child_path_selftests()
Definition
child-path-selftests.c:64
defs.h
selftests::child_path::child_path_check
static bool child_path_check(const char *parent, const char *child, const char *expected)
Definition
child-path-selftests.c:30
selftests::child_path::test
static void test()
Definition
child-path-selftests.c:41
selftests
Definition
disasm-selftests.c:26
Generated by
1.10.0