21#include "ns3/length.h"
23#include "ns3/object.h"
24#include "ns3/string.h"
28#include <boost/units/base_units/us/foot.hpp>
29#include <boost/units/systems/si.hpp>
30#include <boost/units/systems/si/prefixes.hpp>
36#include <initializer_list>
148 const std::initializer_list<std::string>& symbols);
167#ifdef HAVE_BOOST_UNITS
172 void TestConstructLengthFromBoostUnits ();
173 void TestConstructLengthFromBoostUnitsMeters ();
174 void TestConstructLengthFromBoostUnitsKiloMeters ();
175 void TestConstructLengthFromBoostUnitsFeet ();
259 const std::string& expectedOutput,
260 const std::string& context);
319 virtual void DoRun ();
338 "length constructed from meters has wrong value");
344 using TestEntry = std::tuple<Length, std::string>;
346 const double expectedMeters = 1;
347 const std::initializer_list<TestEntry> inputs {
348 std::make_tuple (
Length (1e9, Unit::Nanometer),
"nanometer"),
349 std::make_tuple (
Length (1e6, Unit::Micrometer),
"micrometer"),
350 std::make_tuple (
Length (1e3, Unit::Millimeter),
"millimeter"),
351 std::make_tuple (
Length (1e2, Unit::Centimeter),
"centimeter"),
352 std::make_tuple (
Length (1e-3, Unit::Kilometer),
"kilometer"),
353 std::make_tuple (
Length ( (1 / 1852.0), Unit::NauticalMile),
"nautical_mile")
356 for (
const TestEntry& entry : inputs )
358 const Length& l = std::get<0> (entry);
359 const std::string& context = std::get<1> (entry);
362 context <<
": constructed length from SI unit has wrong value");
369 using TestEntry = std::tuple<Length, std::string>;
371 const double expectedMeters = 0.3048;
372 const double tolerance = 0.0001;
374 const std::initializer_list<TestEntry> inputs {
375 std::make_tuple (
Length (12.0, Unit::Inch),
"inch"),
376 std::make_tuple (
Length (1.0, Unit::Foot),
"foot"),
377 std::make_tuple (
Length ((1 / 3.0), Unit::Yard),
"yard"),
378 std::make_tuple (
Length ((1 / 5280.0), Unit::Mile),
"mile"),
381 for (
const TestEntry& entry : inputs )
383 const Length& l = std::get<0> (entry);
384 const std::string& context = std::get<1> (entry);
387 "constructed length from US unit (" << context <<
") has wrong value");
394 const double value = 5;
395 Length original (value, Unit::Meter);
400 "copy constructed length has wrong value");
406 const double value = 5;
407 Length original (value, Unit::Meter);
409 Length copy (std::move (original));
412 "move constructed length has wrong value");
419 const std::initializer_list<std::string>& symbols)
421 const std::array<std::string, 2> SEPARATORS {{
"",
" "}};
423 for (
const std::string& symbol : symbols)
425 for (
const std::string& separator : SEPARATORS )
427 std::ostringstream stream;
429 stream << unitValue << separator << symbol;
433 std::ostringstream msg;
434 msg <<
"string constructed length has wrong value: '" << stream.str () <<
"'";
444 const double value = 5;
447 {
"m",
"meter",
"meters",
"metre",
"metres"});
453 const double value = 5;
454 const double expectedValue = 5e-9;
457 {
"nm",
"nanometer",
"nanometers",
458 "nanometre",
"nanometres"});
464 const double value = 5;
465 const double expectedValue = 5e-6;
466 const double tolerance = 1e-7;
469 {
"um",
"micrometer",
"micrometers",
470 "micrometre",
"micrometres"});
476 const double value = 5;
477 const double expectedValue = 5e-3;
478 const double tolerance = 1e-4;
481 {
"mm",
"millimeter",
"millimeters",
482 "millimetre",
"millimetres"});
488 const double value = 5;
489 const double expectedValue = 5e-2;
490 const double tolerance = 1e-3;
493 {
"cm",
"centimeter",
"centimeters",
494 "centimetre",
"centimetres"});
500 const double value = 5;
501 const double expectedValue = 5e3;
504 {
"km",
"kilometer",
"kilometers",
505 "kilometre",
"kilometres"});
511 const double value = 5;
512 const double expectedValue = 9260;
515 {
"nmi",
"nautical mile",
"nautical miles"});
520 const double value = 5;
521 const double expectedValue = 0.127;
522 const double tolerance = 1e-4;
525 {
"in",
"inch",
"inches"});
531 const double value = 5;
532 const double expectedValue = 1.524;
533 const double tolerance = 1e-4;
536 {
"ft",
"foot",
"feet"});
542 const double value = 5;
543 const double expectedValue = 4.572;
544 const double tolerance = 1e-4;
547 {
"yd",
"yard",
"yards"});
553 const double value = 5;
554 const double expectedValue = 8046.72;
555 const double tolerance = 1e-3;
558 {
"mi",
"mile",
"miles"});
561#ifdef HAVE_BOOST_UNITS
563LengthTestCase::TestConstructLengthFromBoostUnits ()
565 TestConstructLengthFromBoostUnitsMeters ();
566 TestConstructLengthFromBoostUnitsKiloMeters ();
567 TestConstructLengthFromBoostUnitsFeet ();
571LengthTestCase::TestConstructLengthFromBoostUnitsMeters ()
573 namespace bu = boost::units;
575 auto meters = 5 * bu::si::meter;
580 "Construction from boost::units meters produced "
585LengthTestCase::TestConstructLengthFromBoostUnitsKiloMeters ()
587 namespace bu = boost::units;
588 auto kilometer = bu::si::kilo * bu::si::meter;
590 const double expectedValue = 5000;
591 auto quantity = 5 * kilometer;
596 "Construction from boost::units kilometers produced "
601LengthTestCase::TestConstructLengthFromBoostUnitsFeet ()
603 namespace bu = boost::units;
605 bu::us::foot_base_unit::unit_type Foot;
607 const double expectedValue = 3.048;
608 auto feet = 10 * Foot;
613 "Construction from boost::units foot produced "
621 using Builder = std::function<
Length (
double)>;
623 double inputValue = 10;
625 std::map<Unit, Builder> TESTDATA{
639 for (
auto& entry : TESTDATA)
641 Length expected (inputValue, entry.first);
643 Length output = entry.second (inputValue);
646 "The builder free function for " << entry.first <<
647 " did not create a Length with the correct value");
657 std::tie (
result, l) = Length::TryParse (1,
"");
665 using TestInput = std::pair<double, std::string>;
666 using TestArgs = std::pair<double, double>;
667 std::map<TestInput, TestArgs>
tests{
670 {{5,
"kilometer"}, {5e3, 0}},
671 {{5,
" kilometer"}, {5e3, 0}}
674 for (
auto& entry :
tests)
676 TestInput input = entry.first;
677 TestArgs args = entry.second;
682 std::tie (
result, l) = Length::TryParse (input.first, input.second);
686 std::stringstream stream;
687 stream <<
"Parsing input (" << input.first <<
", " << input.second
688 <<
") returned the wrong value";
698 const double value = 5;
700 Length original (value, Unit::Meter);
706 "copy assignment failed");
712 const double value = 5;
714 Length original (value, Unit::Meter);
717 copy = std::move (original);
720 "move assignment failed");
734 "quantity assignment failed");
740 const double value = 5;
741 Length one (value, Unit::Meter);
750 const double value = 5;
751 Length one (value, Unit::Meter);
752 Length two ( value, Unit::Foot );
760 const double value = 5;
761 const double tolerance = 0.1;
763 Length one (value, Unit::Meter);
764 Length two ( (value + 0.1), Unit::Meter);
767 "IsEqual returned false for almost equal lengths");
773 const double value = 5;
774 const double tolerance = 0.01;
776 Length one (value, Unit::Meter);
777 Length two ( (value + 0.1), Unit::Meter);
780 "IsEqual returned true for almost equal lengths");
786 const double value = 5;
788 Length one (value, Unit::Meter);
789 Length two ( (value + 0.1), Unit::Meter);
792 "IsNotEqual returned false for not equal lengths");
798 const double value = 5;
800 Length one (value, Unit::Meter);
804 "IsNotEqual returned true for equal lengths");
810 const double tolerance = 0.001;
812 Length one ( 5.01, Unit::Meter);
813 Length two ( 5.02, Unit::Meter);
816 "IsNotEqual with tolerance returned false for not equal lengths");
822 const double tolerance = 0.01;
824 Length one ( 5.01, Unit::Meter);
825 Length two ( 5.02, Unit::Meter);
828 "IsNotEqual with tolerance returned true for not equal lengths");
834 const double value = 5;
836 Length one (value, Unit::Meter);
837 Length two ( (value + 0.1), Unit::Meter);
840 "IsLess returned false for non equal lengths");
846 const double value = 5;
848 Length one (value, Unit::Meter);
852 "IsLess returned true for equal lengths");
858 const double tolerance = 0.01;
860 Length one ( 5.1234, Unit::Meter );
861 Length two ( 5.1278, Unit::Meter );
864 "IsLess with tolerance returned true");
870 Length one (2.0, Unit::Meter);
871 Length two (1.0, Unit::Meter);
874 "IsGreater returned false");
880 Length one (2.0, Unit::Meter);
881 Length two (1.0, Unit::Meter);
884 "IsGreater returned true");
890 const double tolerance = 0.01;
892 Length one (5.1234, Unit::Meter);
893 Length two (5.1278, Unit::Meter);
896 "IsGreater returned true");
902 Length l (1.0, Unit::Meter);
904 std::stringstream stream;
909 "unexpected output from operator<<");
915 const double value = 5;
919 std::stringstream stream;
921 stream << value <<
"m";
926 "unexpected length from operator>>");
933 const std::string& expectedOutput,
934 const std::string& context)
936 const std::string msg = context +
": unexpected output when serializing length";
938 std::ostringstream stream;
941 << std::setprecision (5)
950 Length l (1.0, Unit::Meter);
968 const double value = 5;
970 Length one ( value, Unit::Meter );
971 Length two ( value, Unit::Meter );
974 "operator== returned false for equal lengths");
980 const double value = 5;
982 Length one ( value, Unit::Meter );
983 Length two ( value, Unit::Kilometer );
986 "operator== returned true for non equal lengths");
992 const double value = 5;
994 Length one ( value, Unit::Meter );
995 Length two ( value, Unit::Kilometer);
998 "operator!= returned false for non equal lengths");
1005 const double value = 5;
1007 Length one ( value, Unit::Meter );
1008 Length two ( value, Unit::Meter );
1011 "operator!= returned true for equal lengths");
1018 const double value = 5;
1020 Length one ( value, Unit::Meter );
1021 Length two ( value, Unit::Kilometer);
1024 "operator< returned false for smaller length");
1030 const double value = 5;
1032 Length one ( value, Unit::Meter );
1033 Length two ( value, Unit::Kilometer);
1036 "operator< returned true for larger length");
1042 const double value = 5;
1044 Length one ( value, Unit::Meter );
1045 Length two ( value, Unit::Kilometer);
1049 "operator<= returned false for smaller length");
1052 "operator<= returned false for equal lengths");
1058 const double value = 5;
1060 Length one ( value, Unit::Meter );
1061 Length two ( value, Unit::Kilometer);
1064 "operator<= returned true for larger length");
1070 const double value = 5;
1072 Length one ( value, Unit::Meter );
1073 Length two ( value, Unit::Kilometer);
1076 "operator> returned false for larger length");
1082 const double value = 5;
1084 Length one ( value, Unit::Meter );
1085 Length two ( value, Unit::Kilometer);
1088 "operator> returned true for smaller length");
1094 const double value = 5;
1096 Length one ( value, Unit::Meter );
1097 Length two ( value, Unit::Kilometer);
1101 "operator>= returned false for larger length");
1104 "operator>= returned false for equal lengths");
1110 const double value = 5;
1112 Length one ( value, Unit::Meter );
1113 Length two ( value, Unit::Kilometer);
1116 "operator>= returned true for smaller length");
1122 const double value = 1;
1123 const double expectedOutput = 2;
1125 Length one ( value, Unit::Meter );
1126 Length two ( value, Unit::Meter );
1131 "operator+ modified first operand");
1133 "operator+ modified second operand");
1135 "operator+ returned incorrect value");
1141 const double value = 1;
1142 const double expectedOutput = 2;
1144 Length one ( value, Unit::Meter );
1149 "operator+ modified first operand");
1151 "operator+ returned incorrect value");
1157 const double value = 1;
1158 const double expectedOutput = 2;
1160 Length one ( value, Unit::Meter );
1165 "operator+ modified first operand");
1167 "operator+ returned incorrect value");
1173 const double value = 1;
1174 const double expectedOutput = 0;
1176 Length one ( value, Unit::Meter );
1177 Length two ( value, Unit::Meter );
1182 "operator- modified first operand");
1184 "operator- modified second operand");
1186 "operator- returned incorrect value");
1192 const double value = 1;
1193 const double expectedOutput = 0;
1195 Length one ( value, Unit::Meter );
1200 "operator- modified first operand");
1202 "operator- returned incorrect value");
1208 const double value = 1;
1209 const double expectedOutput = 0;
1211 Length one ( value, Unit::Meter );
1216 "operator- modified second operand");
1218 "operator- returned incorrect value");
1224 const double value = 1;
1225 const double scalar = 5;
1226 const double expectedOutput = value * scalar;
1228 Length one ( value, Unit::Meter );
1232 "operator* modified first operand");
1234 "operator* returned incorrect value");
1240 const double value = 1;
1241 const double scalar = 5;
1242 const double expectedOutput = value * scalar;
1244 Length one ( value, Unit::Meter );
1248 "operator* modified second operand");
1250 "operator* returned incorrect value");
1256 const double value = 10;
1257 const double scalar = 5;
1258 const double expectedOutput = value / scalar;
1260 Length one ( value, Unit::Meter );
1264 "operator/ modified first operand");
1266 "operator/ returned incorrect value");
1272 const double valueOne = 100;
1273 const double valueTwo = 2;
1274 const double expectedOutput = valueOne / valueTwo;
1276 Length one ( valueOne, Unit::Meter );
1277 Length two ( valueTwo, Unit::Meter );
1279 double result = one / two;
1282 "operator/ modified first operand");
1284 "operator/ modified second operand");
1286 "operator/ returned incorrect value");
1293 const double value = 1;
1295 Length one ( value, Unit::Meter );
1298 double result = one / two;
1301 "operator/ did not return NaN when dividing by zero");
1307 const double topValue = 100;
1308 const double bottomValue = 20;
1309 const int64_t expectedOutput = 5;
1311 Length numerator (topValue, Unit::Meter);
1312 Length denominator (bottomValue, Unit::Meter);
1314 auto result =
Div (numerator, denominator);
1317 "Div() returned an incorrect value");
1323 const double topValue = 100;
1324 const double bottomValue = 20;
1325 const int64_t expectedOutput = 5;
1326 const int64_t expectedRemainder = 0;
1328 Length numerator (topValue, Unit::Meter);
1329 Length denominator (bottomValue, Unit::Meter);
1332 auto result =
Div (numerator, denominator, &remainder);
1335 "Div() returned an incorrect value");
1337 "Div() returned an incorrect remainder");
1343 const double topValue = 110;
1344 const double bottomValue = 20;
1345 const int64_t expectedOutput = 5;
1346 const int64_t expectedRemainder = 10;
1348 Length numerator (topValue, Unit::Meter);
1349 Length denominator (bottomValue, Unit::Meter);
1352 auto result =
Div (numerator, denominator, &remainder);
1355 "Div() returned an incorrect value");
1357 "Div() returned an incorrect remainder");
1363 Length numerator (10, Unit::Meter);
1364 Length denominator (2, Unit::Meter);
1366 auto result =
Mod (numerator, denominator);
1369 "Mod() returned a non zero value");
1375 Length numerator (14, Unit::Meter);
1376 Length denominator (3, Unit::Meter);
1377 const double expectedValue = 2;
1379 auto result =
Mod (numerator, denominator);
1382 "Mod() returned the wrong value");
1412#ifdef HAVE_BOOST_UNITS
1413 TestConstructLengthFromBoostUnits ();
1547 virtual void DoRun ();
1553 static TypeId tid =
TypeId (
"LengthValueTestCase::TestObject")
1555 .SetGroupName (
"Test")
1557 .AddAttribute (
"Length",
1587 "Length attribute serialization has wrong output");
1596 std::ostringstream stream;
1603 "Length attribute deserialization failed");
1605 "Length attribute has wrong value after deserialization");
1611 Length expected (5, Unit::Kilometer);
1614 obj->SetAttribute (
"Length",
LengthValue (expected));
1617 obj->GetAttribute (
"Length", val);
1620 "Length attribute does not have expected value");
1626 Length expected (5, Unit::Kilometer);
1629 std::stringstream stream;
1630 stream << expected.
As (Unit::Kilometer);
1632 obj->SetAttribute (
"Length",
StringValue (stream.str()));
1635 obj->GetAttribute (
"Length", val);
1638 "Length attribute does not have expected value");
Implements tests for the Length class.
void TestAddingLengthAndQuantity()
Test arithmetic operations.
void TestIsGreaterReturnsFalse()
Test member comparison operators.
void TestOperatorGreaterOrEqualReturnsTrue()
Test free function comparison operators.
void TestOperatorEqualsReturnsFalse()
Test free function comparison operators.
void TestTryParseReturnsTrue()
Test the TryParse function returns true on success.
void TestConstructLengthFromMeterString()
Test that a length object can be constructed from a string.
void TestDivReturnsZeroRemainder()
Test Div function.
void TestBuilderFreeFunctions()
Test constructing length objects using the builder free functions.
void TestConstructLengthFromMileString()
Test that a length object can be constructed from a string.
void TestIsEqualWithToleranceReturnsFalse()
Test member comparison operators.
void TestDivReturnsCorrectRemainder()
Test Div function.
void TestModReturnsZero()
Test Mod function.
void TestConstructLengthFromCentiMeterString()
Test that a length object can be constructed from a string.
void TestDivideLengthByScalar()
Test arithmetic operations.
void TestModReturnsNonZero()
Test Mod function.
void TestLengthMoveConstructor()
Test that the value from one length is copied to another using the move constructor.
void TestTryParseReturnsFalse()
Test the TryParse function returns false on bad input.
void TestCopyAssignment()
Test that a length object can be updated by assignment from another length object.
virtual void DoRun()
Implementation to actually run this TestCase.
void TestIsNotEqualReturnsTrue()
Test member comparison operators.
void TestConstructLengthFromFootString()
Test that a length object can be constructed from a string.
void TestInputStreamOperator()
Test reading length object from a stream produces the expected length value.
void TestDivideLengthByLengthReturnsNaN()
Test arithmetic operations.
void TestIsNotEqualWithToleranceReturnsFalse()
Test member comparison operators.
void TestOperatorLessOrEqualReturnsTrue()
Test free function comparison operators.
void TestIsLessReturnsFalse()
Test member comparison operators.
void TestSubtractingQuantityAndLength()
Test arithmetic operations.
void TestConstructLengthFromMilliMeterString()
Test that a length object can be constructed from a string.
virtual ~LengthTestCase()=default
Destructor.
void TestConstructLengthFromInchString()
Test that a length object can be constructed from a string.
void TestConstructLengthFromSIUnits()
Test that a Length object constructed from various SI units has the correct value in meters.
void TestConstructLengthFromNanoMeterString()
Test that a length object can be constructed from a string.
void TestMultiplyLengthByScalar()
Test arithmetic operations.
void AssertTrue(bool condition, std::string msg)
Helper function to compare results with true.
void TestIsEqualReturnsFalse()
Test member comparison operators.
void TestConstructLengthFromQuantity()
Test that a Length object can be constructed from a Quantity object.
void TestConstructLengthFromKiloMeterString()
Test that a length object can be constructed from a string.
void TestDefaultLengthIsZero()
Test that a default constructed Length object has a value of 0.
void TestOperatorEqualsReturnsTrue()
Test free function comparison operators.
void TestConstructLengthFromUSUnits()
Test that a Length object constructed from various US units has the correct value in meters.
void AssertFalse(bool condition, std::string msg)
Helper function to compare results with false.
void TestIsEqualReturnsTrue()
Test member comparison operators.
void TestIsNotEqualWithToleranceReturnsTrue()
Test member comparison operators.
void TestOperatorLessThanReturnsFalse()
Test free function comparison operators.
void TestIsGreaterWithToleranceReturnsFalse()
Test member comparison operators.
void TestLengthSerialization(const Length &l, const T &unit, const std::string &expectedOutput, const std::string &context)
Generic function for testing serialization of a Length object in various units.
void TestSubtractingLengthAndQuantity()
Test arithmetic operations.
void TestSubtractingTwoLengths()
Test arithmetic operations.
void TestDivideLengthByLength()
Test arithmetic operations.
void TestDivReturnsCorrectResult()
Test Div function.
void TestAddingQuantityAndLength()
Test arithmetic operations.
void TestIsNotEqualReturnsFalse()
Test member comparison operators.
void TestConstructLengthFromMicroMeterString()
Test that a length object can be constructed from a string.
void TestOperatorGreaterThanReturnsTrue()
Test free function comparison operators.
void TestOutputStreamOperator()
Test writing length object to a stream produces the expected output.
LengthTestCase()
Constructor.
void TestConstructLengthFromYardString()
Test that a length object can be constructed from a string.
void TestAddingTwoLengths()
Test arithmetic operations.
void TestConstructLengthFromNauticalMileString()
Test that a length object can be constructed from a string.
void TestIsLessReturnsTrue()
Test member comparison operators.
void TestOperatorGreaterThanReturnsFalse()
Test free function comparison operators.
void TestOperatorLessThanReturnsTrue()
Test free function comparison operators.
void TestOperatorNotEqualsReturnsFalse()
Test free function comparison operators.
void TestMoveAssignment()
Test that a length object can be updated by assignment from a moved length object.
void TestOperatorLessOrEqualReturnsFalse()
Test free function comparison operators.
void TestConstructLengthFromString(double unitValue, double meterValue, double tolerance, const std::initializer_list< std::string > &symbols)
Test that a length object can be constructed from a string.
void TestSerializeLengthWithUnit()
Test serializing a length object to all of the supported unit types.
void TestOperatorGreaterOrEqualReturnsFalse()
Test free function comparison operators.
void TestLengthCopyConstructor()
Test that the value from one length is copied to another using the copy constructor.
void TestOperatorNotEqualsReturnsTrue()
Test free function comparison operators.
void TestMultiplyScalarByLength()
Test arithmetic operations.
void TestIsLessWithToleranceReturnsFalse()
Test member comparison operators.
void TestIsGreaterReturnsTrue()
Test member comparison operators.
void TestQuantityAssignment()
Test that a length object can be updated by assignment from a quantity.
void TestIsEqualWithToleranceReturnsTrue()
Test member comparison operators.
The Test Suite that runs the test case.
LengthTestSuite()
Default Constructor.
Class with Length attribute.
static TypeId GetTypeId()
Get the type ID.
Length m_length
Length object.
Test case for LengthValue attribute.
virtual ~LengthValueTestCase()
Destructor.
void TestAttributeSerialization()
Test that a LengthValue can be serialized to a string.
void TestObjectAttribute()
Test that a LengthValue works as an attribute.
LengthValueTestCase()
Default Constructor.
void TestAttributeConstructor()
Test that a LengthValue can be constructed from a Length instance.
void TestAttributeDeserialization()
Test that a LengthValue can be deserialized from a string.
virtual void DoRun()
Implementation to actually run this TestCase.
void TestSetAttributeUsingStringValue()
Test that a StringValue is converted to LengthValue.
An immutable class which represents a value in a specific length unit.
double Value() const
The value of the quantity.
Represents a length in meters.
double GetDouble() const
Current length value.
bool IsGreater(const Length &other, double tolerance=DEFAULT_TOLERANCE) const
Check if other is less in value than this instance.
bool IsEqual(const Length &other, double tolerance=DEFAULT_TOLERANCE) const
Check if other is equal in value to this instance.
Quantity As(Unit unit) const
Create a Quantity in a specific unit from a Length.
Unit
Units of length in various measurement systems that are supported by the Length class.
bool IsLess(const Length &other, double tolerance=DEFAULT_TOLERANCE) const
Check if other is greater in value than this instance.
bool IsNotEqual(const Length &other, double tolerance=DEFAULT_TOLERANCE) const
Check if other is not equal in value to this instance.
AttributeValue implementation for Length.
virtual std::string SerializeToString(Ptr< const AttributeChecker > checker) const
virtual bool DeserializeFromString(std::string value, Ptr< const AttributeChecker > checker)
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< const AttributeChecker > MakeLengthChecker(void)
Ptr< const AttributeAccessor > MakeLengthAccessor(T1 a1)
Length KiloMeters(double value)
Construct a length from a value in the indicated unit.
Length MilliMeters(double value)
Construct a length from a value in the indicated unit.
Length NauticalMiles(double value)
Construct a length from a value in the indicated unit.
Length Yards(double value)
Construct a length from a value in the indicated unit.
Length Feet(double value)
Construct a length from a value in the indicated unit.
Length Mod(const Length &numerator, const Length &denominator)
Calculate the amount remaining after dividing two lengths.
Length MicroMeters(double value)
Construct a length from a value in the indicated unit.
Length Miles(double value)
Construct a length from a value in the indicated unit.
Length Meters(double value)
Construct a length from a value in the indicated unit.
Length CentiMeters(double value)
Construct a length from a value in the indicated unit.
int64_t Div(const Length &numerator, const Length &denominator, Length *remainder)
Calculate how many times numerator can be split into denominator sized pieces.
Length NanoMeters(double value)
Construct a length from a value in the indicated unit.
Length Inches(double value)
Construct a length from a value in the indicated unit.
#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.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Length::Unit Unit
Save some typing by defining a short alias for Length::Unit.
static LengthTestSuite gLengthTestSuite
LengthTestSuite instance.
Every class exported by the ns3 library is enclosed in the ns3 namespace.