1 /* Selftests for text art.
2 Copyright (C) 2023-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
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
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
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/>. */
22 #define INCLUDE_VECTOR
24 #include "coretypes.h"
26 #include "pretty-print.h"
27 #include "text-art/selftests.h"
28 #include "text-art/canvas.h"
32 /* Run all tests, aborting if any fail. */
35 selftest::text_art_tests ()
37 text_art_style_cc_tests ();
38 text_art_styled_string_cc_tests ();
40 text_art_box_drawing_cc_tests ();
41 text_art_canvas_cc_tests ();
42 text_art_ruler_cc_tests ();
43 text_art_table_cc_tests ();
44 text_art_widget_cc_tests ();
47 /* Implementation detail of ASSERT_CANVAS_STREQ. */
50 selftest::assert_canvas_streq (const location
&loc
,
51 const text_art::canvas
&canvas
,
53 const char *expected_str
)
55 canvas
.print_to_pp (pp
);
57 fprintf (stderr
, "%s\n", pp_formatted_text (pp
));
58 ASSERT_STREQ_AT (loc
, pp_formatted_text (pp
), expected_str
);
61 /* Implementation detail of ASSERT_CANVAS_STREQ. */
64 selftest::assert_canvas_streq (const location
&loc
,
65 const text_art::canvas
&canvas
,
67 const char *expected_str
)
72 pp_show_color (&pp
) = true;
73 pp
.url_format
= URL_FORMAT_DEFAULT
;
75 assert_canvas_streq (loc
, canvas
, &pp
, expected_str
);
78 #endif /* #if CHECKING_P */