KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_text_attributes.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright (C) 2023 Wayne Stambaugh <
[email protected]
>
5
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6
*
7
* This program is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License as published by the
9
* Free Software Foundation, either version 3 of the License, or (at your
10
* option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19
*/
20
21
#include <
qa_utils/wx_utils/unit_test_utils.h
>
22
23
#include <
font/text_attributes.h
>
24
#include <
font/font.h
>
25
26
27
BOOST_AUTO_TEST_SUITE
( TextAttributes )
28
29
30
BOOST_AUTO_TEST_CASE
( Compare )
31
{
32
std::hash<TEXT_ATTRIBUTES> hasher;
33
TEXT_ATTRIBUTES
a;
34
TEXT_ATTRIBUTES
b;
35
36
BOOST_CHECK_EQUAL
( a, b );
37
BOOST_CHECK_EQUAL
( hasher( a ), hasher( b ) );
38
39
a.
m_Font
=
KIFONT::FONT::GetFont
();
40
BOOST_CHECK_GT( a, b );
41
BOOST_CHECK_NE( hasher( a ), hasher( b ) );
42
43
a.
m_Font
=
nullptr
;
44
b.
m_Font
=
KIFONT::FONT::GetFont
();
45
BOOST_CHECK_LT( a, b );
46
47
b.
m_Font
=
nullptr
;
48
a.
m_Halign
=
GR_TEXT_H_ALIGN_RIGHT
;
49
BOOST_CHECK_GT( a, b );
50
51
a.
m_Halign
=
GR_TEXT_H_ALIGN_CENTER
;
52
b.
m_Halign
=
GR_TEXT_H_ALIGN_RIGHT
;
53
BOOST_CHECK_LT( a, b );
54
55
b.
m_Halign
=
GR_TEXT_H_ALIGN_CENTER
;
56
a.
m_Valign
=
GR_TEXT_V_ALIGN_BOTTOM
;
57
BOOST_CHECK_GT( a, b );
58
59
a.
m_Valign
=
GR_TEXT_V_ALIGN_CENTER
;
60
b.
m_Valign
=
GR_TEXT_V_ALIGN_BOTTOM
;
61
BOOST_CHECK_LT( a, b );
62
63
b.
m_Valign
=
GR_TEXT_V_ALIGN_CENTER
;
64
a.
m_Angle
=
EDA_ANGLE
( 90.0,
DEGREES_T
);
65
BOOST_CHECK_GT( a, b );
66
67
a.
m_Angle
=
EDA_ANGLE
( 0.0,
DEGREES_T
);
68
b.
m_Angle
=
EDA_ANGLE
( 90.0,
DEGREES_T
);
69
BOOST_CHECK_LT( a, b );
70
71
b.
m_Angle
=
EDA_ANGLE
( 0.0,
DEGREES_T
);
72
a.
m_StrokeWidth
= 1;
73
BOOST_CHECK_GT( a, b );
74
75
a.
m_StrokeWidth
= 0;
76
b.
m_StrokeWidth
= 1;
77
BOOST_CHECK_LT( a, b );
78
79
b.
m_StrokeWidth
= 0;
80
a.
m_Italic
=
true
;
81
BOOST_CHECK_GT( a, b );
82
83
a.
m_Italic
=
false
;
84
b.
m_Italic
=
true
;
85
BOOST_CHECK_LT( a, b );
86
87
b.
m_Italic
=
false
;
88
a.
m_Bold
=
true
;
89
BOOST_CHECK_GT( a, b );
90
91
a.
m_Bold
=
false
;
92
b.
m_Bold
=
true
;
93
BOOST_CHECK_LT( a, b );
94
95
b.
m_Bold
=
false
;
96
a.
m_Underlined
=
true
;
97
BOOST_CHECK_GT( a, b );
98
99
a.
m_Underlined
=
false
;
100
b.
m_Underlined
=
true
;
101
BOOST_CHECK_LT( a, b );
102
103
b.
m_Underlined
=
false
;
104
a.
m_Color
=
KIGFX::COLOR4D
(
RED
);
105
BOOST_CHECK_GT( a, b );
106
107
a.
m_Color
=
KIGFX::COLOR4D
(
UNSPECIFIED_COLOR
);
108
b.
m_Color
=
KIGFX::COLOR4D
(
RED
);
109
BOOST_CHECK_LT( a, b );
110
111
b.
m_Color
=
KIGFX::COLOR4D
(
UNSPECIFIED_COLOR
);
112
a.
m_Mirrored
=
true
;
113
BOOST_CHECK_GT( a, b );
114
115
a.
m_Mirrored
=
false
;
116
b.
m_Mirrored
=
true
;
117
BOOST_CHECK_LT( a, b );
118
119
b.
m_Mirrored
=
false
;
120
b.
m_Multiline
=
false
;
121
BOOST_CHECK_GT( a, b );
122
123
b.
m_Multiline
=
true
;
124
a.
m_Multiline
=
false
;
125
BOOST_CHECK_LT( a, b );
126
127
a.
m_Multiline
=
true
;
128
a.
m_Size
.
x
= 1;
129
BOOST_CHECK_GT( a, b );
130
131
a.
m_Size
.
x
= 0;
132
b.
m_Size
.
x
= 1;
133
BOOST_CHECK_LT( a, b );
134
135
b.
m_Size
.
x
= 0;
136
a.
m_KeepUpright
=
true
;
137
BOOST_CHECK_GT( a, b );
138
139
a.
m_KeepUpright
=
false
;
140
b.
m_KeepUpright
=
true
;
141
BOOST_CHECK_LT( a, b );
142
143
b.
m_KeepUpright
=
false
;
144
}
145
146
147
BOOST_AUTO_TEST_SUITE_END
()
EDA_ANGLE
Definition
eda_angle.h:36
KIFONT::FONT::GetFont
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition
font.cpp:144
KIGFX::COLOR4D
A color representation with 4 components: red, green, blue, alpha.
Definition
color4d.h:101
TEXT_ATTRIBUTES
Definition
text_attributes.h:119
TEXT_ATTRIBUTES::m_StrokeWidth
int m_StrokeWidth
Definition
text_attributes.h:134
TEXT_ATTRIBUTES::m_KeepUpright
bool m_KeepUpright
Definition
text_attributes.h:145
TEXT_ATTRIBUTES::m_Italic
bool m_Italic
Definition
text_attributes.h:135
TEXT_ATTRIBUTES::m_Color
KIGFX::COLOR4D m_Color
Definition
text_attributes.h:139
TEXT_ATTRIBUTES::m_Bold
bool m_Bold
Definition
text_attributes.h:136
TEXT_ATTRIBUTES::m_Underlined
bool m_Underlined
Definition
text_attributes.h:137
TEXT_ATTRIBUTES::m_Multiline
bool m_Multiline
Definition
text_attributes.h:141
TEXT_ATTRIBUTES::m_Angle
EDA_ORIENTATION m_Angle
Definition
text_attributes.h:132
TEXT_ATTRIBUTES::m_Halign
GR_TEXT_H_ALIGN_T m_Halign
Definition
text_attributes.h:130
TEXT_ATTRIBUTES::m_Valign
GR_TEXT_V_ALIGN_T m_Valign
Definition
text_attributes.h:131
TEXT_ATTRIBUTES::m_Font
KIFONT::FONT * m_Font
Definition
text_attributes.h:129
TEXT_ATTRIBUTES::m_Size
VECTOR2I m_Size
Definition
text_attributes.h:142
TEXT_ATTRIBUTES::m_Mirrored
bool m_Mirrored
Definition
text_attributes.h:140
VECTOR2::x
T x
Definition
vector2d.h:75
UNSPECIFIED_COLOR
@ UNSPECIFIED_COLOR
Definition
color4d.h:39
RED
@ RED
Definition
color4d.h:55
DEGREES_T
@ DEGREES_T
Definition
eda_angle.h:30
font.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:80
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
text_attributes.h
GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_CENTER
Definition
text_attributes.h:45
GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_RIGHT
Definition
text_attributes.h:46
GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_BOTTOM
Definition
text_attributes.h:55
GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_CENTER
Definition
text_attributes.h:54
unit_test_utils.h
src
qa
tests
common
test_text_attributes.cpp
Generated on Tue Nov 17 2026 00:06:28 for KiCad PCB EDA Suite by
1.13.2