Supporting to_bytes and from_bytes also for the ..WithProperties types

This commit is contained in:
Matthias Koefferlein
2026-05-03 18:10:00 +02:00
parent 1de28f2d6b
commit 77fb74e072
4 changed files with 105 additions and 0 deletions
+14
View File
@@ -552,6 +552,20 @@ class DBBox_TestClass < TestBase
assert_equal(s.to_s, "(0,0;100,200) props={}")
assert_equal(s.property(1), nil)
# binary serialization
s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), {})
assert_equal(RBA::BoxWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::BoxWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
assert_equal(RBA::BoxWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), {})
assert_equal(RBA::DBoxWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::DBoxWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
assert_equal(RBA::DBoxWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
end
end
+18
View File
@@ -990,6 +990,24 @@ class DBPolygon_TestClass < TestBase
assert_equal(s.class.to_s, "RBA::DSimplePolygonWithProperties")
assert_equal(s.downcast.class.to_s, "RBA::DSimplePolygon")
# binary serialization
s = RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), {})
assert_equal(RBA::PolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::PolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
assert_equal(RBA::PolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::DPolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), {})
assert_equal(RBA::DPolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::DPolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
assert_equal(RBA::DPolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), {})
assert_equal(RBA::SimplePolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::SimplePolygonWithProperties::new(RBA::Box::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
assert_equal(RBA::SimplePolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::DSimplePolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), {})
assert_equal(RBA::DSimplePolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
s = RBA::DSimplePolygonWithProperties::new(RBA::DBox::new(0, 0, 100, 200), { 1 => "one", "key" => 17 })
assert_equal(RBA::DSimplePolygonWithProperties::from_bytes(s.to_bytes).to_s, s.to_s)
end
def test_triangulation