Branch data Line data Source code
1 : : /* Selftests for text art.
2 : : Copyright (C) 2023-2024 Free Software Foundation, Inc.
3 : : Contributed by David Malcolm <dmalcolm@redhat.com>.
4 : :
5 : : This file is part of GCC.
6 : :
7 : : GCC is free software; you can redistribute it and/or modify it under
8 : : the terms of the GNU General Public License as published by the Free
9 : : Software Foundation; either version 3, or (at your option) any later
10 : : version.
11 : :
12 : : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : : for more details.
16 : :
17 : : You should have received a copy of the GNU General Public License
18 : : along with GCC; see the file COPYING3. If not see
19 : : <http://www.gnu.org/licenses/>. */
20 : :
21 : : #include "config.h"
22 : : #define INCLUDE_VECTOR
23 : : #include "system.h"
24 : : #include "coretypes.h"
25 : : #include "selftest.h"
26 : : #include "pretty-print.h"
27 : : #include "text-art/selftests.h"
28 : : #include "text-art/canvas.h"
29 : :
30 : : #if CHECKING_P
31 : :
32 : : /* Run all tests, aborting if any fail. */
33 : :
34 : : void
35 : 4 : selftest::text_art_tests ()
36 : : {
37 : 4 : text_art_style_cc_tests ();
38 : 4 : text_art_styled_string_cc_tests ();
39 : :
40 : 4 : text_art_box_drawing_cc_tests ();
41 : 4 : text_art_canvas_cc_tests ();
42 : 4 : text_art_ruler_cc_tests ();
43 : 4 : text_art_table_cc_tests ();
44 : 4 : text_art_widget_cc_tests ();
45 : 4 : }
46 : :
47 : : /* Implementation detail of ASSERT_CANVAS_STREQ. */
48 : :
49 : : void
50 : 244 : selftest::assert_canvas_streq (const location &loc,
51 : : const text_art::canvas &canvas,
52 : : pretty_printer *pp,
53 : : const char *expected_str)
54 : : {
55 : 244 : canvas.print_to_pp (pp);
56 : 244 : if (0)
57 : : fprintf (stderr, "%s\n", pp_formatted_text (pp));
58 : 244 : ASSERT_STREQ_AT (loc, pp_formatted_text (pp), expected_str);
59 : 244 : }
60 : :
61 : : /* Implementation detail of ASSERT_CANVAS_STREQ. */
62 : :
63 : : void
64 : 236 : selftest::assert_canvas_streq (const location &loc,
65 : : const text_art::canvas &canvas,
66 : : bool styled,
67 : : const char *expected_str)
68 : : {
69 : 236 : pretty_printer pp;
70 : 236 : if (styled)
71 : : {
72 : 92 : pp_show_color (&pp) = true;
73 : 92 : pp.url_format = URL_FORMAT_DEFAULT;
74 : : }
75 : 236 : assert_canvas_streq (loc, canvas, &pp, expected_str);
76 : 236 : }
77 : :
78 : : #endif /* #if CHECKING_P */
|