[poincare] Fix Unit::isSecond, Unit::isMeter and Unit::isKilogram: the

EmptyPrefix is not unique, we can't only compare pointers
This commit is contained in:
Émilie Feral
2020-05-06 12:13:04 +02:00
parent b6ee72bc21
commit bcbdc9312e
2 changed files with 4 additions and 3 deletions

View File

@@ -38,6 +38,7 @@ public:
m_symbol(symbol),
m_exponent(exponent)
{}
inline bool operator==(const Prefix& p) const { return m_exponent == p.m_exponent && strcmp(m_symbol, p.m_symbol) == 0; }
const char * symbol() const { return m_symbol; }
int8_t exponent() const { return m_exponent; }
int serialize(char * buffer, int bufferSize) const;

View File

@@ -392,16 +392,16 @@ Expression Unit::removeUnit(Expression * unit) {
}
bool Unit::isSecond() const {
return node()->dimension() == TimeDimension && node()->representative() == SecondRepresentative && node()->prefix() == &EmptyPrefix;
return node()->dimension() == TimeDimension && node()->representative() == SecondRepresentative && *(node()->prefix()) == EmptyPrefix;
}
bool Unit::isMeter() const {
return node()->dimension() == DistanceDimension && node()->representative() == MeterRepresentative && node()->prefix() == &EmptyPrefix;
return node()->dimension() == DistanceDimension && node()->representative() == MeterRepresentative && *(node()->prefix()) == EmptyPrefix;
}
bool Unit::isKilogram() const {
return node()->dimension() == MassDimension && node()->representative() == KilogramRepresentative && node()->prefix() == &KiloPrefix;
return node()->dimension() == MassDimension && node()->representative() == KilogramRepresentative && *(node()->prefix()) == KiloPrefix;
}
bool Unit::IsISSpeed(Expression & e) {