25 #include <ns3/building-position-allocator.h>
26 #include <ns3/buildings-mobility-model.h>
27 #include <ns3/building.h>
28 #include <ns3/buildings-helper.h>
29 #include <ns3/mobility-helper.h>
30 #include <ns3/simulator.h>
41 Room (uint32_t xx, uint32_t yy, uint32_t zz);
47 Room::Room (uint32_t xx, uint32_t yy, uint32_t zz)
55 operator < (
const Room& a,
const Room& b)
58 || ( (a.x == b.x) && (a.y < b.y) )
59 || ( (a.x == b.x) && (a.y == b.y) && (a.z < b.z) ));
70 virtual void DoRun (
void);
75 RandomRoomPositionAllocatorTestCase::RandomRoomPositionAllocatorTestCase ()
76 :
TestCase (
"RandomRoom, 12 rooms, 24 nodes")
89 b->SetBoundaries (
Box (1, 3, 1, 4, 1, 3));
103 BuildingsHelper::MakeMobilityModelConsistent ();
105 std::map<Room, uint32_t> roomCounter;
107 for (NodeContainer::Iterator it = nodes.
Begin (); it != nodes.
End (); ++it)
110 NS_ASSERT_MSG (mm,
"no mobility model aggregated to this node");
112 NS_ASSERT_MSG (bmm,
"mobility model aggregated to this node is not a BuildingsMobilityModel");
114 NS_TEST_ASSERT_MSG_EQ (bmm->IsIndoor (),
true,
"node should be indoor");
115 Room r (bmm->GetRoomNumberX (), bmm->GetRoomNumberY (), bmm->GetFloorNumber ());
118 Vector p = bmm->GetPosition ();
119 NS_TEST_ASSERT_MSG_GT (p.x, bmm->GetRoomNumberX (),
"wrong x value");
120 NS_TEST_ASSERT_MSG_LT (p.x, bmm->GetRoomNumberX () + 1,
"wrong x value");
121 NS_TEST_ASSERT_MSG_GT (p.y, bmm->GetRoomNumberY (),
"wrong y value");
122 NS_TEST_ASSERT_MSG_LT (p.y, bmm->GetRoomNumberY () + 1,
"wrong y value");
123 NS_TEST_ASSERT_MSG_GT (p.z, bmm->GetFloorNumber (),
"wrong z value");
124 NS_TEST_ASSERT_MSG_LT (p.z, bmm->GetFloorNumber () + 1,
"wrong z value");
128 for (std::map<Room, uint32_t>::iterator it = roomCounter.begin (); it != roomCounter.end (); ++it)
133 NS_TEST_ASSERT_MSG_EQ (it->second, 2,
"expected 2 nodes per room");
136 NS_TEST_ASSERT_MSG_EQ (roomCounter.size (), 12,
"expected 12 rooms allocated");
151 virtual void DoRun (
void);
156 SameRoomPositionAllocatorTestCase::SameRoomPositionAllocatorTestCase ()
170 b->SetBoundaries (
Box (-10, -6, 20, 26, -1, 5));
186 positionAlloc = CreateObject<SameRoomPositionAllocator> (nodes);
190 BuildingsHelper::MakeMobilityModelConsistent ();
192 std::map<Room, uint32_t> roomCounter;
194 for (NodeContainer::Iterator it = copyNodes.
Begin (); it != copyNodes.
End (); ++it)
197 NS_ASSERT_MSG (mm,
"no mobility model aggregated to this node");
199 NS_ASSERT_MSG (bmm,
"mobility model aggregated to this node is not a BuildingsMobilityModel");
201 NS_TEST_ASSERT_MSG_EQ (bmm->IsIndoor (),
true,
"node should be indoor");
202 Room r (bmm->GetRoomNumberX (), bmm->GetRoomNumberY (), bmm->GetFloorNumber ());
206 for (std::map<Room, uint32_t>::iterator it = roomCounter.begin (); it != roomCounter.end (); ++it)
209 NS_TEST_ASSERT_MSG_EQ (it->second, 4,
"expected 4 nodes per room");
212 NS_TEST_ASSERT_MSG_EQ (roomCounter.size (), 12,
"expected 12 rooms allocated");
229 BuildingPositionAllocatorTestSuite::BuildingPositionAllocatorTestSuite ()
230 :
TestSuite (
"building-position-allocator", UNIT)
239 static BuildingPositionAllocatorTestSuite buildingsPositionAllocatorTestSuiteInstance;
virtual void DoRun(void)
Implementation to actually run this test case.
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
#define NS_LOG_COMPONENT_DEFINE(name)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Keep track of the current position and velocity of an object.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
virtual void DoRun(void)
Implementation to actually run this test case.
#define NS_LOG_LOGIC(msg)
static void Destroy(void)
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
#define NS_ASSERT_MSG(condition, message)
Helper class used to assign positions and mobility models to nodes.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Ptr< T > GetObject(void) const