Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koefferlein committed Jan 5, 2024
1 parent f26fac5 commit f476416
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions testdata/ruby/dbTransTest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,37 @@ def test_5_CplxTrans_Hash

end

# Complex trans conversions, issue #1586
def test_6_CplxTransConversions

itrans = RBA::ICplxTrans::new(1.0, 0.0, false, RBA::Vector::new(1, 2))
vtrans = RBA::VCplxTrans::new(1000.0, 0.0, false, RBA::Vector::new(1, 2))
dtrans = RBA::DCplxTrans::new(1.0, 0.0, false, RBA::DVector::new(1, 2))
ctrans = RBA::CplxTrans::new(0.001, 0.0, false, RBA::DVector::new(1, 2))

assert_equal(RBA::ICplxTrans::new(vtrans, 0.001).to_s, "r0 *1 1,2")
assert_equal(RBA::ICplxTrans::new(dtrans, 0.001).to_s, "r0 *1 1000,2000")
assert_equal(RBA::ICplxTrans::new(ctrans, 0.001).to_s, "r0 *1 1000,2000")

assert_equal(RBA::VCplxTrans::new(itrans, 0.001).to_s, "r0 *1000 1,2")
assert_equal(RBA::VCplxTrans::new(dtrans, 0.001).to_s, "r0 *1000 1000,2000")
assert_equal(RBA::VCplxTrans::new(ctrans, 0.001).to_s, "r0 *1000 1000,2000")

assert_equal(RBA::DCplxTrans::new(itrans, 0.001).to_s, "r0 *1 0.001,0.002")
assert_equal(RBA::DCplxTrans::new(vtrans, 0.001).to_s, "r0 *1 0.001,0.002")
assert_equal(RBA::DCplxTrans::new(ctrans, 0.001).to_s, "r0 *1 1,2")

assert_equal(RBA::CplxTrans::new(itrans, 0.001).to_s, "r0 *0.001 0.001,0.002")
assert_equal(RBA::CplxTrans::new(vtrans, 0.001).to_s, "r0 *0.001 0.001,0.002")
assert_equal(RBA::CplxTrans::new(dtrans, 0.001).to_s, "r0 *0.001 1,2")

# issue #1586 (NOTE: to_itrans is deprecated)
t = RBA::DCplxTrans::new(1.0, 45.0, false, 12.345678, 20.000000)
assert_equal(t.to_itrans(0.001).to_s, "r45 *1 12345.678,20000")
assert_equal(RBA::ICplxTrans::new(t, 0.001).to_s, "r45 *1 12345.678,20000")

end

end

load("test_epilogue.rb")

0 comments on commit f476416

Please sign in to comment.