1 /* Self tests for ui_file
3 Copyright (C) 2022-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/scoped_restore.h"
21 #include "gdbsupport/selftest.h"
28 check_one (const char *str
, int quoter
, const char *result
)
31 out
.putstr (str
, quoter
);
32 SELF_CHECK (out
.string () == result
);
38 check_one ("basic stuff: \\", '\\',
40 check_one ("more basic stuff: \\Q", 'Q',
41 "more basic stuff: \\\\\\Q");
42 check_one ("more basic stuff: \\Q", '\0',
43 "more basic stuff: \\Q");
45 check_one ("weird stuff: \x1f\x90\n\b\t\f\r\033\007", '\\',
46 "weird stuff: \\037\\220\\n\\b\\t\\f\\r\\e\\a");
48 scoped_restore save_7
= make_scoped_restore (&sevenbit_strings
, true);
49 check_one ("more weird stuff: \xa5", '\\',
50 "more weird stuff: \\245");
54 } /* namespace selftests */
56 void _initialize_ui_file_selftest ();
58 _initialize_ui_file_selftest ()
60 selftests::register_test ("ui-file",
61 selftests::file::run_tests
);