From 394947df722452e1ab2fca1ffec9cf4f248953aa Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 20 Aug 2017 23:59:06 +0200 Subject: [PATCH] Segfault fixed in RecursiveShapeIterator The RSI does no longer segfault when the default one gets reset. --- src/db/dbRecursiveShapeIterator.cc | 2 +- src/unit_tests/dbRecursiveShapeIterator.cc | 156 ++++++++++++++++++++- 2 files changed, 156 insertions(+), 2 deletions(-) diff --git a/src/db/dbRecursiveShapeIterator.cc b/src/db/dbRecursiveShapeIterator.cc index 65334c4ce..63774e08c 100644 --- a/src/db/dbRecursiveShapeIterator.cc +++ b/src/db/dbRecursiveShapeIterator.cc @@ -425,7 +425,7 @@ RecursiveShapeIterator::validate () const // TODO: get rid of that const cast (const_cast (mp_shapes))->update (); start_shapes (); - } else if (! m_has_layers || m_current_layer < m_layers.size ()) { + } else if (mp_layout && (! m_has_layers || m_current_layer < m_layers.size ())) { // Ensures the trees are built properly - this is important in MT contexts (i.e. TilingProcessor) mp_layout->update (); new_cell (); diff --git a/src/unit_tests/dbRecursiveShapeIterator.cc b/src/unit_tests/dbRecursiveShapeIterator.cc index ce35e60cc..f5dd5532d 100644 --- a/src/unit_tests/dbRecursiveShapeIterator.cc +++ b/src/unit_tests/dbRecursiveShapeIterator.cc @@ -57,6 +57,12 @@ std::string collect(db::RecursiveShapeIterator &s, const db::Layout &layout, boo return res; } +std::string collect_with_copy(db::RecursiveShapeIterator s, const db::Layout &layout, bool with_layer = false) +{ + s.reset (); + return collect (s, layout, with_layer); +} + TEST(1) { db::Manager m; @@ -67,8 +73,14 @@ TEST(1) db::Cell &c0 (g.cell (g.add_cell ())); + db::RecursiveShapeIterator idef; + EXPECT_EQ (idef.at_end (), true); + EXPECT_EQ (collect (idef, g), ""); + EXPECT_EQ (collect_with_copy (idef, g), ""); + db::RecursiveShapeIterator i00 (g, c0, 0, db::Box (0, 0, 100, 100)); EXPECT_EQ (collect (i00, g), ""); + EXPECT_EQ (collect_with_copy (i00, g), ""); db::Cell &c1 (g.cell (g.add_cell ())); db::Cell &c2 (g.cell (g.add_cell ())); @@ -76,6 +88,7 @@ TEST(1) db::RecursiveShapeIterator i0 (g, c0, 0, db::Box (0, 0, 100, 100)); EXPECT_EQ (collect (i0, g), ""); + EXPECT_EQ (collect_with_copy (i0, g), ""); db::Box b (0, 100, 1000, 1200); c0.shapes (0).insert (b); @@ -97,58 +110,84 @@ TEST(1) db::RecursiveShapeIterator i1 (g, c0, 0, db::Box (0, 0, 100, 100)); x = collect(i1, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); + x = collect_with_copy(i1, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); db::RecursiveShapeIterator i1_1inf (g, c0, 0, db::Box (0, 0, 100, 100)); i1_1inf.min_depth(1); x = collect(i1_1inf, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); + x = collect_with_copy(i1_1inf, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); db::RecursiveShapeIterator i1_11 (g, c0, 0, db::Box (0, 0, 100, 100)); i1_11.min_depth(1); i1_11.max_depth(1); x = collect(i1_11, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); + x = collect_with_copy(i1_11, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); db::RecursiveShapeIterator i1_12 (g, c0, 0, db::Box (0, 0, 100, 100)); i1_12.min_depth(1); i1_12.max_depth(2); x = collect(i1_12, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); + x = collect_with_copy(i1_12, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); db::RecursiveShapeIterator i1_22 (g, c0, 0, db::Box (0, 0, 100, 100)); i1_22.min_depth(2); i1_22.max_depth(2); x = collect(i1_22, g); EXPECT_EQ (x, ""); + x = collect_with_copy(i1_22, g); + EXPECT_EQ (x, ""); db::RecursiveShapeIterator i1o (g, c0, 0, db::Box (0, 0, 100, 100), true); x = collect(i1o, g); EXPECT_EQ (x, ""); + x = collect_with_copy(i1o, g); + EXPECT_EQ (x, ""); i1o = db::RecursiveShapeIterator (g, c0, 0, db::Box (0, 0, 100, 101), true); x = collect(i1o, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)"); + x = collect_with_copy(i1o, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)"); i1o = db::RecursiveShapeIterator (g, c0, 0, db::Box (0, 0, 101, 101), true); x = collect(i1o, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); + x = collect_with_copy(i1o, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); db::RecursiveShapeIterator i2 (g, c0, 0, db::Box (-100, 0, 100, 100)); db::RecursiveShapeIterator i2c = i2; x = collect(i2, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(i2, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); x = collect(i2c, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(i2c, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); db::RecursiveShapeIterator i2o (g, c0, 0, db::Box (-100, 0, 100, 100), true); x = collect(i2o, g); EXPECT_EQ (x, ""); + x = collect_with_copy(i2o, g); + EXPECT_EQ (x, ""); i2o = db::RecursiveShapeIterator (g, c0, 0, db::Box (-101, 0, 101, 101), true); x = collect(i2o, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(i2o, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); db::RecursiveShapeIterator i4 (g, c0, 0, db::Box (-100, 0, 2000, 100)); db::RecursiveShapeIterator i4_copy (g, c0, 0, db::Box (-100, 0, 2000, 100)); i4.max_depth (0); x = collect(i4, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)"); + x = collect_with_copy(i4, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)"); EXPECT_EQ (i4 == i4, true); EXPECT_EQ (i4 != i4, false); @@ -160,14 +199,20 @@ TEST(1) i4.max_depth (1); x = collect(i4, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(i4, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); i4 = i4_copy; x = collect(i4, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(i4, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); db::RecursiveShapeIterator i5 (g, c0, 0, db::Box::world ()); x = collect(i5, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(i5, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); std::set cc; db::RecursiveShapeIterator ii; @@ -179,13 +224,19 @@ TEST(1) ii.select_cells (cc); x = collect(ii, g); EXPECT_EQ (x, "[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); ii.reset (); x = collect(ii, g); EXPECT_EQ (x, "[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); ii.reset_selection (); x = collect(ii, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); ii.reset_selection (); cc.clear (); @@ -197,6 +248,8 @@ TEST(1) ii.select_cells (cc); x = collect(ii, g); EXPECT_EQ (x, "[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)"); ii = db::RecursiveShapeIterator (g, c0, 0, db::Box::world ()); ii.unselect_all_cells (); @@ -206,6 +259,8 @@ TEST(1) ii.select_cells (cc); x = collect(ii, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); ii = db::RecursiveShapeIterator (g, c0, 0, db::Box::world ()); ii.unselect_all_cells (); @@ -215,40 +270,58 @@ TEST(1) ii.select_cells (cc); x = collect(ii, g); EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[$1](0,100;1000,1200)/[$2](0,100;1000,1200)"); // Shapes iterators ii = db::RecursiveShapeIterator (c0.shapes (0)); x = collect(ii, g); EXPECT_EQ (x, "[](0,100;1000,1200)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[](0,100;1000,1200)"); ii = db::RecursiveShapeIterator (c0.shapes (0), db::Box (0, 0, 10, 10)); x = collect(ii, g); EXPECT_EQ (x, ""); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, ""); ii.set_region (db::Box (0, 100, 0, 110)); x = collect(ii, g); EXPECT_EQ (x, "[](0,100;1000,1200)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[](0,100;1000,1200)"); ii = db::RecursiveShapeIterator (c0.shapes (1), db::Box::world ()); x = collect(ii, g); EXPECT_EQ (x, ""); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, ""); ii = db::RecursiveShapeIterator (c0.shapes (2), db::Box::world ()); x = collect(ii, g); EXPECT_EQ (x, "[](0,100;1000,1200)/[](50,150;1050,1250)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[](0,100;1000,1200)/[](50,150;1050,1250)"); ii = db::RecursiveShapeIterator (c0.shapes (2), db::Box (0, 0, 100, 100)); x = collect(ii, g); EXPECT_EQ (x, "[](0,100;1000,1200)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[](0,100;1000,1200)"); ii.set_overlapping (true); x = collect(ii, g); EXPECT_EQ (x, ""); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, ""); ii.set_region (db::Box (0, 0, 101, 101)); x = collect(ii, g); EXPECT_EQ (x, "[](0,100;1000,1200)"); + x = collect_with_copy(ii, g); + EXPECT_EQ (x, "[](0,100;1000,1200)"); } TEST(1a) @@ -279,36 +352,54 @@ TEST(1a) std::string x; db::RecursiveShapeIterator i0 (g, c0, 0, db::Box ()); + x = collect_with_copy(i0, g); + EXPECT_EQ (x, ""); x = collect(i0, g); EXPECT_EQ (x, ""); db::RecursiveShapeIterator i1 (g, c0, 0, db::Box (0, 0, 100, 100)); + x = collect_with_copy(i1, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); x = collect(i1, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); db::RecursiveShapeIterator i1o (g, c0, 0, db::Box (0, 0, 100, 100), true); + x = collect_with_copy(i1o, g); + EXPECT_EQ (x, ""); x = collect(i1o, g); EXPECT_EQ (x, ""); i1o = db::RecursiveShapeIterator (g, c0, 0, db::Box (0, 0, 100, 101), true); + x = collect_with_copy(i1o, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)"); x = collect(i1o, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)"); i1o = db::RecursiveShapeIterator (g, c0, 0, db::Box (0, 0, 101, 101), true); + x = collect_with_copy(i1o, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); x = collect(i1o, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)"); db::RecursiveShapeIterator i2 (g, c0, 0, db::Box (-100, 0, 100, 100)); + x = collect_with_copy(i2, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); x = collect(i2, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); db::RecursiveShapeIterator i2o (g, c0, 0, db::Box (-100, 0, 100, 100), true); + x = collect_with_copy(i2o, g); + EXPECT_EQ (x, ""); x = collect(i2o, g); EXPECT_EQ (x, ""); i2o = db::RecursiveShapeIterator (g, c0, 0, db::Box (-101, 0, 101, 101), true); + x = collect_with_copy(i2o, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); x = collect(i2o, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); db::RecursiveShapeIterator i4 (g, c0, 0, db::Box (-100, 0, 2000, 100)); db::RecursiveShapeIterator i4_copy (g, c0, 0, db::Box (-100, 0, 2000, 100)); i4.max_depth (0); + x = collect_with_copy(i4, g); + EXPECT_EQ (x, ""); x = collect(i4, g); EXPECT_EQ (x, ""); @@ -320,33 +411,47 @@ TEST(1a) EXPECT_EQ (i4 == i4_copy, true); EXPECT_EQ (i4 != i4_copy, false); i4.max_depth (1); + x = collect_with_copy(i4, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); x = collect(i4, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](-1200,0;-100,1000)"); i4 = i4_copy; + x = collect_with_copy(i4, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); x = collect(i4, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); db::RecursiveShapeIterator i5 (g, c0, 0, db::Box::world ()); + x = collect_with_copy(i5, g); + EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); x = collect(i5, g); EXPECT_EQ (x, "[$2](0,100;1000,1200)/[$3](100,0;1100,1100)/[$4](1200,0;2200,1100)/[$4](-1200,0;-100,1000)"); std::set ll; db::RecursiveShapeIterator i5a (g, c0, ll, db::Box::world ()); + x = collect_with_copy(i5a, g, true); + EXPECT_EQ (x, ""); x = collect(i5a, g, true); EXPECT_EQ (x, ""); ll.insert (0); db::RecursiveShapeIterator i5b (g, c0, ll, db::Box::world ()); + x = collect_with_copy(i5b, g, true); + EXPECT_EQ (x, "[$2](0,100;1000,1200)*0/[$3](100,0;1100,1100)*0/[$4](1200,0;2200,1100)*0/[$4](-1200,0;-100,1000)*0"); x = collect(i5b, g, true); EXPECT_EQ (x, "[$2](0,100;1000,1200)*0/[$3](100,0;1100,1100)*0/[$4](1200,0;2200,1100)*0/[$4](-1200,0;-100,1000)*0"); ll.insert (1); db::RecursiveShapeIterator i5c (g, c0, ll, db::Box::world ()); db::RecursiveShapeIterator i5cc = i5c; + x = collect_with_copy(i5c, g, true); + EXPECT_EQ (x, "[$2](0,100;1000,1200)*0/[$3](100,0;1100,1100)*0/[$3](101,1;1101,1101)*1/[$4](1200,0;2200,1100)*0/[$4](-1200,0;-100,1000)*0"); x = collect(i5c, g, true); EXPECT_EQ (x, "[$2](0,100;1000,1200)*0/[$3](100,0;1100,1100)*0/[$3](101,1;1101,1101)*1/[$4](1200,0;2200,1100)*0/[$4](-1200,0;-100,1000)*0"); + x = collect_with_copy(i5cc, g, true); + EXPECT_EQ (x, "[$2](0,100;1000,1200)*0/[$3](100,0;1100,1100)*0/[$3](101,1;1101,1101)*1/[$4](1200,0;2200,1100)*0/[$4](-1200,0;-100,1000)*0"); x = collect(i5cc, g, true); EXPECT_EQ (x, "[$2](0,100;1000,1200)*0/[$3](100,0;1100,1100)*0/[$3](101,1;1101,1101)*1/[$4](1200,0;2200,1100)*0/[$4](-1200,0;-100,1000)*0"); } @@ -374,10 +479,15 @@ TEST(1b) c0.insert (db::CellInstArray (db::CellInst (c1.cell_index ()), tt)); db::RecursiveShapeIterator i (g, c0, 0, db::Box (1000000, 1000000, 10001000, 10001000)); - std::string x = collect(i, g); + std::string x; + x = collect_with_copy(i, g); + EXPECT_EQ (x, "[$2](1998000,0;2000000,2000000)/[$2](0,1998000;2000000,2000000)/[$2](1998000,0;2000000,2000000)/[$2](0,1998000;2000000,2000000)"); + x = collect(i, g); EXPECT_EQ (x, "[$2](1998000,0;2000000,2000000)/[$2](0,1998000;2000000,2000000)/[$2](1998000,0;2000000,2000000)/[$2](0,1998000;2000000,2000000)"); db::RecursiveShapeIterator i2 (g, c0, 0, db::Box (1000000, 1000000, 1001000, 1001000)); + x = collect_with_copy(i2, g); + EXPECT_EQ (x, ""); x = collect(i2, g); EXPECT_EQ (x, ""); } @@ -406,22 +516,32 @@ TEST(2) EXPECT_EQ (x, ""); db::RecursiveShapeIterator i (g, c0, 0, db::Box::world ()); + x = collect_with_copy(i, g); + EXPECT_EQ (x, "[$3](1000,-500;2000,500)/[$3](1000,1500;2000,2500)/[$3](4000,500;5000,1500)/[$3](4000,2500;5000,3500)/[$3](1000,5500;2000,6500)/[$3](1000,7500;2000,8500)/[$3](4000,6500;5000,7500)/[$3](4000,8500;5000,9500)/[$3](7000,-500;8000,500)/[$3](7000,1500;8000,2500)/[$3](10000,500;11000,1500)/[$3](10000,2500;11000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)/[$3](10000,8500;11000,9500)"); x = collect(i, g); EXPECT_EQ (x, "[$3](1000,-500;2000,500)/[$3](1000,1500;2000,2500)/[$3](4000,500;5000,1500)/[$3](4000,2500;5000,3500)/[$3](1000,5500;2000,6500)/[$3](1000,7500;2000,8500)/[$3](4000,6500;5000,7500)/[$3](4000,8500;5000,9500)/[$3](7000,-500;8000,500)/[$3](7000,1500;8000,2500)/[$3](10000,500;11000,1500)/[$3](10000,2500;11000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)/[$3](10000,8500;11000,9500)"); db::RecursiveShapeIterator i2 (g, c0, 0, db::Box (3400, 3450, 5600, 6500)); + x = collect_with_copy(i2, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](4000,6500;5000,7500)"); x = collect(i2, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](4000,6500;5000,7500)"); db::RecursiveShapeIterator i3 (g, c0, 0, db::Box (6650, 5300, 10000, 7850)); + x = collect_with_copy(i3, g); + EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)"); x = collect(i3, g); EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)"); db::RecursiveShapeIterator i2o (g, c0, 0, db::Box (3400, 3450, 5600, 6500), true); + x = collect_with_copy(i2o, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); x = collect(i2o, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); db::RecursiveShapeIterator i3o (g, c0, 0, db::Box (6650, 5300, 10000, 7850), true); + x = collect_with_copy(i3o, g); + EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); x = collect(i3o, g); EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); } @@ -446,16 +566,22 @@ TEST(3) std::string x; db::RecursiveShapeIterator i (g, c0, 0, db::Box::world ()); + x = collect_with_copy(i, g); + EXPECT_EQ (x, "[$3](1000,-500;2000,500)/[$3](1000,1500;2000,2500)/[$3](4000,500;5000,1500)/[$3](4000,2500;5000,3500)/[$3](1000,5500;2000,6500)/[$3](1000,7500;2000,8500)/[$3](4000,6500;5000,7500)/[$3](4000,8500;5000,9500)/[$3](7000,-500;8000,500)/[$3](7000,1500;8000,2500)/[$3](10000,500;11000,1500)/[$3](10000,2500;11000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)/[$3](10000,8500;11000,9500)"); x = collect(i, g); EXPECT_EQ (x, "[$3](1000,-500;2000,500)/[$3](1000,1500;2000,2500)/[$3](4000,500;5000,1500)/[$3](4000,2500;5000,3500)/[$3](1000,5500;2000,6500)/[$3](1000,7500;2000,8500)/[$3](4000,6500;5000,7500)/[$3](4000,8500;5000,9500)/[$3](7000,-500;8000,500)/[$3](7000,1500;8000,2500)/[$3](10000,500;11000,1500)/[$3](10000,2500;11000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)/[$3](10000,8500;11000,9500)"); db::RecursiveShapeIterator i2 (g, c0, 0, db::Region (db::Box (3400, 3450, 5600, 6500))); EXPECT_EQ (i2.has_complex_region (), false); EXPECT_EQ (i2.region ().to_string (), "(3400,3450;5600,6500)"); + x = collect_with_copy(i2, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](4000,6500;5000,7500)"); x = collect(i2, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](4000,6500;5000,7500)"); db::RecursiveShapeIterator i3 (g, c0, 0, db::Region (db::Box (6650, 5300, 10000, 7850))); + x = collect_with_copy(i3, g); + EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)"); x = collect(i3, g); EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)"); @@ -464,14 +590,20 @@ TEST(3) rr.insert (db::Box (6650, 5300, 10000, 7850)); db::RecursiveShapeIterator i23 (g, c0, 0, rr); + x = collect_with_copy(i23, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](4000,6500;5000,7500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)"); x = collect(i23, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](4000,6500;5000,7500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)/[$3](10000,6500;11000,7500)"); db::RecursiveShapeIterator i2o (g, c0, 0, db::Region (db::Box (3400, 3450, 5600, 6500)), true); + x = collect_with_copy(i2o, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); x = collect(i2o, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); db::RecursiveShapeIterator i3o (g, c0, 0, db::Region (db::Box (6650, 5300, 10000, 7850)), true); + x = collect_with_copy(i3o, g); + EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); x = collect(i3o, g); EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); @@ -485,20 +617,28 @@ TEST(3) db::RecursiveShapeIterator i23ocopy = i23o; + x = collect_with_copy(i23o, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); x = collect(i23o, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); + x = collect_with_copy (i23ocopy, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); x = collect (i23ocopy, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); // reset i23o.reset (); + x = collect_with_copy (i23o, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); x = collect (i23o, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); // copy constructor i23ocopy = i23o; i23ocopy.reset (); + x = collect_with_copy (i23ocopy, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); x = collect (i23ocopy, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); @@ -506,6 +646,8 @@ TEST(3) db::Region rg; i23o.set_region (rg); + x = collect_with_copy(i23o, g); + EXPECT_EQ (x, ""); x = collect(i23o, g); EXPECT_EQ (x, ""); @@ -513,31 +655,43 @@ TEST(3) rg.insert (db::Box (16650, 5300, 20000, 7850)); i23o.set_region (rg); + x = collect_with_copy(i23o, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); x = collect(i23o, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); i23o.set_region (db::Box (6650, 5300, 10000, 7850)); + x = collect_with_copy(i23o, g); + EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); x = collect(i23o, g); EXPECT_EQ (x, "[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); // region confinement i23o.confine_region (db::Box (3400, 3450, 5600, 6500)); + x = collect_with_copy(i23o, g); + EXPECT_EQ (x, ""); x = collect(i23o, g); EXPECT_EQ (x, ""); i23o.set_region (rro); i23o.confine_region (db::Box (3400, 3450, 5600, 6500)); + x = collect_with_copy(i23o, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); x = collect(i23o, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); i23o.set_region (db::Box (3400, 3450, 5600, 6500)); i23o.confine_region (rro); + x = collect_with_copy(i23o, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); x = collect(i23o, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)"); i23o.set_region (rro); i23o.confine_region (rro); + x = collect_with_copy(i23o, g); + EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); x = collect(i23o, g); EXPECT_EQ (x, "[$3](4000,2500;5000,3500)/[$3](7000,5500;8000,6500)/[$3](7000,7500;8000,8500)"); }