Design: 04.02.03.03/P05
This is an abstract, language-independent design. Grim
details may be found in the
corresponding source code.
You may return to the
documentation
for the module containing this program design, or to the
entire hierarchical table of
topics covered by the PVT.
PROGRAM 5: Text extent results derived from nominal character
sizes
CHARACTERISTICS: ynnn
OPERATOR SCRIPT: passive test
DESIGN:
Open primary workstation
Establish specwt = specific primary workstation type
font = a randomly selected font; non-monospaced if possible
for text path = RIGHT,LEFT,UP,DOWN
<inquire text extent> to determine:
ncw,nch = nominal character body width,height
for "W", ".", " "
ncww = nominal character body width for "W", horizontal path
ncwp = nominal character body width for ".", horizontal path
ncwb = nominal character body width for " ", horizontal path
mincw = minimum value for ncw for vertical paths
maxcw = maximum value for ncw for vertical paths
minch = minimum value for nch for all paths
maxch = maximum value for nch for all paths
next text path
TEST: #SR 1 2 3 15 16
"The nominal height of all character bodies for a given
font should be equal, regardless of text path."
if (minch approx= maxch) then
pass
nomch = nominal character body height = (minch+maxch) / 2
else
fail
endif
TEST: #SR 1 2 3 16
"The nominal rectangle width of all vertical text paths for
a given font should be equal."
if (mincw approx= maxcw) then
pass
nomvw = nominal width of vertical path = (mincw+maxcw) / 2
else
fail
endif
TEST: #SR 1 2 3 15
"The nominal rectangle width for a given font and text
string should be equal for all horizontal text paths."
pass/fail depending on
(ncww for path:LEFT approx= ncww for path:RIGHT and
ncwp for path:LEFT approx= ncwp for path:RIGHT and
ncwb for path:LEFT approx= ncwb for path:RIGHT)
if (any of three previous tests failed) then
message: no more tests, cannot determine nominal sizes
goto end_prog
endif
get nominal displacements for vertical text alignments:
vtab(TOP,CAP,HALF,BASE,BOTTOM) = vertical offsets
testr = test text string = "WW ...."
*** *** *** *** *** horizontal text paths *** *** *** *** ***
locok = true
ccpok = true
negok = true
nomrx,nomry = nominal horizontal rectangle size
based on ncw,nch, ncww,ncwp,ncwb
for horizontal text paths
for all text alignments (txal)
chht,chxp,chsp = some random values for character height,
expansion factor, and spacing
calculate expected value for:
xlo,xhi,ylo,yhi = position of text extent rectangle
ccpx,ccpy = concatenation point
<inquire text extent> with specwt, font, chxp, chsp,
chht, txp, txal, testr
to determine actual rectangle:
txexrx(1), txexrx(2), txexry(1), txexry(2)
and concatenation point:
acpx, acpy
chht2 = chht
chxp2 = chxp
randomly, do one of the following:
a) chht2 = -chht2
b) chxp2 = -chxp2
c) chht2 = -chht2
chxp2 = -chxp2
<inquire text extent> with specwt, font, chxp2, chsp,
chht2, txp, txal, testr
to determine actual rectangle, but with negative values for
chxp and/or chht:
t2exrx(1), t2exrx(2), t2exry(1), t2exry(2)
and concatenation point:
a2cpx, a2cpy
if (1st actual rectangle not= 2nd or
1st concatenation point not= 2nd) then
message: negative values failed using font, chxp, chsp, chht,
txp, txal
negok = false
endif
For approximate equality:
abstol = absolute tolerance = .02*chh
reltol = relative tolerance = .02
if actual rectangle not= expected then
message: rectangle failed using font, chxp, chsp, chht,
txp, txal
locok = false
endif
if actual concatenation point not= expected then
message: concatenation point failed using font, chxp, chsp,
chht, txp, txal
ccpok = false
endif
next alignment
next text path
TEST: #SR 6 8 10 15 17 18
"Negating the character height or expansion factor should
not change the location of a horizontal text extent
rectangle nor its associated concatenation point."
pass/fail depending on (negok)
TEST: #SR 1 2 3 6 7 8 9 10 11 13 14 15
"For any valid parameter values, the location of a
horizontal text extent rectangle should be as derived
from nominal character body sizes and from nominal text
alignments."
pass/fail depending on (locok)
TEST: #SR 1 2 3 6 7 8 9 10 11 13 14 17 18
"For any valid parameter values, the location of the
concatenation point following a horizontal text extent
rectangle should be as derived from nominal character body
sizes and from nominal text alignments."
pass/fail depending on (ccpok)
*** *** *** *** *** vertical text paths *** *** *** *** ***
locok = true
ccpok = true
negok = true
nomrx,nomry = nominal vertical rectangle size
based on ncw,nch, ncww,ncwp,ncwb
for vertical text paths
for all text alignments (txal)
chht,chxp,chsp = some random values for character height,
expansion factor, and spacing
calculate expected value for:
xlo,xhi,ylo,yhi = position of text extent rectangle
ccpx,ccpy = concatenation point
<inquire text extent> with specwt, font, chxp, chsp,
chht, txp, txal, testr
to determine actual rectangle:
txexrx(1), txexrx(2), txexry(1), txexry(2)
and concatenation point:
acpx, acpy
chht2 = chht
chxp2 = chxp
randomly, do one of the following:
a) chht2 = -chht2
b) chxp2 = -chxp2
c) chht2 = -chht2
chxp2 = -chxp2
<inquire text extent> with specwt, font, chxp2, chsp,
chht2, txp, txal, testr
to determine actual rectangle, but with negative values for
chxp and/or chht:
t2exrx(1), t2exrx(2), t2exry(1), t2exry(2)
and concatenation point:
a2cpx, a2cpy
if (1st actual rectangle not= 2nd or
1st concatenation point not= 2nd) then
message: negative values failed using font, chxp, chsp, chht,
txp, txal
negok = false
endif
For approximate equality:
abstol = absolute tolerance = .02*chh
reltol = relative tolerance = .02
if actual rectangle not= expected then
message: rectangle failed using font, chxp, chsp, chht,
txp, txal
locok = false
endif
if actual concatenation point not= expected then
message: concatenation point failed using font, chxp, chsp,
chht, txp, txal
ccpok = false
endif
next alignment
next text path
TEST: #SR 6 8 10 16 17 18
"Negating the character height or expansion factor should
not change the location of a vertical text extent
rectangle nor its associated concatenation point."
pass/fail depending on (negok)
TEST: #SR 1 2 3 6 7 8 9 10 11 13 14 16
"For any valid parameter values, the location of a
vertical text extent rectangle should be as derived
from nominal character body sizes and from nominal text
alignments."
pass/fail depending on (locok)
TEST: #SR 1 2 3 6 7 8 9 10 11 13 14 17 18
"For any valid parameter values, the location of the
concatenation point following a vertical text extent
rectangle should be as derived from nominal character body
sizes and from nominal text alignments."
pass/fail depending on (ccpok)
endprog:
END PROGRAM 5