Skip to content

Commit e1860ef

Browse files
author
Paolo Fittipaldi
committed
In TestUtils: Added setters with units to enable conversions of unit during testing
1 parent 9457697 commit e1860ef

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

quisp/channels/FreeSpaceChannel_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class MockNode : public quisp_test::TestQNode {
3030
class FreeSpaceChannel : public OriginalFreeSpaceChannel {
3131
public:
3232
FreeSpaceChannel() : OriginalFreeSpaceChannel::FreeSpaceChannel() {
33-
setParDouble(this, "distance", 0);
33+
setParDouble(this, "distance", 0, "km");
3434
setParDouble(this, "delay", 0);
3535
setParDouble(this, "datarate", 0);
3636
setParDouble(this, "ber", 0);
3737
setParDouble(this, "per", 0);
3838
setParDouble(this, "orbital_period", 86400);
39-
setParDouble(this, "speed_of_light_in_freespace", 299792458);
39+
setParDouble(this, "speed_of_light_in_freespace", 299792.458, "km");
4040
setParBool(this, "disabled", false);
4141
setParBool(this, "csv_varies_delay", true);
4242

quisp/test_utils/TestUtilFunctions.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ void setParDouble(cModule *module, const char *name, const double val) {
3434
module->addPar(p);
3535
}
3636

37+
void setParDouble(cModule *module, const char *name, const double val, const char *unit) {
38+
if (module->findPar(name) != -1) {
39+
module->par(name) = val;
40+
return;
41+
}
42+
cParImpl *p = new cDoubleParImpl();
43+
p->setName(name);
44+
p->setDoubleValue(val);
45+
p->setUnit(unit);
46+
p->setIsMutable(true);
47+
module->addPar(p);
48+
}
49+
3750
void setParStr(cModule *module, const char *name, const char *val) {
3851
if (module->findPar(name) != -1) {
3952
module->par(name) = val;
@@ -94,6 +107,19 @@ void setParDouble(cChannel *channel, const char *name, const double val) {
94107
channel->addPar(p);
95108
}
96109

110+
void setParDouble(cChannel *channel, const char *name, const double val, const char *unit) {
111+
if (channel->findPar(name) != -1) {
112+
channel->par(name) = val;
113+
return;
114+
}
115+
cParImpl *p = new cDoubleParImpl();
116+
p->setName(name);
117+
p->setDoubleValue(val);
118+
p->setUnit(unit);
119+
p->setIsMutable(true);
120+
channel->addPar(p);
121+
}
122+
97123
void setParStr(cChannel *channel, const char *name, const char *val) {
98124
if (channel->findPar(name) != -1) {
99125
channel->par(name) = val;

quisp/test_utils/TestUtilFunctions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ using quisp_test::simulation::TestSimulation;
1313

1414
void setParInt(cModule *module, const char *name, const int val);
1515
void setParDouble(cModule *module, const char *name, const double val);
16+
void setParDouble(cModule *module, const char *name, const double val, const char *unit);
1617
void setParBool(cModule *module, const char *name, const bool val);
1718
void setParStr(cModule *module, const char *name, const char *val);
1819
void setParObject(cModule *module, const char *name, omnetpp::cObject *val);
1920
void setParInt(cChannel *channel, const char *name, const int val);
2021
void setParDouble(cChannel *channel, const char *name, const double val);
22+
void setParDouble(cChannel *channel, const char *name, const double val, const char *unit);
2123
void setParBool(cChannel *channel, const char *name, const bool val);
2224
void setParStr(cChannel *channel, const char *name, const char *val);
2325
void setParObject(cChannel *channel, const char *name, omnetpp::cObject *val);

0 commit comments

Comments
 (0)