1/* Selftests for text art.
2 Copyright (C) 2023-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along 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
34void
35selftest::text_art_tests ()
36{
37 text_art_style_cc_tests ();
38 text_art_styled_string_cc_tests ();
39
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 ();
45}
46
47/* Implementation detail of ASSERT_CANVAS_STREQ. */
48
49void
50selftest::assert_canvas_streq (const location &loc,
51 const text_art::canvas &canvas,
52 pretty_printer *pp,
53 const char *expected_str)
54{
55 canvas.print_to_pp (pp);
56 if (0)
57 fprintf (stderr, format: "%s\n", pp_formatted_text (pp));
58 ASSERT_STREQ_AT (loc, pp_formatted_text (pp), expected_str);
59}
60
61/* Implementation detail of ASSERT_CANVAS_STREQ. */
62
63void
64selftest::assert_canvas_streq (const location &loc,
65 const text_art::canvas &canvas,
66 bool styled,
67 const char *expected_str)
68{
69 pretty_printer pp;
70 if (styled)
71 {
72 pp_show_color (&pp) = true;
73 pp.url_format = URL_FORMAT_DEFAULT;
74 }
75 assert_canvas_streq (loc, canvas, pp: &pp, expected_str);
76}
77
78#endif /* #if CHECKING_P */
79

source code of gcc/text-art/selftests.cc