21 #include <ns3/simulator.h>
34 :
TestSuite(
"box-line-intersection", UNIT)
37 Box box =
Box(890.0, 990.0, 840.0, 870.0, 0.0, 6.0);
79 :
TestCase(BuildNameString(indexPos1, indexPos2, box, intersect)),
80 m_indexPos1(indexPos1),
81 m_indexPos2(indexPos2),
83 m_intersect(intersect)
97 std::ostringstream oss;
98 oss <<
"Box line intersection test : checking"
99 <<
" pos1 index " << indexPos1 <<
" and pos2 index " << indexPos2
100 <<
" intersection with the box (" << box.
xMin <<
", " << box.
xMax <<
", " << box.
yMin
101 <<
", " << box.
yMax <<
", " << box.
zMin <<
", " << box.
zMax
102 <<
"). The expected intersection flag = " << intersect <<
" ";
116 "Unexpected result of box and line segment intersection!");
117 Simulator::Destroy();
128 pos = Vector(934.0, 852.0, 1.5);
131 pos = Vector(931.0, 861.0, 1.5);
134 pos = Vector(484.0, 298.0, 1.5);
137 pos = Vector(1000.0, 850.0, 1.5);
140 pos = Vector(850.0, 850.0, 1.5);
143 pos = Vector(934.0, 852.0, boxHeight + 14.0);
static BoxLineIntersectionTestSuite boxLineIntersectionTestSuite
boxLineIntersectionTestSuite
TestCase to check the box line intersection.
uint16_t m_indexPos2
Second position index.
BoxLineIntersectionTestCase(uint16_t indexPos1, uint16_t indexPos2, Box box, bool intersect)
Create BoxLineIntersectionTestCase.
uint16_t m_indexPos1
First position index.
void DoRun() override
Setup the simulation according to the configuration set by the class constructor, run it,...
std::string BuildNameString(uint16_t indexPos1, uint16_t indexPos2, Box box, bool intersect)
Builds the test name string based on provided parameter values.
bool m_intersect
Flag to indicate the intersection.
Vector CreatePosition(uint16_t index, double boxHeight)
Create the position as per the given index.
~BoxLineIntersectionTestCase() override
Destructor.
Box m_box
The box to check the intersection with.
BoxLineIntersectionTestSuite()
Constructor.
double yMax
The y coordinate of the top bound of the box.
double xMin
The x coordinate of the left bound of the box.
double yMin
The y coordinate of the bottom bound of the box.
double xMax
The x coordinate of the right bound of the box.
double zMin
The z coordinate of the down bound of the box.
bool IsIntersect(const Vector &l1, const Vector &l2) const
Checks if a line-segment between position l1 and position l2 intersects a box.
double zMax
The z coordinate of the up bound of the box.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.