mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] Fix Unit::IsISEnergy
This commit is contained in:
@@ -459,11 +459,11 @@ bool Unit::IsISEnergy(Expression & e) {
|
||||
return e.type() == ExpressionNode::Type::Multiplication && e.numberOfChildren() == 3 &&
|
||||
e.childAtIndex(0).type() == ExpressionNode::Type::Unit && e.childAtIndex(0).convert<Unit>().isKilogram() &&
|
||||
e.childAtIndex(1).type() == ExpressionNode::Type::Power &&
|
||||
e.childAtIndex(1).childAtIndex(0).type() == ExpressionNode::Type::Unit && e.childAtIndex(1).childAtIndex(0).convert<Unit>().isMeter();
|
||||
e.childAtIndex(1).childAtIndex(0).type() == ExpressionNode::Type::Unit && e.childAtIndex(1).childAtIndex(0).convert<Unit>().isMeter() &&
|
||||
e.childAtIndex(1).childAtIndex(1).type() == ExpressionNode::Type::Rational && e.childAtIndex(1).childAtIndex(1).convert<const Rational>().isTwo() &&
|
||||
e.childAtIndex(2).type() == ExpressionNode::Type::Power &&
|
||||
e.childAtIndex(2).childAtIndex(0).type() == ExpressionNode::Type::Unit && e.childAtIndex(1).childAtIndex(0).convert<Unit>().isSecond();
|
||||
e.childAtIndex(2).childAtIndex(1).type() == ExpressionNode::Type::Rational && e.childAtIndex(1).childAtIndex(1).convert<const Rational>().isMinusTwo();
|
||||
e.childAtIndex(2).childAtIndex(0).type() == ExpressionNode::Type::Unit && e.childAtIndex(2).childAtIndex(0).convert<Unit>().isSecond() &&
|
||||
e.childAtIndex(2).childAtIndex(1).type() == ExpressionNode::Type::Rational && e.childAtIndex(2).childAtIndex(1).convert<const Rational>().isMinusTwo();
|
||||
}
|
||||
|
||||
bool Unit::IsISTime(Expression & e) {
|
||||
|
||||
@@ -428,6 +428,8 @@ QUIZ_CASE(poincare_expression_unit_helper) {
|
||||
// 4. Energy
|
||||
Expression kilogramMeter2PerSecond2 = extract_unit("_kg×_m^2×_s^-2");
|
||||
quiz_assert(Unit::IsISEnergy(kilogramMeter2PerSecond2));
|
||||
Expression kilogramMeter3PerSecond2 = extract_unit("_kg×_m^3×_s^-2");
|
||||
quiz_assert(!Unit::IsISEnergy(kilogramMeter3PerSecond2));
|
||||
|
||||
// 5. International System
|
||||
quiz_assert(Unit::IsIS(kilogramMeter2PerSecond2));
|
||||
|
||||
Reference in New Issue
Block a user