mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[poincare/unit] Fix temperature conversion
The program would crash when trying to evaluate a unit conversion of the form "x→_U" where U was a unit of temperature and x did not have any unit.
This commit is contained in:
committed by
EmilieNumworks
parent
5ce5f4fbac
commit
fff514d410
@@ -834,7 +834,7 @@ Expression Unit::ConvertTemperatureUnits(Expression e, Unit unit, ExpressionNode
|
||||
|
||||
Expression startUnit;
|
||||
e = e.removeUnit(&startUnit);
|
||||
if (startUnit.type() != ExpressionNode::Type::Unit) {
|
||||
if (startUnit.isUninitialized() || startUnit.type() != ExpressionNode::Type::Unit) {
|
||||
return Undefined::Builder();
|
||||
}
|
||||
const Representative * startRepr = static_cast<Unit &>(startUnit).representative();
|
||||
|
||||
@@ -1267,6 +1267,7 @@ QUIZ_CASE(poincare_simplification_unit_convert) {
|
||||
assert_parsed_expression_simplify_to("1→3_m", Undefined::Name());
|
||||
assert_parsed_expression_simplify_to("4→_km/_m", Undefined::Name());
|
||||
assert_parsed_expression_simplify_to("3×_min→_s+1-1", Undefined::Name());
|
||||
assert_parsed_expression_simplify_to("0→_K", Undefined::Name());
|
||||
|
||||
assert_parsed_expression_simplify_to("0_K→_°C", "-273.15×_°C");
|
||||
assert_parsed_expression_simplify_to("0_°C→_K", "273.15×_K");
|
||||
|
||||
Reference in New Issue
Block a user