Commit dad1d8d1 authored by snuverink_j's avatar snuverink_j
Browse files

Merge branch '524-distribution-unit-tests-failing' into 'master'

Resolve "Distribution Unit Tests failing"

Closes #524

See merge request !344
parents fed401f6 ca6f864e
......@@ -43,7 +43,6 @@
#include <boost/regex.hpp>
using std::string;
using namespace Expressions;
......@@ -75,7 +74,7 @@ namespace Attributes {
const SRefAttr<bool> &value = ref->evaluate();
return value.evaluate();
} else {
throw OpalException("Attributes::get()", "Attribute \"" +
throw OpalException("Attributes::getBool()", "Attribute \"" +
attr.getName() + "\" is not logical.");
}
} else {
......@@ -85,10 +84,11 @@ namespace Attributes {
void setBool(Attribute &attr, bool val) {
SValue<SRefAttr<bool> > *ref;
if(dynamic_cast<const Bool *>(&attr.getHandler())) {
attr.set(new SValue<bool>(val));
} else if(SValue<SRefAttr<bool> > *ref =
dynamic_cast<SValue<SRefAttr<bool> >*>(&attr.getBase())) {
} else if((attr.isBaseAllocated() == true) &&
(ref = dynamic_cast<SValue<SRefAttr<bool> >*>(&attr.getBase()))) {
const SRefAttr<bool> &value = ref->evaluate();
value.set(val);
} else {
......@@ -161,7 +161,7 @@ namespace Attributes {
if(dynamic_cast<const Place *>(&attr.getHandler())) {
attr.set(new SValue<PlaceRep>(rep));
} else {
throw OpalException("Attributes::getPlace()", "Attribute \"" +
throw OpalException("Attributes::setPlace()", "Attribute \"" +
attr.getName() + "\" is not a place reference.");
}
}
......@@ -182,7 +182,7 @@ namespace Attributes {
dynamic_cast<SValue<RangeRep> *>(&attr.getBase())) {
return range->evaluate();
} else {
throw OpalException("Attributes::get()", "Attribute \"" +
throw OpalException("Attributes::getRange()", "Attribute \"" +
attr.getName() + "\" is not a range reference.");
}
} else {
......@@ -195,7 +195,7 @@ namespace Attributes {
if(dynamic_cast<const Range *>(&attr.getHandler())) {
attr.set(new SValue<RangeRep>(rep));
} else {
throw OpalException("Attributes::get()", "Attribute \"" +
throw OpalException("Attributes::setRange()", "Attribute \"" +
attr.getName() + "\" is not a range reference.");
}
}
......@@ -236,10 +236,11 @@ namespace Attributes {
void setReal(Attribute &attr, double val) {
SValue<SRefAttr<double> > *ref;
if(dynamic_cast<const Real *>(&attr.getHandler())) {
attr.set(new SValue<double>(val));
} else if(SValue<SRefAttr<double> > *ref =
dynamic_cast<SValue<SRefAttr<double> >*>(&attr.getBase())) {
} else if((attr.isBaseAllocated() == true) &&
(ref = dynamic_cast<SValue<SRefAttr<double> >*>(&attr.getBase()))) {
const SRefAttr<double> &value = ref->evaluate();
value.set(val);
} else {
......@@ -357,10 +358,11 @@ namespace Attributes {
void setString(Attribute &attr, const std::string &val) {
SValue<SRefAttr<std::string> > *ref;
if(dynamic_cast<const String *>(&attr.getHandler())) {
attr.set(new SValue<std::string>(val));
} else if(SValue<SRefAttr<std::string> > *ref =
dynamic_cast<SValue<SRefAttr<std::string> >*>(&attr.getBase())) {
} else if((attr.isBaseAllocated() == true) &&
(ref = dynamic_cast<SValue<SRefAttr<std::string> >*>(&attr.getBase()))) {
const SRefAttr<std::string> &value = ref->evaluate();
value.set(val);
} else {
......@@ -385,10 +387,11 @@ namespace Attributes {
void setUpperCaseString(Attribute &attr, const std::string &val) {
SValue<SRefAttr<std::string> > *ref;
if(dynamic_cast<const UpperCaseString *>(&attr.getHandler())) {
attr.set(new SValue<std::string>(Util::toUpper(val)));
} else if(SValue<SRefAttr<std::string> > *ref =
dynamic_cast<SValue<SRefAttr<std::string> >*>(&attr.getBase())) {
} else if((attr.isBaseAllocated() == true) &&
(ref = dynamic_cast<SValue<SRefAttr<std::string> >*>(&attr.getBase()))) {
const SRefAttr<std::string> &value = ref->evaluate();
value.set(Util::toUpper(val));
} else {
......@@ -495,7 +498,7 @@ namespace Attributes {
dynamic_cast<SValue<TableRowRep> *>(&attr.getBase())) {
return row->evaluate();
} else {
throw OpalException("Attributes::get()", "Attribute \"" +
throw OpalException("Attributes::getTableRow()", "Attribute \"" +
attr.getName() +
"\" is not a table row reference.");
}
......@@ -509,7 +512,7 @@ namespace Attributes {
if(dynamic_cast<const TableRow *>(&attr.getHandler())) {
attr.set(new SValue<TableRowRep>(rep));
} else {
throw OpalException("Attributes::get()", "Attribute \"" +
throw OpalException("Attributes::setTableRow()", "Attribute \"" +
attr.getName() +
"\" is not a table row reference.");
}
......@@ -543,7 +546,7 @@ namespace Attributes {
if(dynamic_cast<const TokenList *>(&attr.getHandler())) {
attr.set(new SValue<std::list<Token> >(val));
} else {
throw OpalException("Attributes::set()", "Attribute \"" + attr.getName() +
throw OpalException("Attributes::setTokenList()", "Attribute \"" + attr.getName() +
"\" is not a token list.");
}
}
......
......@@ -34,7 +34,7 @@ TEST(BinomialTest, FullSigmaTest1) {
Distribution dist;
Attributes::setString(dist.itsAttr[Attrib::Distribution::TYPE], "BINOMIAL");
Attributes::setUpperCaseString(dist.itsAttr[Attrib::Distribution::TYPE], "BINOMIAL");
Attributes::setReal(dist.itsAttr[Attrib::Distribution::MX], 999999999.9);
Attributes::setReal(dist.itsAttr[Attrib::Distribution::MY], 999999999.9);
Attributes::setReal(dist.itsAttr[Attrib::Distribution::MZ], 999999999.9);
......@@ -114,7 +114,7 @@ TEST(BinomialTest, FullSigmaTest2) {
Distribution dist;
Attributes::setString(dist.itsAttr[Attrib::Distribution::TYPE], "BINOMIAL");
Attributes::setUpperCaseString(dist.itsAttr[Attrib::Distribution::TYPE], "BINOMIAL");
Attributes::setReal(dist.itsAttr[Attrib::Distribution::MX], 1.0);
Attributes::setReal(dist.itsAttr[Attrib::Distribution::MY], 1.0);
Attributes::setReal(dist.itsAttr[Attrib::Distribution::MZ], 1.0);
......
......@@ -34,7 +34,7 @@ TEST(GaussTest, FullSigmaTest1) {
Distribution dist;
Attributes::setString(dist.itsAttr[Attrib::Distribution::TYPE], "GAUSS");
Attributes::setUpperCaseString(dist.itsAttr[Attrib::Distribution::TYPE], "GAUSS");
Attributes::setReal(dist.itsAttr[Attrib::Distribution::SIGMAX], expectedR11 * 1e-3);
Attributes::setReal(dist.itsAttr[Attrib::Distribution::SIGMAPX], expectedR22);
Attributes::setReal(dist.itsAttr[Attrib::Distribution::SIGMAY], expectedR33 * 1e-3);
......@@ -112,7 +112,7 @@ TEST(GaussTest, FullSigmaTest2) {
Distribution dist;
Attributes::setString(dist.itsAttr[Attrib::Distribution::TYPE], "GAUSS");
Attributes::setUpperCaseString(dist.itsAttr[Attrib::Distribution::TYPE], "GAUSS");
Attributes::setReal(dist.itsAttr[Attrib::Distribution::SIGMAX], expectedR11 * 1e-3);
Attributes::setReal(dist.itsAttr[Attrib::Distribution::SIGMAPX], expectedR22);
Attributes::setReal(dist.itsAttr[Attrib::Distribution::SIGMAY], expectedR33 * 1e-3);
......
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