1 /* Self tests for general utility routines for GDB, the GNU debugger.
3 Copyright (C) 2016-2017 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/>. */
27 /* common-utils self tests. Defined here instead of in
28 common/common-utils.c because that file is shared with
32 common_utils_tests (void)
34 SELF_CHECK (string_printf ("%s", "") == "");
35 SELF_CHECK (string_printf ("%d comes before 2", 1) == "1 comes before 2");
36 SELF_CHECK (string_printf ("hello %s", "world") == "hello world");
38 #define X10 "0123456789"
39 #define X100 X10 X10 X10 X10 X10 X10 X10 X10 X10 X10
40 #define X1000 X100 X100 X100 X100 X100 X100 X100 X100 X100 X100
41 #define X10000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000 X1000
42 #define X100000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000 X10000
43 SELF_CHECK (string_printf ("%s", X10
) == X10
);
44 SELF_CHECK (string_printf ("%s", X100
) == X100
);
45 SELF_CHECK (string_printf ("%s", X1000
) == X1000
);
46 SELF_CHECK (string_printf ("%s", X10000
) == X10000
);
47 SELF_CHECK (string_printf ("%s", X100000
) == X100000
);
50 } /* namespace selftests */
55 _initialize_utils_selftests (void)
58 register_self_test (selftests::common_utils_tests
);
This page took 0.033664 seconds and 4 git commands to generate.