40 aStringToPopulate +=
" {";
42 if( aNode->isOverbar() )
43 aStringToPopulate +=
"OVER";
44 if( aNode->isSubscript() )
45 aStringToPopulate +=
"SUB";
46 if( aNode->isSuperscript() )
47 aStringToPopulate +=
"SUP";
49 if( aNode->has_content() )
50 aStringToPopulate +=
"'" + aNode->string() +
"'";
52 for(
auto& c : aNode->children )
55 aStringToPopulate +=
"} ";
70 std::vector<PARSE_CASE> cases =
74 " { {'A normal string'} } "
77 "_{A subscript String}",
78 " { {SUB {'A subscript String'} } } "
81 "^{A superscript String}",
82 " { {SUP {'A superscript String'} } } "
85 "~{An overbar String}",
86 " { {OVER {'An overbar String'} } } "
89 "~{An incomplete markup",
90 " { {'~{An incomplete markup'} } "
93 "A string ~{overbar}",
94 " { {'A string '} {OVER {'overbar'} } } "
97 "A string ~{incomplete markup",
98 " { {'A string ~{incomplete markup'} } "
101 "A string ~{overbar} ~{incomplete markup",
102 " { {'A string '} {OVER {'overbar'} } {' ~{incomplete markup'} } "
104 {
"A string ~{incomplete markup ~{overbar}",
105 " { {'A string ~{incomplete markup '} {OVER {'overbar'} } } "
109 for(
auto& c : cases )
111 BOOST_TEST_INFO_SCOPE( c.Input );
114 std::unique_ptr<MARKUP::NODE> rootNode = parser.
Parse();
144 int spaceWidth = font->
GetTextAsGlyphs(
nullptr,
nullptr, wxS(
" " ), glyphSize,
150 int fiveSpaceWidth = font->
GetTextAsGlyphs(
nullptr,
nullptr, wxS(
" " ), glyphSize,
153 BOOST_CHECK_GT( fiveSpaceWidth, spaceWidth );
156 struct LINEBREAK_CASE
162 int wideColumn = 100000;
164 std::vector<LINEBREAK_CASE> cases =
166 { wxS(
"~{ }" ), wxS(
"~{ }" ) },
167 { wxS(
"A ~{ }" ), wxS(
"A ~{ }" ) },
168 { wxS(
"A ~{ B }" ), wxS(
"A ~{ B }" ) },
169 { wxS(
"~{ } end" ), wxS(
"~{ } end" ) },
170 { wxS(
"/~{ }" ), wxS(
"/~{ }" ) },
171 { wxS(
"_{ }" ), wxS(
"_{ }" ) },
172 { wxS(
"^{ }" ), wxS(
"^{ }" ) },
175 for(
auto& c : cases )
177 BOOST_TEST_INFO_SCOPE( c.Input );
179 wxString
text = c.Input;
FONT is an abstract base class for both outline and stroke fonts.
virtual VECTOR2I GetTextAsGlyphs(BOX2I *aBBox, std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aSize, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle, bool aMirror, const VECTOR2I &aOrigin, TEXT_STYLE_FLAGS aTextStyle) const =0
Convert text string to an array of GLYPHs.
void LinebreakText(wxString &aText, int aColumnWidth, const VECTOR2I &aGlyphSize, int aThickness, bool aBold, bool aItalic) const
Insert characters into text to ensure that no lines are wider than aColumnWidth.
static STROKE_FONT * LoadFont(const wxString &aFontName)
Load a stroke font.
std::unique_ptr< NODE > Parse()
static constexpr EDA_ANGLE ANGLE_0
std::string ExpectedResult
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
void nodeToString(std::unique_ptr< MARKUP::NODE > &aNode, std::string &aStringToPopulate)
Declare the test suite.
BOOST_AUTO_TEST_CASE(Parse)
Test the #Parse method.
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I