mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
Diameter - fix for meta_handler *value_exponent
This commit is contained in:
@@ -228,11 +228,11 @@ func metaValueExponent(m *diam.Message, argsTpl utils.RSRFields, roundingDecimal
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
exp, err := strconv.ParseFloat(handlerArgs[1], 64)
|
||||
exp, err := strconv.Atoi(handlerArgs[1])
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
res := val * math.Exp(exp)
|
||||
res := val * math.Pow10(exp)
|
||||
return strconv.FormatFloat(utils.Round(res, roundingDecimals, utils.ROUNDING_MIDDLE), 'f', -1, 64), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ func TestMetaValueExponent(t *testing.T) {
|
||||
})
|
||||
if val, err := metaValueExponent(m, utils.ParseRSRFieldsMustCompile("Requested-Service-Unit>CC-Money>Unit-Value>Value-Digits;^|;Requested-Service-Unit>CC-Money>Unit-Value>Exponent", utils.INFIELD_SEP), 10); err != nil {
|
||||
t.Error(err)
|
||||
} else if val != "67.3794699909" {
|
||||
} else if val != "0.1" {
|
||||
t.Error("Received: ", val)
|
||||
}
|
||||
if _, err = metaValueExponent(m, utils.ParseRSRFieldsMustCompile("Requested-Service-Unit>CC-Money>Unit-Value>Value-Digits;Requested-Service-Unit>CC-Money>Unit-Value>Exponent", utils.INFIELD_SEP), 10); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user