style changes and removals of typeid

refs #81
This commit is contained in:
Klaus Basan
2013-12-22 20:28:56 +00:00
committed by Mathew Sutcliffe
parent 229d7c6068
commit 978f3c88e5
73 changed files with 7356 additions and 7130 deletions

View File

@@ -4,6 +4,13 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "samplesaviation.h"
#include "blackmisc/pqconstants.h"
#include "blackmisc/avheading.h"
#include "blackmisc/aviocomsystem.h"
#include "blackmisc/avionavsystem.h"
#include "blackmisc/aviotransponder.h"
#include <QDebug>
using namespace BlackMisc::Aviation;
using namespace BlackMisc::PhysicalQuantities;
@@ -11,51 +18,54 @@ using namespace BlackMisc::PhysicalQuantities;
namespace BlackMiscTest
{
/*
* Samples
*/
int CSamplesAviation::samples()
{
CHeading h1(180, CHeading::Magnetic, CAngleUnit::deg());
CHeading h2(180, CHeading::True, CAngleUnit::deg());
qDebug() << h1;
qDebug() << h1 << h2 << (h1 == h2) << (h1 != h2) << (h1 == h1);
CComSystem c1 = CComSystem::getCom1System(125.3);
qDebug() << c1;
c1.setActiveUnicom();
qDebug() << c1;
// CComSystem *c1p = new CComSystem("Test", CFrequency(125.3,CFrequencyUnit::MHz()));
if (!CComSystem::tryGetComSystem(c1, "Test", -1.0))
qDebug() << c1 << "is reset to default as expected";
else
qDebug() << "Something is wrong here";
try
/*
* Samples
*/
int CSamplesAviation::samples()
{
// uncomment to test assert
// CFrequency f1(-1.0, CFrequencyUnit::MHz());
// c1 = CComSystem("ups", f1, f1);
// qDebug() << "Why do I get here??";
CHeading h1(180, CHeading::Magnetic, CAngleUnit::deg());
CHeading h2(180, CHeading::True, CAngleUnit::deg());
qDebug() << h1;
qDebug() << h1 << h2 << (h1 == h2) << (h1 != h2) << (h1 == h1);
// COM system
CComSystem c1 = CComSystem::getCom1System(125.3);
qDebug() << c1;
c1.setActiveUnicom();
qDebug() << c1;
if (!CComSystem::tryGetComSystem(c1, "Test", -1.0))
qDebug() << c1 << "is reset to default as expected";
else
qDebug() << "Something is wrong here";
try
{
// uncomment to test assert
// CFrequency f1(-1.0, CFrequencyUnit::MHz());
// c1 = CComSystem("ups", f1, f1);
// qDebug() << "Why do I get here??";
}
catch (std::range_error &ex)
{
qDebug() << "As expected" << ex.what();
}
// NAV system
CNavSystem nav1;
CNavSystem::tryGetNav1System(nav1, 110.0);
qDebug() << nav1;
// Transponder tests
CTransponder tr1("T1", 7000, CTransponder::StateStandby);
CTransponder tr2("T2", "4532", CTransponder::ModeMil3);
qDebug() << tr1 << tr2;
qDebug() << "-----------------------------------------------";
return 0;
}
catch (std::range_error &ex)
{
qDebug() << "As expected" << ex.what();
}
CNavSystem nav1;
CNavSystem::tryGetNav1System(nav1, 110.0);
qDebug() << nav1;
CTransponder tr1("T1", 7000, CTransponder::StateStandby);
CTransponder tr2("T2", "4532", CTransponder::ModeMil3);
qDebug() << tr1 << tr2;
// bye
qDebug() << "-----------------------------------------------";
return 0;
}
} // namespace

View File

