Skip to content
Snippets Groups Projects
Commit 9c6db1bf authored by Michael Trummer's avatar Michael Trummer
Browse files

intermediate state. not compilable

parent d7db9ca0
No related branches found
No related tags found
No related merge requests found
......@@ -6,62 +6,14 @@
#include "ESeries.h"
const unsigned int ESeries::resDec12[] = {100, 120, 150, 180, 220, 270,
330, 390, 470, 560, 680, 820};
// Q_DECLARE_METATYPE(ESeries<e12>)
// Q_DECLARE_METATYPE(ESeries<e24>)
const unsigned int ESeries::resDec24[] = {
template<SeriesType SerieType>
const unsigned int ESeries<SerieType>::resDec12[] = {
100, 120, 150, 180, 220, 270, 330, 390, 470, 560, 680, 820};
template<SeriesType SerieType>
const unsigned int ESeries<SerieType>::resDec24[] = {
100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270, 300,
330, 360, 390, 430, 470, 510, 560, 620, 680, 750, 820, 910};
ESeries::Series& operator++(ESeries::Series& serie)
{
switch (serie)
{
case ESeries::e12:
serie = ESeries::e24;
break;
case ESeries::e24:
default:
serie = ESeries::e12;
}
return serie;
}
ESeries::ESeries(Series dec)
{
switch (dec)
{
case e12:
values = resDec12;
elemCnt = sizeof(resDec12) / sizeof(unsigned int);
name = "E12";
break;
case e24:
values = resDec24;
elemCnt = sizeof(resDec24) / sizeof(unsigned int);
name = "E24";
break;
}
}
unsigned int ESeries::getLowerOrEqIndex(double upperRTh) const
{
int i;
for (i = elemCnt - 1; i > 0; --i)
{
if (upperRTh >= values[i])
break;
}
return i > 0 ? i - 1 : 0;
}
unsigned int ESeries::getUpperOrEqIndex(double lowerRTh) const
{
unsigned int i;
for (i = 0; i < elemCnt; ++i)
{
if (lowerRTh <= values[i])
break;
}
return i;
}
......@@ -10,19 +10,53 @@
#include <QMetaType>
#include <QString>
#include <cassert>
#include "ISeries.h"
enum SeriesType
{
e12,
e24
};
template<SeriesType>
struct ResSerie
{
static const unsigned int values[1];
static const unsigned int elemCnt = 0;
constexpr static const char name[] = "E12";
};
template<>
struct ResSerie<SeriesType::e12>
{
constexpr static const unsigned int values[] = {100, 120, 150, 180, 220, 270,
330, 390, 470, 560, 680, 820};
constexpr static const unsigned int elemCnt =
sizeof(values) / sizeof(values[0]);
constexpr static const char name[] = "E12";
};
///
/// \brief operator ++ overloaded prefix operator for ESeries::Series enum. This
/// operator can be used to iterate through the enum.
/// \param serie ESeries::Series enum object on which is incremented
/// \return returns the next ESeries::Series enum entry.
///
template<SeriesType SerieType>
SeriesType& operator++(SeriesType& serie);
///
/// \brief An object of the ESeries class represents a resistor E-Serie. Eg.
/// E12, E24
///
class ESeries : public ISeries {
template<SeriesType SerieType>
class ESeries
{
public:
///
/// \brief ESeries
/// \param serie defines which e-serie the object represents
///
ESeries(Series serie = e24);
ESeries(double value = 0, bool searchAboveValue = true);
///
/// \brief getElemCnt function is a getter to get the count of the e-serie
......@@ -30,7 +64,7 @@ class ESeries : public ISeries {
///
unsigned int getElemCnt() const
{
return elemCnt;
return ResSerie<SerieType>::elemCnt;
}
///
......@@ -43,84 +77,133 @@ class ESeries : public ISeries {
///
const unsigned int& operator[](int index) const
{
assert(index < static_cast<int>(elemCnt));
assert(index < static_cast<int>(ResSerie<SerieType>::elemCnt));
assert(index >= 0);
return values[index];
return ResSerie<SerieType>::values[index];
}
///
/// \brief Compares the content equality of two E-Serie objects.
/// LHS object is this. The this pointer points to the
/// RHS object.
/// \param rhs is the right hand side object to compare for the equality
/// \return true if the rhs object equals to the this object
///
bool operator==(const ISeries& rightHandSide) const
bool operator<(const ESeries<SerieType>& rhs) const
{
const ESeries* rhs = dynamic_cast<const ESeries*>(&rightHandSide);
if (0 == rhs)
return false;
bool equal = true;
if (elemCnt != rhs->elemCnt)
equal = false;
if (name != rhs->name)
equal = false;
return ResSerie<SerieType>::values[index] <
ResSerie<SerieType>::values[rhs.index];
}
bool operator>(const ESeries<SerieType>& rhs) const
{
return ResSerie<SerieType>::values[index] >
ResSerie<SerieType>::values[rhs.index];
}
for (unsigned int i = 0; i < elemCnt; ++i)
ESeries& operator++()
{
if (index++ > ResSerie<SerieType>::elemCnt)
{
if (values[i] != rhs->values[i])
equal = false;
index = 0;
exp++;
}
return equal;
return *this;
}
ESeries operator+(const ESeries& rhs)
{
ESeries<SerieType> ret;
ret.index = index + rhs.index;
if (ret.index > ResSerie<SerieType>::elemCnt)
index -= ResSerie<SerieType>::elemCnt;
exp += rhs.exp;
return ret;
}
ESeries operator*(const ESeries& rhs)
{
ESeries<SerieType> ret;
}
///
/// \brief get the name of the serie as QString. For example: E24.
/// \return the name of the e-serie as QString
///
const QString& getName() const
QString getName() const
{
return name;
return QString(ResSerie<SerieType>::name);
}
///
/// \brief getLowerOrEqIndex used to check against lower or equal
/// value in e-serie and get the index of the closest value.
/// \param upperRTh value of the resistor to check. Must be in the interval
/// between 100 and 1000
/// \return the index of the best matching value
///
unsigned int getLowerOrEqIndex(double upperRTh) const;
///
/// \brief getUpperOrEqIndex used to check against greater or equal value in
/// e-serie and get the index of the closest value.
/// \param lowerRTh value of the resistor to check. Must be in the interval
/// between 100 and 1000
/// \return the index of the best matching value
///
unsigned int getUpperOrEqIndex(double lowerRTh) const;
ESeries<SerieType>& operator=(ESeries<SerieType>& rhs)
{
*this =
}
private:
const unsigned int* values;
unsigned int elemCnt;
QString name;
enum
{
normExp = 2
};
unsigned int index;
int exp;
static const unsigned int resDec12[];
static const unsigned int resDec24[];
void init(Series dec);
unsigned int getLowerOrEqIndex(double value) const;
unsigned int getUpperOrEqIndex(double value) const;
double getValue() const
{
return ResSerie<SerieType>::values[index] * pow(normExp - exp);
}
};
///
/// \brief operator ++ overloaded prefix operator for ESeries::Series enum. This
/// operator can be used to iterate through the enum.
/// \param serie ESeries::Series enum object on which is incremented
/// \return returns the next ESeries::Series enum entry.
///
ESeries::Series& operator++(ESeries::Series& serie);
Q_DECLARE_METATYPE(ESeries)
SeriesType& operator++(SeriesType& serie)
{
switch (serie)
{
case e12:
serie = e24;
break;
case e24:
default:
serie = e12;
}
return serie;
}
template<SeriesType SerieType>
ESeries<SerieType>::ESeries(double value, bool searchAboveValue)
{
if (searchAboveValue)
index = getUpperOrEqIndex(value);
else
index = getLowerOrEqIndex(value);
exp = log10(value);
}
template<SeriesType SerieType>
unsigned int ESeries<SerieType>::getLowerOrEqIndex(double value) const
{
int upperExp = log10(value);
double upperNormRTh = value * pow(10.0, normExp - upperExp);
int i;
for (i = ResSerie<SerieType>::elemCnt - 1; i > 0; --i)
{
if (upperNormRTh >= ResSerie<SerieType>::values[i])
break;
}
return i > 0 ? i - 1 : 0;
}
template<SeriesType SerieType>
unsigned int ESeries<SerieType>::getUpperOrEqIndex(double value) const
{
int lowerExp = log10(value);
double lowerNormRTh = value * pow(10.0, normExp - lowerExp);
unsigned int i;
for (i = 0; i < ResSerie<SerieType>::elemCnt; ++i)
{
if (lowerNormRTh <= ResSerie<SerieType>::values[i])
break;
}
return i;
}
#endif // ESERIES_H
#ifndef ISERIES_H
#define ISERIES_H
#include <QString>
class ISeries {
public:
///
/// \brief The Series enum used to define which e-serie the object should
/// represent. This can be done whith the ctor parameter
///
enum Series
{
e12,
e24
};
///
/// \brief public anonymous enum which conaints constants
///
enum
{
nrOfSeries = 2
};
///
/// \brief ~ISeries D'tor
///
virtual ~ISeries()
{
}
///
/// \brief getElemCnt function is a getter to get the count of the e-serie
/// \return Element count of the serie the object represents
///
virtual unsigned int getElemCnt() const = 0;
///
/// \brief operator [] to get an element of the serie with an index.
/// \pre index < size of serie (element count)
/// \pre index >= 0
/// \param index of the element to be returned
/// \return the element that at the index position in the serie represented
/// by the object
///
virtual const unsigned int& operator[](int index) const = 0;
///
/// \brief Compares the content equality of two E-Serie objects.
/// LHS object is this. The this pointer points to the
/// RHS object.
/// \param rhs is the right hand side object to compare for the equality
/// \return true if the rhs object equals to the this object
///
virtual bool operator==(const ISeries& rhs) const = 0;
///
/// \brief get the name of the serie as QString. For example: E24.
/// \return the name of the e-serie as QString
///
virtual const QString& getName() const = 0;
///
/// \brief getLowerOrEqIndex used to check against lower or equal
/// value in e-serie and get the index of the closest value.
/// \param upperRTh value of the resistor to check. Must be in the interval
/// between 100 and 1000
/// \return the index of the best matching value
///
virtual unsigned int getLowerOrEqIndex(double upperRTh) const = 0;
///
/// \brief getUpperOrEqIndex used to check against greater or equal value in
/// e-serie and get the index of the closest value.
/// \param lowerRTh value of the resistor to check. Must be in the interval
/// between 100 and 1000
/// \return the index of the best matching value
///
virtual unsigned int getUpperOrEqIndex(double lowerRTh) const = 0;
};
#endif // ISERIES_H
......@@ -8,83 +8,3 @@
#include <cassert>
#include <cmath>
#include <limits>
VoltageDivider::VoltageDivider()
{
}
VoltageDivider::ResultingResistors VoltageDivider::calc(double u1, double u2,
double lowerRTh,
double upperRTh,
const ISeries& resSerie)
{
assert(u1 > u2);
assert(u2 > 0);
assert(lowerRTh < upperRTh);
assert(1 <= lowerRTh);
int lowerExp = log10(lowerRTh);
int upperExp = log10(upperRTh);
double lowerNormRTh = lowerRTh * pow(10.0, destExp - lowerExp);
double upperNormRTh = upperRTh * pow(10.0, destExp - upperExp);
unsigned int lowerIdx = resSerie.getUpperOrEqIndex(lowerNormRTh);
unsigned int upperIdx = resSerie.getLowerOrEqIndex(upperNormRTh);
if (upperIdx < lowerIdx)
throw std::runtime_error(
"choosen rmax, rmin are not valid for corresponding E-Serie.");
double dMin = std::numeric_limits<double>::infinity();
double rMin = resSerie[lowerIdx] * pow(10, lowerExp - destExp);
double rMax = resSerie[upperIdx] * pow(10, upperExp - destExp);
double r1 = 0;
double r2 = 0;
for (int expR1 = (lowerExp - destExp); expR1 <= (upperExp - destExp); ++expR1)
{
unsigned int r1Idx = 0;
if (resSerie[r1Idx] * pow(10, expR1) < rMin)
r1Idx = lowerIdx;
for (; r1Idx < resSerie.getElemCnt(); r1Idx++)
{
double r1e = resSerie[r1Idx] * pow(10, expR1);
if (r1e > rMax)
break;
for (int expR2 = (lowerExp - destExp); expR2 <= (upperExp - destExp);
++expR2)
{
unsigned int r2Idx = 0;
if (resSerie[r2Idx] * pow(10, expR2) < rMin)
r2Idx = lowerIdx;
for (; r2Idx < resSerie.getElemCnt(); ++r2Idx)
{
double r2e = resSerie[r2Idx] * pow(10, expR2);
if (r2e > rMax)
break;
double ua = u1 / (r1e + r2e) * r1e;
double d;
d = ua > u2 ? ua - u2 : u2 - ua;
if (d < dMin)
{
dMin = d;
r1 = r1e;
r2 = r2e;
}
}
}
}
}
assert(r1 <= upperRTh);
assert(lowerRTh <= r1);
assert(r2 <= upperRTh);
assert(lowerRTh <= r2);
ResultingResistors resResistors;
resResistors.r1 = r1;
resResistors.r2 = r2;
return resResistors;
}
......@@ -9,12 +9,14 @@
#include <QObject>
#include <QString>
#include "ISeries.h"
#include "ESeries.h"
///
/// \brief The VoltageDivider class
///
class VoltageDivider {
template<SeriesType SerieType>
class VoltageDivider
{
public:
///
/// \brief The ResultingResistors struct
......@@ -47,15 +49,52 @@ class VoltageDivider {
/// \return returns the resulting restistor values if calculation finishes
/// successful. Otherwise 0 is returned in r1 and r2.
///
static ResultingResistors calc(double u1, double u2, double lowerRTh,
double upperRTh, const ISeries& resSerie);
static ResultingResistors calc(double u1, double u2,
const ESeries<SerieType>& lowerRTh,
const ESeries<SerieType>& upperRTh)
{
assert(u1 > u2);
assert(u2 > 0);
double dMin = std::numeric_limits<double>::infinity();
double r1saved;
double r2saved;
for (ESeries<SerieType> r1 = lowerRTh; r1 < upperRTh; ++r1)
{
for (ESeries<SerieType> r2 = lowerRTh; r2 < upperRTh; ++r2)
{
double r = (r1 + r2) * r1;
double ua = u1 / r;
double d;
d = ua > u2 ? ua - u2 : u2 - ua;
if (d < dMin)
{
dMin = d;
r1saved = r1;
r2saved = r2;
}
}
}
assert(r1saved <= upperRTh);
assert(lowerRTh <= r1saved);
assert(r2saved <= upperRTh);
assert(lowerRTh <= r2saved);
ResultingResistors resResistors;
resResistors.r1 = r1saved;
resResistors.r2 = r2saved;
return resResistors;
}
private:
///
/// \brief VoltageDivider Ctor is private to restrict any instantiation of
/// this class.
///
VoltageDivider();
VoltageDivider()
{
}
enum
{
......
......@@ -20,7 +20,6 @@ HEADERS += \
VoltageDividerWidget.h \
../../src/ESeries.h \
VoltageDivider.h \
../../src/ISeries.h \
SOURCES += \
main.cpp \
......
#include "ESeriesMock.h"
#ifndef ESERIESMOCK_H
#define ESERIESMOCK_H
#include <cassert>
#include "../../src/ISeries.h"
class ESeriesMock : public ISeries {
public:
ESeriesMock()
: equalReturnValue(false), dummyString("dummy"), lowIdxRetVal(0),
upperIdxRetVal(0)
{
for (int i = 0; i < nrOfElems; ++i)
element[i] = 0;
}
///
/// \brief ~ISeries D'tor
///
virtual ~ESeriesMock()
{
}
///
/// \brief getElemCnt function is a getter to get the count of the e-serie
/// \return Element count of the serie the object represents
///
virtual unsigned int getElemCnt() const
{
return 2;
}
///
/// \brief operator [] to get an element of the serie with an index.
/// \pre index < size of serie (element count)
/// \pre index >= 0
/// \param index of the element to be returned
/// \return the element that at the index position in the serie represented
/// by the object
///
virtual const unsigned int& operator[](int index) const
{
assert(nrOfElems > index);
return element[index];
}
///
/// \brief Compares the content equality of two E-Serie objects.
/// LHS object is this. The this pointer points to the
/// RHS object.
/// \param rhs is the right hand side object to compare for the equality
/// \return true if the rhs object equals to the this object
///
virtual bool operator==(const ISeries& rhs) const
{
(void) rhs;
return equalReturnValue;
}
///
/// \brief get the name of the serie as QString. For example: E24.
/// \return the name of the e-serie as QString
///
virtual const QString& getName() const
{
return dummyString;
}
///
/// \brief getLowerOrEqIndex used to check against lower or equal
/// value in e-serie and get the index of the closest value.
/// \param upperRTh value of the resistor to check. Must be in the interval
/// between 100 and 1000
/// \return the index of the best matching value
///
virtual unsigned int getLowerOrEqIndex(double upperRTh) const
{
(void) upperRTh;
return lowIdxRetVal;
}
///
/// \brief getUpperOrEqIndex used to check against greater or equal value in
/// e-serie and get the index of the closest value.
/// \param lowerRTh value of the resistor to check. Must be in the interval
/// between 100 and 1000
/// \return the index of the best matching value
///
virtual unsigned int getUpperOrEqIndex(double lowerRTh) const
{
(void) lowerRTh;
return upperIdxRetVal;
}
// Mock specific methods
void setEqualOperatorReturnValue(bool value)
{
equalReturnValue = value;
}
void setLowerIdxReturnValue(unsigned int lowIdxRetVal)
{
this->lowIdxRetVal = lowIdxRetVal;
}
void setUpperIdxReturnValue(unsigned int upperIdxRetVal)
{
this->upperIdxRetVal = upperIdxRetVal;
}
void setArrayElement(unsigned int index, unsigned int value)
{
assert(nrOfElems > index);
element[index] = value;
}
private:
enum
{
nrOfElems = 2
};
unsigned int element[nrOfElems];
bool equalReturnValue;
QString dummyString;
unsigned int lowIdxRetVal;
unsigned int upperIdxRetVal;
unsigned int arrayOperatorRetVal;
};
#endif // ESERIESMOCK_H
......@@ -9,7 +9,6 @@
#include <cfloat>
#include <cmath>
#include "../../src/VoltageDivider.h"
#include "ESeriesMock.h"
using namespace testing;
......@@ -19,114 +18,117 @@ using namespace testing;
///
TEST(VoltageDivider, testCalc_iec11)
{
ESeriesMock eSerie;
EXPECT_DEATH(VoltageDivider::ResultingResistors res =
VoltageDivider::calc(nextafter(0, -1), 5, 1.1, 9900, eSerie),
"");
ESeries<e12> lowerR;
ESeries<e12> upperR;
EXPECT_DEATH(
VoltageDivider<e12>::ResultingResistors res =
VoltageDivider<e12>::calc(nextafter(0, -1), 5, lowerR, upperR),
"");
}
TEST(VoltageDivider, testCalc_iec21)
{
ESeriesMock eSerie;
EXPECT_DEATH(VoltageDivider::ResultingResistors res =
VoltageDivider::calc(5, nextafter(0, -1), 1.1, 9900, eSerie),
"");
}
TEST(VoltageDivider, testCalc_iec31_1)
{
ESeriesMock eSerie;
EXPECT_DEATH(VoltageDivider::ResultingResistors res =
VoltageDivider::calc(5, 4, nextafter(1, 0), 9900, eSerie),
"");
}
TEST(VoltageDivider, testCalc_iec31_2)
{
ESeriesMock eSerie;
EXPECT_DEATH(VoltageDivider::ResultingResistors res =
VoltageDivider::calc(5, 4, nextafter(0, -1), 9900, eSerie),
"");
}
TEST(VoltageDivider, testCalc_iec41)
{
ESeriesMock eSerie;
EXPECT_DEATH(VoltageDivider::ResultingResistors res =
VoltageDivider::calc(5, 4, 9900, nextafter(0, -1), eSerie),
"");
}
TEST(VoltageDivider, testCalc_vec61_1)
{
double u2 = nextafter(0, 1);
double u1 = nextafter(u2, 1);
double lowRth = 1;
double upRth = nextafter(lowRth, 2);
ESeriesMock eSerie;
eSerie.setArrayElement(0, 100);
eSerie.setArrayElement(1, 220);
VoltageDivider::ResultingResistors res;
res = VoltageDivider::calc(u1, u2, lowRth, upRth, eSerie);
EXPECT_DOUBLE_EQ(res.r1, 1.0);
EXPECT_DOUBLE_EQ(res.r2, 1.0);
}
TEST(VoltageDivider, testCalc_vec61_2)
{
double u1 = nextafter(DBL_MAX, 1);
double u2 = nextafter(u1, 1);
double lowRth = 100;
double upRth = 220;
ESeriesMock eSerie;
eSerie.setArrayElement(0, 100);
eSerie.setArrayElement(1, 220);
eSerie.setLowerIdxReturnValue(1);
VoltageDivider::ResultingResistors res;
res = VoltageDivider::calc(u1, u2, lowRth, upRth, eSerie);
// TODO: ESeriesTest und ESeriesMock
}
TEST(VoltageDivider, testCalc_vec61_3)
{
double u1 = 12;
double u2 = 5;
double upRth = nextafter(DBL_MAX, 1);
double lowRth = nextafter(upRth, 1);
ESeriesMock eSerie;
VoltageDivider::ResultingResistors res =
VoltageDivider::calc(u1, u2, lowRth, upRth, eSerie);
EXPECT_DOUBLE_EQ(res.r1, 1.0);
EXPECT_DOUBLE_EQ(res.r2, 1.0);
}
TEST(VoltageDivider, testCalc_vec62)
{
double u1 = nextafter(DBL_MAX, 1);
double u2 = nextafter(u1, 1);
double lowRth = nextafter(1, 2);
double upRth = nextafter(lowRth, 2);
ESeriesMock eSerie;
VoltageDivider::ResultingResistors res =
VoltageDivider::calc(u1, u2, lowRth, upRth, eSerie);
EXPECT_DOUBLE_EQ(res.r1, 1.0);
EXPECT_DOUBLE_EQ(res.r2, 1.0);
}
TEST(VoltageDivider, testCalc_iec61)
{
ESeriesMock eSerie;
VoltageDivider::ResultingResistors res =
VoltageDivider::calc(12, 11, 100, 10000, eSerie);
EXPECT_NEAR(res.r1, 330, 0.01);
EXPECT_NEAR(res.r2, 3900, 0.01);
}
// TEST(VoltageDivider, testCalc_iec21)
//{
// ESeriesMock eSerie;
// EXPECT_DEATH(VoltageDivider::ResultingResistors res =
// VoltageDivider::calc(5, nextafter(0, -1), 1.1, 9900,
// eSerie),
// "");
//}
// TEST(VoltageDivider, testCalc_iec31_1)
//{
// ESeriesMock eSerie;
// EXPECT_DEATH(VoltageDivider::ResultingResistors res =
// VoltageDivider::calc(5, 4, nextafter(1, 0), 9900, eSerie),
// "");
//}
// TEST(VoltageDivider, testCalc_iec31_2)
//{
// ESeriesMock eSerie;
// EXPECT_DEATH(VoltageDivider::ResultingResistors res =
// VoltageDivider::calc(5, 4, nextafter(0, -1), 9900, eSerie),
// "");
//}
// TEST(VoltageDivider, testCalc_iec41)
//{
// ESeriesMock eSerie;
// EXPECT_DEATH(VoltageDivider::ResultingResistors res =
// VoltageDivider::calc(5, 4, 9900, nextafter(0, -1), eSerie),
// "");
//}
// TEST(VoltageDivider, testCalc_vec61_1)
//{
// double u2 = nextafter(0, 1);
// double u1 = nextafter(u2, 1);
// double lowRth = 1;
// double upRth = nextafter(lowRth, 2);
// ESeriesMock eSerie;
// eSerie.setArrayElement(0, 100);
// eSerie.setArrayElement(1, 120);
// VoltageDivider::ResultingResistors res;
// res = VoltageDivider::calc(u1, u2, lowRth, upRth, eSerie);
// EXPECT_DOUBLE_EQ(res.r1, 1.0);
// EXPECT_DOUBLE_EQ(res.r2, 1.0);
//}
// TEST(VoltageDivider, testCalc_vec61_2)
//{
// double u1 = DBL_MAX;
// double u2 = nextafter(u1, 1);
// double lowRth = nextafter(820, 1);
// double upRth = DBL_MAX;
// ESeriesMock eSerie;
// eSerie.setArrayElement(0, 680);
// eSerie.setArrayElement(1, 820);
// eSerie.setLowerIdxReturnValue(1);
// VoltageDivider::ResultingResistors res;
// res = VoltageDivider::calc(u1, u2, lowRth, upRth, eSerie);
// // TODO: ESeriesTest und ESeriesMock
//}
// TEST(VoltageDivider, testCalc_vec61_3)
//{
// double u1 = 12;
// double u2 = 5;
// double upRth = nextafter(DBL_MAX, 1);
// double lowRth = nextafter(upRth, 1);
// ESeriesMock eSerie;
// VoltageDivider::ResultingResistors res =
// VoltageDivider::calc(u1, u2, lowRth, upRth, eSerie);
// EXPECT_DOUBLE_EQ(res.r1, 1.0);
// EXPECT_DOUBLE_EQ(res.r2, 1.0);
//}
// TEST(VoltageDivider, testCalc_vec62)
//{
// double u1 = nextafter(DBL_MAX, 1);
// double u2 = nextafter(u1, 1);
// double lowRth = nextafter(1, 2);
// double upRth = nextafter(lowRth, 2);
// ESeriesMock eSerie;
// VoltageDivider::ResultingResistors res =
// VoltageDivider::calc(u1, u2, lowRth, upRth, eSerie);
// EXPECT_DOUBLE_EQ(res.r1, 1.0);
// EXPECT_DOUBLE_EQ(res.r2, 1.0);
//}
// TEST(VoltageDivider, testCalc_iec61)
//{
// ESeriesMock eSerie;
// VoltageDivider::ResultingResistors res =
// VoltageDivider::calc(12, 11, 100, 10000, eSerie);
// EXPECT_NEAR(res.r1, 330, 0.01);
// EXPECT_NEAR(res.r2, 3900, 0.01);
//}
......@@ -18,15 +18,13 @@ QT -= gui
HEADERS += \
../../src/VoltageDivider.h \
../../src/ESeries.h \
../../src/ISeries.h \
ESeriesMock.h
../../src/ISeries.h
SOURCES += \
main.cpp \
../../src/VoltageDivider.cpp \
../../src/ESeries.cpp \
VoltageDividerTest.cpp \
ESeriesMock.cpp
VoltageDividerTest.cpp
#GoogleTest Settings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment