diff options
author | fvogel <fvogelnew1@free.fr> | 2022-10-28 20:58:19 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2022-10-28 20:58:19 (GMT) |
commit | af298e611c2eb20bce0b6a501f16925a54bf1c59 (patch) | |
tree | 659e9f591c0921426836ea626793d6ac29955f4b /tests/canvText.test | |
parent | e02e3e295a7936be7745a5e7885a890a22c500f0 (diff) | |
download | tk-af298e611c2eb20bce0b6a501f16925a54bf1c59.zip tk-af298e611c2eb20bce0b6a501f16925a54bf1c59.tar.gz tk-af298e611c2eb20bce0b6a501f16925a54bf1c59.tar.bz2 |
canvText-20.1: Tolerate rounding error of at most 1 pixel on the bounding boxes values.
Diffstat (limited to 'tests/canvText.test')
-rw-r--r-- | tests/canvText.test | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/canvText.test b/tests/canvText.test index 3d0acdc..de21fbc 100644 --- a/tests/canvText.test +++ b/tests/canvText.test @@ -947,6 +947,12 @@ test canvText-20.1 {angled text bounding box} -setup { lassign $bbox a b c d list $b $a $d $c } + proc almosteq {b1 b2} { + # check whether the two boxes are equal, with 1 unit tolerance on each x y w h + lassign $b1 a b c d + lassign $b2 e f g h + expr {($e-$a)<=1 && ($f-$b)<=1 && ($g-$c)<=1 && ($h-$d)<=1} + } } -body { .c create text 2 2 -tag t -anchor center -text 0 -font {TkDefaultFont 24} set bb0 [.c bbox t] @@ -956,9 +962,9 @@ test canvText-20.1 {angled text bounding box} -setup { set bb2 [.c bbox t] .c itemconf t -angle 270 set bb3 [.c bbox t] - list [expr {$bb0 eq $bb2 ? "ok" : "$bb0,$bb2"}] \ - [expr {$bb1 eq $bb3 ? "ok" : "$bb1,$bb3"}] \ - [expr {$bb0 eq [transpose $bb1] ? "ok" : "$bb0,$bb1"}] \ + list [expr {[almosteq $bb0 $bb2] ? "ok" : "$bb0,$bb2"}] \ + [expr {[almosteq $bb1 $bb3] ? "ok" : "$bb1,$bb3"}] \ + [expr {[almosteq $bb0 [transpose $bb1]] ? "ok" : "$bb0,$bb1"}] } -cleanup { destroy .c rename transpose {} |