@@ -6,13 +6,6 @@
#ifndef BLACKMISCTEST_SAMPLESAVIATION_H
#define BLACKMISCTEST_SAMPLESAVIATION_H
#include "blackmisc/pqconstants.h"
#include "blackmisc/avheading.h"
#include "blackmisc/aviocomsystem.h"
#include "blackmisc/avionavsystem.h"
#include "blackmisc/aviotransponder.h"
#include <QDebug>
namespace BlackMiscTest {
/*!

View File

@@ -10,109 +10,108 @@ using namespace BlackMisc::PhysicalQuantities;
namespace BlackMiscTest
{
/**
* Running the quantities
*/
int CSamplesPhysicalQuantities::samples()
{
// cases which must not work
// CLengthUnit du1(CAngleUnit::rad());
/**
* Running the quantities
*/
int CSamplesPhysicalQuantities::samples()
{
// cases which must not work
// CLengthUnit du1(CAngleUnit::rad());
CLengthUnit lu1(CLengthUnit::cm());
CLengthUnit lu2(CLengthUnit::ft());
QString lu1s = lu1.toQString(true);
QString lu2s = lu2.toQString(true);
qDebug() << lu1 << lu2 << lu1s << lu2s << lu1.getName(true) << lu2.getName(true);
const CLength l1(5.0, CLengthUnit::ft()); // 5 ft
CLength l2(1, CLengthUnit::NM()); // 1NM
CLength l3(1, CLengthUnit::km());
CLength l4(l3);
CLengthUnit lu1(CLengthUnit::cm());
CLengthUnit lu2(CLengthUnit::ft());
QString lu1s = lu1.toQString(true);
QString lu2s = lu2.toQString(true);
qDebug() << lu1 << lu2 << lu1s << lu2s << lu1.getName(true) << lu2.getName(true);
const CLength l1(5.0, CLengthUnit::ft()); // 5 ft
CLength l2(1, CLengthUnit::NM()); // 1NM
CLength l3(1, CLengthUnit::km());
CLength l4(l3);
qDebug() << CLengthUnit::ft();
qDebug() << l1 << l2 << l3 << l4;
qDebug() << l1.valueRoundedWithUnit(CLengthUnit::ft(), 5)
<< l2.valueRoundedWithUnit(CLengthUnit::km());
qDebug() << l3.getUnit();
qDebug() << CLengthUnit::ft();
qDebug() << l1 << l2 << l3 << l4;
qDebug() << l1.valueRoundedWithUnit(CLengthUnit::ft(), 5)
<< l2.valueRoundedWithUnit(CLengthUnit::km());
qDebug() << l3.getUnit();
l2.switchUnit(CLengthUnit::ft()); // now in ft
l3 += l3; // 2km now
l3 *= 1.5;// 3km now
qDebug() << l2 << l3;
l2.switchUnit(CLengthUnit::ft()); // now in ft
l3 += l3; // 2km now
l3 *= 1.5;// 3km now
qDebug() << l2 << l3;
l3 = l3 * 2;
qDebug() << "doubled l3:" << l3;
l3 = l3 * 2;
qDebug() << "doubled l3:" << l3;
// more tests
CFrequency f1(1E6, CFrequencyUnit::Hz()); // 1MHz
qDebug() << f1 << f1.valueRoundedWithUnit(CFrequencyUnit::MHz()) << f1.valueRoundedWithUnit(CFrequencyUnit::GHz(), 3);
CSpeed s1 = CSpeed(100, CSpeedUnit::km_h());
CSpeed s2 = CSpeed(1000, CSpeedUnit::ft_min());
CSpeed s3 = CSpeed(s2);
s3.switchUnit(CSpeedUnit::m_s());
qDebug() << s1 << s1.valueRoundedWithUnit(CSpeedUnit::defaultUnit()) << s1.valueRoundedWithUnit(CSpeedUnit::NM_h());
qDebug() << s2 << s3;
CFrequency f1(1E6, CFrequencyUnit::Hz()); // 1MHz
qDebug() << f1 << f1.valueRoundedWithUnit(CFrequencyUnit::MHz()) << f1.valueRoundedWithUnit(CFrequencyUnit::GHz(), 3);
CAngle a1(180, CAngleUnit::deg());
CAngle a2(1.5 * CAngle::PI(), CAngleUnit::rad());
CAngle a3(180.5, CAngleUnit::deg());
CAngle a4(35.4336, CAngleUnit::sexagesimalDeg()); // 35.72666
a1 += a2;
// a1 = d2; // must not work
qDebug() << a1;
a1.switchUnit(CAngleUnit::deg());
// a2 += d1; // must not work
a2 = a1 + a1;
CSpeed s1 = CSpeed(100, CSpeedUnit::km_h());
CSpeed s2 = CSpeed(1000, CSpeedUnit::ft_min());
CSpeed s3 = CSpeed(s2);
s3.switchUnit(CSpeedUnit::m_s());
qDebug() << s1 << s1.valueRoundedWithUnit(CSpeedUnit::defaultUnit()) << s1.valueRoundedWithUnit(CSpeedUnit::NM_h());
qDebug() << s2 << s3;
a2.switchUnit(CAngleUnit::deg());
qDebug() << a1.valueRoundedWithUnit() << a1.piFactor();
qDebug() << a2;
a3.switchUnit(CAngleUnit::sexagesimalDeg());
a4.switchUnit(CAngleUnit::deg());
qDebug() << a3 << a4;
CAngle a1(180, CAngleUnit::deg());
CAngle a2(1.5 * CAngle::PI(), CAngleUnit::rad());
CAngle a3(180.5, CAngleUnit::deg());
CAngle a4(35.4336, CAngleUnit::sexagesimalDeg()); // 35.72666
a1 += a2;
// a1 = d2; // must not work
qDebug() << a1;
a1.switchUnit(CAngleUnit::deg());
// a2 += d1; // must not work
a2 = a1 + a1;
CMass w1(1, CMassUnit::tonne());
CMass w2(w1);
w2.switchUnit(CMassUnit::lb());
qDebug() << w1 << w1.valueRoundedWithUnit(CMassUnit::kg()) << w2;
a2.switchUnit(CAngleUnit::deg());
qDebug() << a1.valueRoundedWithUnit() << a1.piFactor();
qDebug() << a2;
a3.switchUnit(CAngleUnit::sexagesimalDeg());
a4.switchUnit(CAngleUnit::deg());
qDebug() << a3 << a4;
CPressure p1(1013.25, CPressureUnit::hPa());
qDebug() << p1 << p1.valueRoundedWithUnit(CPressureUnit::psi()) << p1.valueRoundedWithUnit(CPressureUnit::inHg());
CMass w1(1, CMassUnit::tonne());
CMass w2(w1);
w2.switchUnit(CMassUnit::lb());
qDebug() << w1 << w1.valueRoundedWithUnit(CMassUnit::kg()) << w2;
CTemperature t1;
CTemperature t2(20, CTemperatureUnit::C());
CTemperature t3(1, CTemperatureUnit::F());
qDebug() << t1 << t2 << t2.valueRoundedWithUnit(CTemperatureUnit::defaultUnit(), -1, true);
qDebug() << t3.valueRoundedWithUnit(CTemperatureUnit::F(), -1, true) << t3.valueRoundedWithUnit(CTemperatureUnit::C(), -1, true) << "I18N/UTF";
CPressure p1(1013.25, CPressureUnit::hPa());
qDebug() << p1 << p1.valueRoundedWithUnit(CPressureUnit::psi()) << p1.valueRoundedWithUnit(CPressureUnit::inHg());
// some logging with CLogMessage
// bDebug << p1;
// bDebug << p1.getUnit() << p1.getUnit().getMultiplier();
CTemperature t1;
CTemperature t2(20, CTemperatureUnit::C());
CTemperature t3(1, CTemperatureUnit::F());
qDebug() << t1 << t2 << t2.valueRoundedWithUnit(CTemperatureUnit::defaultUnit(), -1, true);
qDebug() << t3.valueRoundedWithUnit(CTemperatureUnit::F(), -1, true) << t3.valueRoundedWithUnit(CTemperatureUnit::C(), -1, true) << "I18N/UTF";
// some of the faults Mathew has pointed out, not longer possible
// CAngleUnit::rad() = CAngleUnit::deg();
// qDebug() << CAngleUnit::rad(); // wrong
// some logging with CLogMessage
// bDebug << p1;
// bDebug << p1.getUnit() << p1.getUnit().getMultiplier();
(t1 - t2).switchUnit(CTemperatureUnit::F()); // was not working since wrong return type const
// CLengthUnit duA(CSpeedUnit::ft_min()); // no longer possible
CLengthUnit duB(CLengthUnit::cm());
qDebug() << duB;
// some of the faults Mathew has pointed out, not longer possible
// CAngleUnit::rad() = CAngleUnit::deg();
// qDebug() << CAngleUnit::rad(); // wrong
CTime ti1(1, CTimeUnit::h());
CTime ti2(ti1);
ti2.switchUnit(CTimeUnit::ms());
CTime ti3(1.0101, CTimeUnit::hms());
CTime ti4(1.15, CTimeUnit::hrmin());
CTime ti5(1.30, CTimeUnit::minsec());
qDebug() << ti1 << ti2 << ti3 << ti4 << ti5;
(t1 - t2).switchUnit(CTemperatureUnit::F()); // was not working since wrong return type const
// CLengthUnit duA(CSpeedUnit::ft_min()); // no longer possible
CLengthUnit duB(CLengthUnit::cm());
qDebug() << duB;
CAcceleration ac1(10, CAccelerationUnit::m_s2());
qDebug() << ac1 << ac1.toQString(true) << ac1.valueRoundedWithUnit(-1, true) << "I18N/UTF";
CTime ti1(1, CTimeUnit::h());
CTime ti2(ti1);
ti2.switchUnit(CTimeUnit::ms());
CTime ti3(1.0101, CTimeUnit::hms());
CTime ti4(1.15, CTimeUnit::hrmin());
CTime ti5(1.30, CTimeUnit::minsec());
qDebug() << ti1 << ti2 << ti3 << ti4 << ti5;
CAcceleration ac1(10, CAccelerationUnit::m_s2());
qDebug() << ac1 << ac1.valueRoundedWithUnit(-1, true) << "I18N/UTF";
// bye
qDebug() << "-----------------------------------------------";
return 0;
}
// bye
qDebug() << "-----------------------------------------------";
return 0;
}
} // namespace