mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/unit] Change units for volume split
In additional outputs, a volume is now splitted as : _gal+_qt+_pt+_cup instead of : _gal+_cup+_floz Change-Id: I5020afbab23be6331d8a8742fd6295db178f0b37
This commit is contained in:
committed by
Émilie Feral
parent
5e06f62ff6
commit
801c61549c
@@ -639,10 +639,12 @@ public:
|
||||
static_assert(strings_equal(k_surfaceRepresentatives[k_acreRepresentativeIndex].m_rootSymbol, "acre"), "Index for the Acre Representative is incorrect.");
|
||||
static constexpr int k_literRepresentativeIndex = 0;
|
||||
static_assert(strings_equal(k_volumeRepresentatives[k_literRepresentativeIndex].m_rootSymbol, "L"), "Index for the Liter Representative is incorrect.");
|
||||
static constexpr int k_fluidOunceRepresentativeIndex = 3;
|
||||
static_assert(strings_equal(k_volumeRepresentatives[k_fluidOunceRepresentativeIndex].m_rootSymbol, "floz"), "Index for the Fluid Ounce Representative is incorrect.");
|
||||
static constexpr int k_cupRepresentativeIndex = 4;
|
||||
static_assert(strings_equal(k_volumeRepresentatives[k_cupRepresentativeIndex].m_rootSymbol, "cup"), "Index for the Cup Representative is incorrect.");
|
||||
static constexpr int k_pintRepresentativeIndex = 5;
|
||||
static_assert(strings_equal(k_volumeRepresentatives[k_pintRepresentativeIndex].m_rootSymbol, "pt"), "Index for the Pint Representative is incorrect.");
|
||||
static constexpr int k_quartRepresentativeIndex = 6;
|
||||
static_assert(strings_equal(k_volumeRepresentatives[k_quartRepresentativeIndex].m_rootSymbol, "qt"), "Index for the Quart Representative is incorrect.");
|
||||
static constexpr int k_gallonRepresentativeIndex = 7;
|
||||
static_assert(strings_equal(k_volumeRepresentatives[k_gallonRepresentativeIndex].m_rootSymbol, "gal"), "Index for the Gallon Representative is incorrect.");
|
||||
|
||||
|
||||
@@ -59,8 +59,9 @@ constexpr const int
|
||||
Unit::k_hectareRepresentativeIndex,
|
||||
Unit::k_acreRepresentativeIndex,
|
||||
Unit::k_literRepresentativeIndex,
|
||||
Unit::k_fluidOunceRepresentativeIndex,
|
||||
Unit::k_cupRepresentativeIndex,
|
||||
Unit::k_pintRepresentativeIndex,
|
||||
Unit::k_quartRepresentativeIndex,
|
||||
Unit::k_gallonRepresentativeIndex;
|
||||
|
||||
// UnitNode::Prefix
|
||||
@@ -442,7 +443,7 @@ int UnitNode::DistanceRepresentative::setAdditionalExpressions(double value, Exp
|
||||
Unit::Builder(representativesOfSameDimension() + Unit::k_yardRepresentativeIndex, Prefix::EmptyPrefix()),
|
||||
Unit::Builder(representativesOfSameDimension() + Unit::k_mileRepresentativeIndex, Prefix::EmptyPrefix()),
|
||||
};
|
||||
dest[0] = Unit::BuildSplit(value, splitUnits, 4, reductionContext);
|
||||
dest[0] = Unit::BuildSplit(value, splitUnits, sizeof(splitUnits)/sizeof(Unit), reductionContext);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -465,7 +466,7 @@ int UnitNode::MassRepresentative::setAdditionalExpressions(double value, Express
|
||||
Unit::Builder(representativesOfSameDimension() + Unit::k_poundRepresentativeIndex, Prefix::EmptyPrefix()),
|
||||
Unit::Builder(representativesOfSameDimension() + Unit::k_shortTonRepresentativeIndex, Prefix::EmptyPrefix()),
|
||||
};
|
||||
dest[0] = Unit::BuildSplit(value, splitUnits, 3, reductionContext);
|
||||
dest[0] = Unit::BuildSplit(value, splitUnits, sizeof(splitUnits)/sizeof(Unit), reductionContext);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -534,11 +535,12 @@ int UnitNode::VolumeRepresentative::setAdditionalExpressions(double value, Expre
|
||||
Unit::Builder(liter, literPrefix));
|
||||
// 2. Convert to imperial volumes
|
||||
const Unit splitUnits[] = {
|
||||
Unit::Builder(representativesOfSameDimension() + Unit::k_fluidOunceRepresentativeIndex, Prefix::EmptyPrefix()),
|
||||
Unit::Builder(representativesOfSameDimension() + Unit::k_cupRepresentativeIndex, Prefix::EmptyPrefix()),
|
||||
Unit::Builder(representativesOfSameDimension() + Unit::k_pintRepresentativeIndex, Prefix::EmptyPrefix()),
|
||||
Unit::Builder(representativesOfSameDimension() + Unit::k_quartRepresentativeIndex, Prefix::EmptyPrefix()),
|
||||
Unit::Builder(representativesOfSameDimension() + Unit::k_gallonRepresentativeIndex, Prefix::EmptyPrefix()),
|
||||
};
|
||||
*destImperial = Unit::BuildSplit(value, splitUnits, numberOfRepresentatives() - 5, reductionContext);
|
||||
*destImperial = Unit::BuildSplit(value, splitUnits, sizeof(splitUnits)/sizeof(Unit), reductionContext);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -444,9 +444,9 @@ QUIZ_CASE(poincare_expression_additional_results) {
|
||||
assert_additional_results_compute_to("3.6×_MN_m", array8, 2);
|
||||
|
||||
// Volume
|
||||
const char * array9[2] = {"1000×_L", "264×_gal+2×_cup+6.022702×_floz"};
|
||||
const char * array9[2] = {"1000×_L", "264×_gal+1×_pt+0.7528377×_cup"};
|
||||
assert_additional_results_compute_to("1×_m^3", array9, 2);
|
||||
const char * array10[2] = {"182.5426×_L", "48×_gal+3×_cup+4.5×_floz"};
|
||||
const char * array10[2] = {"182.5426×_L", "48×_gal+1×_pt+1.5625×_cup"};
|
||||
assert_additional_results_compute_to("12345×_tbsp", array10, 2);
|
||||
|
||||
// Speed
|
||||
|
||||
Reference in New Issue
Block a user