rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p5
[official-gcc.git] / gcc / text-art / box-drawing.cc
blobe6092735bbe505a221ee54436a7ab34b964e90e4
1 /* Procedural lookup of box drawing characters.
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
10 version.
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.
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/>. */
21 #include "config.h"
22 #define INCLUDE_MEMORY
23 #define INCLUDE_VECTOR
24 #include "system.h"
25 #include "coretypes.h"
26 #include "text-art/box-drawing.h"
27 #include "selftest.h"
28 #include "text-art/selftests.h"
31 /* According to
32 https://en.wikipedia.org/wiki/Box-drawing_character#Character_code
33 "DOS line- and box-drawing characters are not ordered in any programmatic
34 manner, so calculating a particular character shape needs to use a look-up
35 table. "
36 Hence this array. */
37 static const cppchar_t box_drawing_chars[] = {
38 #include "text-art/box-drawing-chars.inc"
41 cppchar_t
42 text_art::get_box_drawing_char (directions line_dirs)
44 const size_t idx = line_dirs.as_index ();
45 gcc_assert (idx < 16);
46 return box_drawing_chars[idx];
49 #if CHECKING_P
51 namespace selftest {
53 /* Run all selftests in this file. */
55 void
56 text_art_box_drawing_cc_tests ()
58 ASSERT_EQ (text_art::get_box_drawing_char
59 (text_art::directions (false, false, false, false)),
60 ' ');
61 ASSERT_EQ (text_art::get_box_drawing_char
62 (text_art::directions (false, false, true, true)),
63 0x2500); /* BOX DRAWINGS LIGHT HORIZONTAL */
64 ASSERT_EQ (text_art::get_box_drawing_char
65 (text_art::directions (true, true, false, false)),
66 0x2502); /* BOX DRAWINGS LIGHT VERTICAL */
67 ASSERT_EQ (text_art::get_box_drawing_char
68 (text_art::directions (true, false, true, false)),
69 0x2518); /* BOX DRAWINGS LIGHT UP AND LEFT */
72 } // namespace selftest
74 #endif /* #if CHECKING_P */