From 1133deb3a6d126d1b05927fa86e234232daf60f8 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 21 Sep 2016 17:31:06 +0300 Subject: [PATCH 1/3] Bug in Item3D::IsAboveBelow When calculating 'ol2' there must be 'ol1' instead of 'ow2' --- SourceFiles/Item3D.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SourceFiles/Item3D.cpp b/SourceFiles/Item3D.cpp index b80254f..c47ee39 100644 --- a/SourceFiles/Item3D.cpp +++ b/SourceFiles/Item3D.cpp @@ -126,7 +126,7 @@ bool Item3D::IsAboveBelow( item_t other ) double ow1 = other->getWLocation(); double ow2 = ow1 + other->side_1()->size() - 1; double ol1 = other->getLLocation(); - double ol2 = ow2 + other->side_3()->size() - 1; + double ol2 = ol1 + other->side_3()->size() - 1; // cout << mw1 <<" "<< mw2 <<" "<< ml1 <<" "<< ml2 <<"\n"<< From db2c534ef311e97c3fcb15d375f2e075edb3d77a Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 22 Sep 2016 10:57:01 +0300 Subject: [PATCH 2/3] Changes in AboveBelow test These changes allows IsAboveBelow bug to occur. --- unit_test/unit_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unit_test/unit_test.cpp b/unit_test/unit_test.cpp index c6f1071..59b1a32 100644 --- a/unit_test/unit_test.cpp +++ b/unit_test/unit_test.cpp @@ -204,21 +204,21 @@ TEST( AboveBelow ) i1->set_side_3( new Side( 3, 'l' ) ); i1->setWLocation(0); i1->setHLocation(0); - i1->setLLocation(0); + i1->setLLocation(7); std::shared_ptr i2( new Item3D() ); i2->set_side_1( new Side( 1, 'w' )); i2->set_side_2( new Side( 2, 'h' ) ); i2->set_side_3( new Side( 3, 'l' ) ); i2->setWLocation(0); i2->setHLocation(200); - i2->setLLocation(0); + i2->setLLocation(5); std::shared_ptr i3( new Item3D() ); i3->set_side_1( new Side( 1, 'w' )); i3->set_side_2( new Side( 2, 'h' ) ); i3->set_side_3( new Side( 3, 'l' ) ); i3->setWLocation(220); i3->setHLocation(0); - i3->setLLocation(0); + i3->setLLocation(5); std::shared_ptr bin( new Bin3D ); i1->setBin( bin->Root( bin )->progid() ); From a5d759eae812bd9dda671b470edc397995e5234c Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 23 Sep 2016 11:16:03 +0300 Subject: [PATCH 3/3] Add AboveBelowBug test 1) Made a roollback commit db2c534. 2) Add AboveBelowBug test which tests the fix in commit 1133deb --- unit_test/unit_test.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/unit_test/unit_test.cpp b/unit_test/unit_test.cpp index 59b1a32..faae36f 100644 --- a/unit_test/unit_test.cpp +++ b/unit_test/unit_test.cpp @@ -204,21 +204,21 @@ TEST( AboveBelow ) i1->set_side_3( new Side( 3, 'l' ) ); i1->setWLocation(0); i1->setHLocation(0); - i1->setLLocation(7); + i1->setLLocation(0); std::shared_ptr i2( new Item3D() ); i2->set_side_1( new Side( 1, 'w' )); i2->set_side_2( new Side( 2, 'h' ) ); i2->set_side_3( new Side( 3, 'l' ) ); i2->setWLocation(0); i2->setHLocation(200); - i2->setLLocation(5); + i2->setLLocation(0); std::shared_ptr i3( new Item3D() ); i3->set_side_1( new Side( 1, 'w' )); i3->set_side_2( new Side( 2, 'h' ) ); i3->set_side_3( new Side( 3, 'l' ) ); i3->setWLocation(220); i3->setHLocation(0); - i3->setLLocation(5); + i3->setLLocation(0); std::shared_ptr bin( new Bin3D ); i1->setBin( bin->Root( bin )->progid() ); @@ -269,6 +269,27 @@ TEST( OverlapArea ) CHECK_CLOSE( i3->AreaWidthLength() / 2, i3->OverlapArea( i2 ), 0.1 ); } + +TEST(AboveBelowBug) +{ + std::shared_ptr i1(new Item3D()); + i1->set_side_1(new Side(1, 'w')); + i1->set_side_2(new Side(2, 'h')); + i1->set_side_3(new Side(3, 'l')); + i1->setWLocation(0); + i1->setHLocation(0); + i1->setLLocation(7); + std::shared_ptr i2(new Item3D()); + i2->set_side_1(new Side(1, 'w')); + i2->set_side_2(new Side(2, 'h')); + i2->set_side_3(new Side(3, 'l')); + i2->setWLocation(0); + i2->setHLocation(200); + i2->setLLocation(5); + + CHECK(i1->IsAboveBelow(i2)); +} + int main(int argc, char *argv[]) { return raven::set::UnitTest::RunAllTests();