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 (C) 2023 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 along
18
* with this program. If not, see <http://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
b.
m_Visible
=
false
;
113
BOOST_CHECK_GT( a, b );
114
115
b.
m_Visible
=
true
;
116
a.
m_Visible
=
false
;
117
BOOST_CHECK_LT( a, b );
118
119
a.
m_Visible
=
true
;
120
a.
m_Mirrored
=
true
;
121
BOOST_CHECK_GT( a, b );
122
123
a.
m_Mirrored
=
false
;
124
b.
m_Mirrored
=
true
;
125
BOOST_CHECK_LT( a, b );
126
127
b.
m_Mirrored
=
false
;
128
b.
m_Multiline
=
false
;
129
BOOST_CHECK_GT( a, b );
130
131
b.
m_Multiline
=
true
;
132
a.
m_Multiline
=
false
;
133
BOOST_CHECK_LT( a, b );
134
135
a.
m_Multiline
=
true
;
136
a.
m_Size
.
x
= 1;
137
BOOST_CHECK_GT( a, b );
138
139
a.
m_Size
.
x
= 0;
140
b.
m_Size
.
x
= 1;
141
BOOST_CHECK_LT( a, b );
142
143
b.
m_Size
.
x
= 0;
144
a.
m_KeepUpright
=
true
;
145
BOOST_CHECK_GT( a, b );
146
147
a.
m_KeepUpright
=
false
;
148
b.
m_KeepUpright
=
true
;
149
BOOST_CHECK_LT( a, b );
150
151
b.
m_KeepUpright
=
false
;
152
}
153
154
155
BOOST_AUTO_TEST_SUITE_END()
EDA_ANGLE
Definition:
eda_angle.h:37
KIFONT::FONT::GetFont
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition:
font.cpp:146
KIGFX::COLOR4D
A color representation with 4 components: red, green, blue, alpha.
Definition:
color4d.h:104
TEXT_ATTRIBUTES
Definition:
text_attributes.h:61
TEXT_ATTRIBUTES::m_Visible
bool m_Visible
Definition:
text_attributes.h:81
TEXT_ATTRIBUTES::m_StrokeWidth
int m_StrokeWidth
Definition:
text_attributes.h:76
TEXT_ATTRIBUTES::m_KeepUpright
bool m_KeepUpright
Definition:
text_attributes.h:87
TEXT_ATTRIBUTES::m_Italic
bool m_Italic
Definition:
text_attributes.h:77
TEXT_ATTRIBUTES::m_Color
KIGFX::COLOR4D m_Color
Definition:
text_attributes.h:80
TEXT_ATTRIBUTES::m_Bold
bool m_Bold
Definition:
text_attributes.h:78
TEXT_ATTRIBUTES::m_Underlined
bool m_Underlined
Definition:
text_attributes.h:79
TEXT_ATTRIBUTES::m_Multiline
bool m_Multiline
Definition:
text_attributes.h:83
TEXT_ATTRIBUTES::m_Halign
GR_TEXT_H_ALIGN_T m_Halign
Definition:
text_attributes.h:72
TEXT_ATTRIBUTES::m_Valign
GR_TEXT_V_ALIGN_T m_Valign
Definition:
text_attributes.h:73
TEXT_ATTRIBUTES::m_Font
KIFONT::FONT * m_Font
Definition:
text_attributes.h:71
TEXT_ATTRIBUTES::m_Angle
EDA_ANGLE m_Angle
Definition:
text_attributes.h:74
TEXT_ATTRIBUTES::m_Size
VECTOR2I m_Size
Definition:
text_attributes.h:84
TEXT_ATTRIBUTES::m_Mirrored
bool m_Mirrored
Definition:
text_attributes.h:82
VECTOR2::x
T x
Definition:
vector2d.h:78
UNSPECIFIED_COLOR
@ UNSPECIFIED_COLOR
Definition:
color4d.h:43
RED
@ RED
Definition:
color4d.h:59
DEGREES_T
@ DEGREES_T
Definition:
eda_angle.h:31
font.h
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(Compare)
Definition:
test_text_attributes.cpp:30
text_attributes.h
GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_CENTER
Definition:
text_attributes.h:44
GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_RIGHT
Definition:
text_attributes.h:45
GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_BOTTOM
Definition:
text_attributes.h:52
GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_CENTER
Definition:
text_attributes.h:51
unit_test_utils.h
src
qa
tests
common
test_text_attributes.cpp
Generated on Fri Sep 29 2023 00:03:49 for KiCad PCB EDA Suite by
1.9.5