Commit ffeadb7b authored by karthik's avatar karthik

edit WhichSide() test

parent a82f1f94
......@@ -228,8 +228,8 @@ BOOST_AUTO_TEST_CASE(Line_hor_vert_test)
BOOST_AUTO_TEST_CASE(Line_whichSide_test)
{
BOOST_MESSAGE("starting line which side test");
Point Pleft(-20, 2);
Point Pright(20, 2);
Point Pleft(-2, 2);
Point Pright(2, -2);
const double Pi = 3.14159265358979323846;
BOOST_CHECK(Line(Point(0,-2), Point(0,1)).WichSide(Pleft) == 0);
......@@ -237,16 +237,18 @@ BOOST_AUTO_TEST_CASE(Line_whichSide_test)
BOOST_CHECK(Line(Point(0,-2), Point(0,1)).WichSide(Pright) == 1);
BOOST_CHECK(Line(Point(0,-2), Point(0,1)).IsLeft(Pright) == false);
for (int i = 0; i <= 6; ++i) { // including horizontal lines
for (int i = 0; i <= 3; ++i) { // including horizontal lines
Line L1(Point(0, 0), Point(cos(i*Pi/6), sin(i*Pi/6)));
BOOST_CHECK_MESSAGE(L1.WichSide(Pleft) == 0, L1.WichSide(Pleft) << " Pt:(-20,2), LINE: (0,0), (" <<
BOOST_CHECK_MESSAGE(L1.WichSide(Pleft) == 0,"L1.WichSide(Pleft): " << L1.WichSide(Pleft) << " Pt:(-2,2), LINE: (0,0), (" <<
cos(i*Pi/6) << "," << sin(i*Pi/6) << ")");
BOOST_CHECK_MESSAGE(L1.IsLeft(Pleft) == true, "L1.IsLeft(Pleft): " << L1.IsLeft(Pleft) << " Pt:(-2,2), LINE: (0,0), (" <<
cos(i*Pi/6) << "," << sin(i*Pi/6) << ")");
BOOST_CHECK(L1.IsLeft(Pleft) == true);
BOOST_CHECK_MESSAGE(L1.WichSide(Pright) == 1, L1.WichSide(Pright)<< " Pt:(20,2), LINE: (0,0), (" <<
BOOST_CHECK_MESSAGE(L1.WichSide(Pright) == 1, "L1.WichSide(Pright): " << L1.WichSide(Pright)<< " Pt:(2,2), LINE: (0,0), (" <<
cos(i*Pi/6) << "," << sin(i*Pi/6) << ")");
BOOST_CHECK_MESSAGE(L1.IsLeft(Pright) == false, "L1.IsLeft(Pright): " << L1.IsLeft(Pright) << " Pt:(2,2), LINE: (0,0), (" <<
cos(i*Pi/6) << "," << sin(i*Pi/6) << ")");
BOOST_CHECK(L1.IsLeft(Pright) == false);
}
// fails for horizontal and nearly horizontal lines
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment