mirror of https://github.com/KLayout/klayout.git
Added unit tests for RBA::Annotation. Plus fixed a bug in the compare function.
This commit is contained in:
parent
d0427184e4
commit
e30f1b6a34
|
|
@ -190,6 +190,7 @@ Object::operator== (const ant::Object &d) const
|
|||
m_fmt_x == d.m_fmt_x && m_fmt_y == d.m_fmt_y && m_fmt == d.m_fmt &&
|
||||
m_style == d.m_style && m_outline == d.m_outline &&
|
||||
m_snap == d.m_snap && m_angle_constraint == d.m_angle_constraint &&
|
||||
m_category == d.m_category &&
|
||||
m_main_position == d.m_main_position &&
|
||||
m_main_xalign == d.m_main_xalign && m_main_yalign == d.m_main_yalign &&
|
||||
m_xlabel_xalign == d.m_xlabel_xalign && m_xlabel_yalign == d.m_xlabel_yalign &&
|
||||
|
|
|
|||
|
|
@ -18,9 +18,115 @@ def annot_obj( p1, p2, fmt, fmt_x, fmt_y, style, outline, snap, ac )
|
|||
end
|
||||
|
||||
class RBA::Annotation
|
||||
def style_to_s(s)
|
||||
if s == StyleRuler
|
||||
"ruler"
|
||||
elsif s == StyleArrowEnd
|
||||
"arrow_end"
|
||||
elsif s == StyleArrowStart
|
||||
"arrow_start"
|
||||
elsif s == StyleArrowBoth
|
||||
"arrow_both"
|
||||
elsif s == StyleLine
|
||||
"line"
|
||||
elsif s == StyleCrossEnd
|
||||
"cross_end"
|
||||
elsif s == StyleCrossStart
|
||||
"cross_start"
|
||||
elsif s == StyleCrossBoth
|
||||
"cross_both"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
def outline_to_s(s)
|
||||
if s == OutlineDiag
|
||||
"diag"
|
||||
elsif s == OutlineXY
|
||||
"xy"
|
||||
elsif s == OutlineDiagXY
|
||||
"diag_xy"
|
||||
elsif s == OutlineYX
|
||||
"yx"
|
||||
elsif s == OutlineDiagYX
|
||||
"diag_yx"
|
||||
elsif s == OutlineBox
|
||||
"diag_box"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
def ac_to_s(s)
|
||||
if s == AngleAny
|
||||
"any"
|
||||
elsif s == AngleDiagonal
|
||||
"diagonal"
|
||||
elsif s == AngleOrtho
|
||||
"ortho"
|
||||
elsif s == AngleHorizontal
|
||||
"horizontal"
|
||||
elsif s == AngleVertical
|
||||
"vertical"
|
||||
elsif s == AngleGlobal
|
||||
"global"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
def pos_to_s(s)
|
||||
if s == PositionAuto
|
||||
"auto"
|
||||
elsif s == PositionP1
|
||||
"p1"
|
||||
elsif s == PositionP2
|
||||
"p2"
|
||||
elsif s == PositionCenter
|
||||
"center"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
def align_to_s(s)
|
||||
if s == AlignAuto
|
||||
"auto"
|
||||
elsif s == AlignCenter
|
||||
"center"
|
||||
elsif s == AlignUp
|
||||
"up"
|
||||
elsif s == AlignDown
|
||||
"down"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
def to_s
|
||||
"p1=" + p1.to_s + ", p2=" + p2.to_s + ", fmt=" + fmt + ", fmt_x=" + fmt_x + ", fmt_y=" + fmt_y +
|
||||
", style=" + style.to_s + ", outline=" + outline.to_s + ", snap=" + snap?.to_s + ", ac=" + angle_constraint.to_s
|
||||
s = "p1=" + p1.to_s + ", p2=" + p2.to_s + ", fmt=" + fmt + ", fmt_x=" + fmt_x + ", fmt_y=" + fmt_y +
|
||||
", style=" + self.style_to_s(style) + ", outline=" + self.outline_to_s(outline) + ", snap=" + snap?.to_s + ", ac=" + self.ac_to_s(angle_constraint)
|
||||
if category != ""
|
||||
s += ", category=" + self.category
|
||||
end
|
||||
if main_position != PositionAuto
|
||||
s += ", main_position=" + self.pos_to_s(main_position)
|
||||
end
|
||||
if main_xalign != AlignAuto
|
||||
s += ", main_xalign=" + self.align_to_s(main_xalign)
|
||||
end
|
||||
if main_yalign != AlignAuto
|
||||
s += ", main_yalign=" + self.align_to_s(main_yalign)
|
||||
end
|
||||
if xlabel_xalign != AlignAuto
|
||||
s += ", xlabel_xalign=" + self.align_to_s(xlabel_xalign)
|
||||
end
|
||||
if xlabel_yalign != AlignAuto
|
||||
s += ", xlabel_yalign=" + self.align_to_s(xlabel_yalign)
|
||||
end
|
||||
if ylabel_xalign != AlignAuto
|
||||
s += ", ylabel_xalign=" + self.align_to_s(ylabel_xalign)
|
||||
end
|
||||
if ylabel_yalign != AlignAuto
|
||||
s += ", ylabel_yalign=" + self.align_to_s(ylabel_yalign)
|
||||
end
|
||||
s
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -30,13 +136,13 @@ class Ant_TestClass < TestBase
|
|||
def test_1
|
||||
|
||||
a = RBA::Annotation::new
|
||||
assert_equal( a.to_s, "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=0, outline=0, snap=true, ac=5" )
|
||||
assert_equal( a.to_s, "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global" )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
b = a.dup
|
||||
assert_equal( b.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( b.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
a = RBA::Annotation::new
|
||||
|
||||
assert_equal( a == b, false )
|
||||
|
|
@ -47,10 +153,10 @@ class Ant_TestClass < TestBase
|
|||
assert_equal( a != b, false )
|
||||
|
||||
c = a.transformed( RBA::DTrans::new( RBA::DPoint::new( 10.0, 20.0 ) ) )
|
||||
assert_equal( c.to_s, "p1=11,22, p2=13,24, fmt=a, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( c.to_s, "p1=11,22, p2=13,24, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
c = a.transformed_cplx( RBA::DCplxTrans::new( RBA::DTrans::new( RBA::DPoint::new( 11.0, 22.0 ) ) ) )
|
||||
assert_equal( c.to_s, "p1=12,24, p2=14,26, fmt=a, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( c.to_s, "p1=12,24, p2=14,26, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
a.fmt = "X=$X,Y=$Y,D=$D,A=$A,P=$P,Q=$Q,U=$U,V=$V"
|
||||
a.fmt_x = "$(X*1000)+$(Y*1e3)"
|
||||
|
|
@ -58,6 +164,204 @@ class Ant_TestClass < TestBase
|
|||
assert_equal( a.text_x, "2000+2000" )
|
||||
assert_equal( a.text_y, "c" )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.category = "abc"
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, category=abc" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.main_position = RBA::Annotation::PositionP1
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, main_position=p1" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.main_position = RBA::Annotation::PositionP2
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, main_position=p2" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.main_position = RBA::Annotation::PositionCenter
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, main_position=center" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.main_xalign = RBA::Annotation::AlignCenter
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, main_xalign=center" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.main_xalign = RBA::Annotation::AlignLeft
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, main_xalign=down" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.main_xalign = RBA::Annotation::AlignRight
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, main_xalign=up" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.main_yalign = RBA::Annotation::AlignCenter
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, main_yalign=center" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.main_yalign = RBA::Annotation::AlignLeft
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, main_yalign=down" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.main_yalign = RBA::Annotation::AlignRight
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, main_yalign=up" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.xlabel_xalign = RBA::Annotation::AlignCenter
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, xlabel_xalign=center" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.xlabel_xalign = RBA::Annotation::AlignLeft
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, xlabel_xalign=down" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.xlabel_xalign = RBA::Annotation::AlignRight
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, xlabel_xalign=up" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.xlabel_yalign = RBA::Annotation::AlignCenter
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, xlabel_yalign=center" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.xlabel_yalign = RBA::Annotation::AlignLeft
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, xlabel_yalign=down" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.xlabel_yalign = RBA::Annotation::AlignRight
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, xlabel_yalign=up" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.ylabel_xalign = RBA::Annotation::AlignCenter
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, ylabel_xalign=center" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.ylabel_xalign = RBA::Annotation::AlignLeft
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, ylabel_xalign=down" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.ylabel_xalign = RBA::Annotation::AlignRight
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, ylabel_xalign=up" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.ylabel_yalign = RBA::Annotation::AlignCenter
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, ylabel_yalign=center" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.ylabel_yalign = RBA::Annotation::AlignLeft
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, ylabel_yalign=down" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 )
|
||||
assert_equal( a.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
aa = a.dup
|
||||
aa.ylabel_yalign = RBA::Annotation::AlignRight
|
||||
assert_equal( aa.to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal, ylabel_yalign=up" )
|
||||
assert_equal( a == aa, false )
|
||||
a = aa.dup
|
||||
assert_equal( a == aa, true )
|
||||
|
||||
end
|
||||
|
||||
# Test LayoutView integration
|
||||
|
|
@ -89,11 +393,11 @@ class Ant_TestClass < TestBase
|
|||
assert_equal( a.is_valid?, true )
|
||||
assert_equal( lv.annotation( -1 ).is_valid?, false )
|
||||
assert_equal( lv.annotation( a.id ).is_valid?, true )
|
||||
assert_equal( lv.annotation( a.id ).to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( lv.annotation( a.id ).to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
arr = []
|
||||
lv.each_annotation { |a| arr.push( a.to_s ) }
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=0, outline=0, snap=true, ac=5;p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global;p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
id = nil
|
||||
lv.each_annotation { |a| id = a.id }
|
||||
|
|
@ -114,13 +418,13 @@ class Ant_TestClass < TestBase
|
|||
|
||||
arr = []
|
||||
lv.each_annotation { |a| arr.push( a.to_s ) }
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=0, outline=0, snap=true, ac=5;p1=1,2, p2=3,4, fmt=u, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global;p1=1,2, p2=3,4, fmt=u, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
lv.erase_annotation(id)
|
||||
|
||||
arr = []
|
||||
lv.each_annotation { |a| arr.push( a.to_s ) }
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=0, outline=0, snap=true, ac=5" )
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global" )
|
||||
|
||||
lv.clear_annotations
|
||||
|
||||
|
|
@ -148,19 +452,19 @@ class Ant_TestClass < TestBase
|
|||
|
||||
arr = []
|
||||
lv.each_annotation { |x| arr.push( x.to_s ) }
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=0, outline=0, snap=true, ac=5;p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global;p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
a.fmt = "u"
|
||||
|
||||
arr = []
|
||||
lv.each_annotation { |a| arr.push( a.to_s ) }
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=0, outline=0, snap=true, ac=5;p1=1,2, p2=3,4, fmt=u, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global;p1=1,2, p2=3,4, fmt=u, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
a.delete
|
||||
|
||||
arr = []
|
||||
lv.each_annotation { |a| arr.push( a.to_s ) }
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=0, outline=0, snap=true, ac=5" )
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global" )
|
||||
|
||||
a0.delete
|
||||
|
||||
|
|
@ -176,13 +480,13 @@ class Ant_TestClass < TestBase
|
|||
|
||||
arr = []
|
||||
lv.each_annotation { |x| arr.push( x.to_s ) }
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=0, outline=0, snap=true, ac=5;p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=$D, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global;p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
lv.each_annotation { |x| x.fmt = "q" }
|
||||
|
||||
arr = []
|
||||
lv.each_annotation { |x| arr.push( x.to_s ) }
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=q, fmt_x=$X, fmt_y=$Y, style=0, outline=0, snap=true, ac=5;p1=1,2, p2=3,4, fmt=q, fmt_x=b, fmt_y=c, style=1, outline=2, snap=false, ac=3" )
|
||||
assert_equal( arr.join( ";" ), "p1=0,0, p2=0,0, fmt=q, fmt_x=$X, fmt_y=$Y, style=ruler, outline=diag, snap=true, ac=global;p1=1,2, p2=3,4, fmt=q, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal" )
|
||||
|
||||
lv.each_annotation { |x| x.delete }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue