mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: number format (#2445)
This commit is contained in:
parent
76b94e363e
commit
1f187a3917
@ -8,7 +8,7 @@ edition = "2018"
|
||||
name = "dart_ffi"
|
||||
# this value will change depending on the target os
|
||||
# default static lib
|
||||
crate-type = ["staticlib"]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
|
@ -13,13 +13,23 @@ mod tests {
|
||||
fn number_type_option_invalid_input_test() {
|
||||
let type_option = NumberTypeOption::default();
|
||||
let field_type = FieldType::Number;
|
||||
let field_rev = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
let field = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
|
||||
// Input is empty String
|
||||
assert_number(&type_option, "", "", &field_type, &field_rev);
|
||||
assert_number(&type_option, "", "", &field_type, &field);
|
||||
|
||||
// Input is letter
|
||||
assert_number(&type_option, "abc", "", &field_type, &field_rev);
|
||||
assert_number(&type_option, "abc", "", &field_type, &field);
|
||||
|
||||
assert_number(&type_option, "-123", "-123", &field_type, &field);
|
||||
|
||||
assert_number(&type_option, "abc-123", "-123", &field_type, &field);
|
||||
|
||||
assert_number(&type_option, "+123", "123", &field_type, &field);
|
||||
|
||||
assert_number(&type_option, "0.2", "0.2", &field_type, &field);
|
||||
|
||||
assert_number(&type_option, "-0.2", "-0.2", &field_type, &field);
|
||||
}
|
||||
|
||||
/// Testing the strip_currency_symbol function. It should return the string without the input symbol.
|
||||
@ -36,120 +46,110 @@ mod tests {
|
||||
fn number_type_option_format_number_test() {
|
||||
let mut type_option = NumberTypeOption::default();
|
||||
let field_type = FieldType::Number;
|
||||
let field_rev = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
let field = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
|
||||
for format in NumberFormat::iter() {
|
||||
type_option.format = format;
|
||||
match format {
|
||||
NumberFormat::Num => {
|
||||
assert_number(&type_option, "18443", "18443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "18443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::USD => {
|
||||
assert_number(&type_option, "18443", "$18,443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "$18,443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::CanadianDollar => {
|
||||
assert_number(&type_option, "18443", "CA$18,443", &field_type, &field_rev)
|
||||
},
|
||||
NumberFormat::EUR => {
|
||||
assert_number(&type_option, "18443", "€18.443", &field_type, &field_rev)
|
||||
},
|
||||
NumberFormat::Pound => {
|
||||
assert_number(&type_option, "18443", "£18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "CA$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::EUR => assert_number(&type_option, "18443", "€18.443", &field_type, &field),
|
||||
NumberFormat::Pound => assert_number(&type_option, "18443", "£18,443", &field_type, &field),
|
||||
|
||||
NumberFormat::Yen => {
|
||||
assert_number(&type_option, "18443", "¥18,443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "¥18,443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Ruble => {
|
||||
assert_number(&type_option, "18443", "18.443RUB", &field_type, &field_rev)
|
||||
},
|
||||
NumberFormat::Rupee => {
|
||||
assert_number(&type_option, "18443", "₹18,443", &field_type, &field_rev)
|
||||
},
|
||||
NumberFormat::Won => {
|
||||
assert_number(&type_option, "18443", "₩18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "18.443RUB", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Rupee => assert_number(&type_option, "18443", "₹18,443", &field_type, &field),
|
||||
NumberFormat::Won => assert_number(&type_option, "18443", "₩18,443", &field_type, &field),
|
||||
|
||||
NumberFormat::Yuan => {
|
||||
assert_number(&type_option, "18443", "CN¥18,443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "CN¥18,443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Real => {
|
||||
assert_number(&type_option, "18443", "R$18,443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "R$18,443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Lira => {
|
||||
assert_number(&type_option, "18443", "TRY18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "TRY18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Rupiah => {
|
||||
assert_number(&type_option, "18443", "IDR18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "IDR18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Franc => {
|
||||
assert_number(&type_option, "18443", "CHF18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "CHF18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::HongKongDollar => {
|
||||
assert_number(&type_option, "18443", "HZ$18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "HZ$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::NewZealandDollar => {
|
||||
assert_number(&type_option, "18443", "NZ$18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "NZ$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Krona => {
|
||||
assert_number(&type_option, "18443", "18 443SEK", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "18 443SEK", &field_type, &field)
|
||||
},
|
||||
NumberFormat::NorwegianKrone => {
|
||||
assert_number(&type_option, "18443", "18,443NOK", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "18,443NOK", &field_type, &field)
|
||||
},
|
||||
NumberFormat::MexicanPeso => {
|
||||
assert_number(&type_option, "18443", "MX$18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "MX$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Rand => {
|
||||
assert_number(&type_option, "18443", "ZAR18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "ZAR18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::NewTaiwanDollar => {
|
||||
assert_number(&type_option, "18443", "NT$18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "NT$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::DanishKrone => {
|
||||
assert_number(&type_option, "18443", "18.443DKK", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "18.443DKK", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Baht => {
|
||||
assert_number(&type_option, "18443", "THB18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "THB18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Forint => {
|
||||
assert_number(&type_option, "18443", "18 443HUF", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "18 443HUF", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Koruna => {
|
||||
assert_number(&type_option, "18443", "18 443CZK", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "18 443CZK", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Shekel => {
|
||||
assert_number(&type_option, "18443", "18 443Kč", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "18 443Kč", &field_type, &field)
|
||||
},
|
||||
NumberFormat::ChileanPeso => {
|
||||
assert_number(&type_option, "18443", "CLP18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "CLP18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::PhilippinePeso => {
|
||||
assert_number(&type_option, "18443", "₱18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "₱18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Dirham => {
|
||||
assert_number(&type_option, "18443", "18,443AED", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "18,443AED", &field_type, &field)
|
||||
},
|
||||
NumberFormat::ColombianPeso => {
|
||||
assert_number(&type_option, "18443", "COP18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "COP18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Riyal => {
|
||||
assert_number(&type_option, "18443", "SAR18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "SAR18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Ringgit => {
|
||||
assert_number(&type_option, "18443", "MYR18,443", &field_type, &field_rev)
|
||||
},
|
||||
NumberFormat::Leu => {
|
||||
assert_number(&type_option, "18443", "18.443RON", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "MYR18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Leu => assert_number(&type_option, "18443", "18.443RON", &field_type, &field),
|
||||
NumberFormat::ArgentinePeso => {
|
||||
assert_number(&type_option, "18443", "ARS18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "ARS18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::UruguayanPeso => {
|
||||
assert_number(&type_option, "18443", "UYU18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "UYU18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Percent => {
|
||||
assert_number(&type_option, "18443", "18,443%", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "18,443%", &field_type, &field)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -160,364 +160,226 @@ mod tests {
|
||||
fn number_type_option_format_str_test() {
|
||||
let mut type_option = NumberTypeOption::default();
|
||||
let field_type = FieldType::Number;
|
||||
let field_rev = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
let field = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
|
||||
for format in NumberFormat::iter() {
|
||||
type_option.format = format;
|
||||
match format {
|
||||
NumberFormat::Num => {
|
||||
assert_number(&type_option, "18443", "18443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "0.2", "0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "", "", &field_type, &field_rev);
|
||||
assert_number(&type_option, "abc", "", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "18443", &field_type, &field);
|
||||
assert_number(&type_option, "0.2", "0.2", &field_type, &field);
|
||||
assert_number(&type_option, "", "", &field_type, &field);
|
||||
assert_number(&type_option, "abc", "", &field_type, &field);
|
||||
},
|
||||
NumberFormat::USD => {
|
||||
assert_number(&type_option, "$18,44", "$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "$0.2", "$0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "$1844", "$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "$18,44", "$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "$0.2", "$0.2", &field_type, &field);
|
||||
assert_number(&type_option, "$1844", "$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "$1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::CanadianDollar => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"CA$18,44",
|
||||
"CA$1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "CA$0.2", "CA$0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CA$1844", "CA$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "CA$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CA$18,44", "CA$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "CA$0.2", "CA$0.2", &field_type, &field);
|
||||
assert_number(&type_option, "CA$1844", "CA$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "CA$1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::EUR => {
|
||||
assert_number(&type_option, "€18.44", "€18,44", &field_type, &field_rev);
|
||||
assert_number(&type_option, "€0.5", "€0,5", &field_type, &field_rev);
|
||||
assert_number(&type_option, "€1844", "€1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "€1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "€18.44", "€18,44", &field_type, &field);
|
||||
assert_number(&type_option, "€0.5", "€0,5", &field_type, &field);
|
||||
assert_number(&type_option, "€1844", "€1.844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "€1.844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Pound => {
|
||||
assert_number(&type_option, "£18,44", "£1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "£0.2", "£0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "£1844", "£1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "£1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "£18,44", "£1,844", &field_type, &field);
|
||||
assert_number(&type_option, "£0.2", "£0.2", &field_type, &field);
|
||||
assert_number(&type_option, "£1844", "£1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "£1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Yen => {
|
||||
assert_number(&type_option, "¥18,44", "¥1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "¥0.2", "¥0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "¥1844", "¥1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "¥1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "¥18,44", "¥1,844", &field_type, &field);
|
||||
assert_number(&type_option, "¥0.2", "¥0.2", &field_type, &field);
|
||||
assert_number(&type_option, "¥1844", "¥1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "¥1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Ruble => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"RUB18.44",
|
||||
"18,44RUB",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "0.5", "0,5RUB", &field_type, &field_rev);
|
||||
assert_number(&type_option, "RUB1844", "1.844RUB", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "1.844RUB", &field_type, &field_rev);
|
||||
assert_number(&type_option, "RUB18.44", "18,44RUB", &field_type, &field);
|
||||
assert_number(&type_option, "0.5", "0,5RUB", &field_type, &field);
|
||||
assert_number(&type_option, "RUB1844", "1.844RUB", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "1.844RUB", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Rupee => {
|
||||
assert_number(&type_option, "₹18,44", "₹1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "₹0.2", "₹0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "₹1844", "₹1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "₹1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "₹18,44", "₹1,844", &field_type, &field);
|
||||
assert_number(&type_option, "₹0.2", "₹0.2", &field_type, &field);
|
||||
assert_number(&type_option, "₹1844", "₹1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "₹1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Won => {
|
||||
assert_number(&type_option, "₩18,44", "₩1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "₩0.3", "₩0", &field_type, &field_rev);
|
||||
assert_number(&type_option, "₩1844", "₩1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "₩1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "₩18,44", "₩1,844", &field_type, &field);
|
||||
assert_number(&type_option, "₩0.3", "₩0", &field_type, &field);
|
||||
assert_number(&type_option, "₩1844", "₩1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "₩1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Yuan => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"CN¥18,44",
|
||||
"CN¥1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "CN¥0.2", "CN¥0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CN¥1844", "CN¥1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "CN¥1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CN¥18,44", "CN¥1,844", &field_type, &field);
|
||||
assert_number(&type_option, "CN¥0.2", "CN¥0.2", &field_type, &field);
|
||||
assert_number(&type_option, "CN¥1844", "CN¥1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "CN¥1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Real => {
|
||||
assert_number(&type_option, "R$18,44", "R$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "R$0.2", "R$0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "R$1844", "R$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "R$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "R$18,44", "R$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "R$0.2", "R$0.2", &field_type, &field);
|
||||
assert_number(&type_option, "R$1844", "R$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "R$1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Lira => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"TRY18.44",
|
||||
"TRY18,44",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "TRY0.5", "TRY0,5", &field_type, &field_rev);
|
||||
assert_number(&type_option, "TRY1844", "TRY1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "TRY1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "TRY18.44", "TRY18,44", &field_type, &field);
|
||||
assert_number(&type_option, "TRY0.5", "TRY0,5", &field_type, &field);
|
||||
assert_number(&type_option, "TRY1844", "TRY1.844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "TRY1.844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Rupiah => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"IDR18,44",
|
||||
"IDR1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "IDR0.2", "IDR0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "IDR1844", "IDR1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "IDR1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "IDR18,44", "IDR1,844", &field_type, &field);
|
||||
assert_number(&type_option, "IDR0.2", "IDR0.2", &field_type, &field);
|
||||
assert_number(&type_option, "IDR1844", "IDR1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "IDR1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Franc => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"CHF18,44",
|
||||
"CHF1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "CHF0.2", "CHF0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CHF1844", "CHF1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "CHF1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CHF18,44", "CHF1,844", &field_type, &field);
|
||||
assert_number(&type_option, "CHF0.2", "CHF0.2", &field_type, &field);
|
||||
assert_number(&type_option, "CHF1844", "CHF1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "CHF1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::HongKongDollar => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"HZ$18,44",
|
||||
"HZ$1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "HZ$0.2", "HZ$0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "HZ$1844", "HZ$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "HZ$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "HZ$18,44", "HZ$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "HZ$0.2", "HZ$0.2", &field_type, &field);
|
||||
assert_number(&type_option, "HZ$1844", "HZ$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "HZ$1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::NewZealandDollar => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"NZ$18,44",
|
||||
"NZ$1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "NZ$0.2", "NZ$0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "NZ$1844", "NZ$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "NZ$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "NZ$18,44", "NZ$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "NZ$0.2", "NZ$0.2", &field_type, &field);
|
||||
assert_number(&type_option, "NZ$1844", "NZ$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "NZ$1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Krona => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"SEK18,44",
|
||||
"18,44SEK",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "SEK0.2", "0,2SEK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "SEK1844", "1 844SEK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "1 844SEK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "SEK18,44", "18,44SEK", &field_type, &field);
|
||||
assert_number(&type_option, "SEK0.2", "0,2SEK", &field_type, &field);
|
||||
assert_number(&type_option, "SEK1844", "1 844SEK", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "1 844SEK", &field_type, &field);
|
||||
},
|
||||
NumberFormat::NorwegianKrone => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"NOK18,44",
|
||||
"1,844NOK",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "NOK0.2", "0.2NOK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "NOK1844", "1,844NOK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "1,844NOK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "NOK18,44", "1,844NOK", &field_type, &field);
|
||||
assert_number(&type_option, "NOK0.2", "0.2NOK", &field_type, &field);
|
||||
assert_number(&type_option, "NOK1844", "1,844NOK", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "1,844NOK", &field_type, &field);
|
||||
},
|
||||
NumberFormat::MexicanPeso => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"MX$18,44",
|
||||
"MX$1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "MX$0.2", "MX$0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "MX$1844", "MX$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "MX$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "MX$18,44", "MX$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "MX$0.2", "MX$0.2", &field_type, &field);
|
||||
assert_number(&type_option, "MX$1844", "MX$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "MX$1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Rand => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"ZAR18,44",
|
||||
"ZAR1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "ZAR0.2", "ZAR0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "ZAR1844", "ZAR1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "ZAR1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "ZAR18,44", "ZAR1,844", &field_type, &field);
|
||||
assert_number(&type_option, "ZAR0.2", "ZAR0.2", &field_type, &field);
|
||||
assert_number(&type_option, "ZAR1844", "ZAR1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "ZAR1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::NewTaiwanDollar => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"NT$18,44",
|
||||
"NT$1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "NT$0.2", "NT$0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "NT$1844", "NT$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "NT$1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "NT$18,44", "NT$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "NT$0.2", "NT$0.2", &field_type, &field);
|
||||
assert_number(&type_option, "NT$1844", "NT$1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "NT$1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::DanishKrone => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"DKK18.44",
|
||||
"18,44DKK",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "DKK0.5", "0,5DKK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "DKK1844", "1.844DKK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "1.844DKK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "DKK18.44", "18,44DKK", &field_type, &field);
|
||||
assert_number(&type_option, "DKK0.5", "0,5DKK", &field_type, &field);
|
||||
assert_number(&type_option, "DKK1844", "1.844DKK", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "1.844DKK", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Baht => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"THB18,44",
|
||||
"THB1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "THB0.2", "THB0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "THB1844", "THB1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "THB1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "THB18,44", "THB1,844", &field_type, &field);
|
||||
assert_number(&type_option, "THB0.2", "THB0.2", &field_type, &field);
|
||||
assert_number(&type_option, "THB1844", "THB1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "THB1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Forint => {
|
||||
assert_number(&type_option, "HUF18,44", "18HUF", &field_type, &field_rev);
|
||||
assert_number(&type_option, "HUF0.3", "0HUF", &field_type, &field_rev);
|
||||
assert_number(&type_option, "HUF1844", "1 844HUF", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "1 844HUF", &field_type, &field_rev);
|
||||
assert_number(&type_option, "HUF18,44", "18HUF", &field_type, &field);
|
||||
assert_number(&type_option, "HUF0.3", "0HUF", &field_type, &field);
|
||||
assert_number(&type_option, "HUF1844", "1 844HUF", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "1 844HUF", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Koruna => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"CZK18,44",
|
||||
"18,44CZK",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "CZK0.2", "0,2CZK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CZK1844", "1 844CZK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "1 844CZK", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CZK18,44", "18,44CZK", &field_type, &field);
|
||||
assert_number(&type_option, "CZK0.2", "0,2CZK", &field_type, &field);
|
||||
assert_number(&type_option, "CZK1844", "1 844CZK", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "1 844CZK", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Shekel => {
|
||||
assert_number(&type_option, "Kč18,44", "18,44Kč", &field_type, &field_rev);
|
||||
assert_number(&type_option, "Kč0.2", "0,2Kč", &field_type, &field_rev);
|
||||
assert_number(&type_option, "Kč1844", "1 844Kč", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "1 844Kč", &field_type, &field_rev);
|
||||
assert_number(&type_option, "Kč18,44", "18,44Kč", &field_type, &field);
|
||||
assert_number(&type_option, "Kč0.2", "0,2Kč", &field_type, &field);
|
||||
assert_number(&type_option, "Kč1844", "1 844Kč", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "1 844Kč", &field_type, &field);
|
||||
},
|
||||
NumberFormat::ChileanPeso => {
|
||||
assert_number(&type_option, "CLP18.44", "CLP18", &field_type, &field_rev);
|
||||
assert_number(&type_option, "0.5", "CLP0", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CLP1844", "CLP1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "CLP1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "CLP18.44", "CLP18", &field_type, &field);
|
||||
assert_number(&type_option, "0.5", "CLP0", &field_type, &field);
|
||||
assert_number(&type_option, "CLP1844", "CLP1.844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "CLP1.844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::PhilippinePeso => {
|
||||
assert_number(&type_option, "₱18,44", "₱1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "₱0.2", "₱0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "₱1844", "₱1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "₱1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "₱18,44", "₱1,844", &field_type, &field);
|
||||
assert_number(&type_option, "₱0.2", "₱0.2", &field_type, &field);
|
||||
assert_number(&type_option, "₱1844", "₱1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "₱1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Dirham => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"AED18,44",
|
||||
"1,844AED",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "AED0.2", "0.2AED", &field_type, &field_rev);
|
||||
assert_number(&type_option, "AED1844", "1,844AED", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "1,844AED", &field_type, &field_rev);
|
||||
assert_number(&type_option, "AED18,44", "1,844AED", &field_type, &field);
|
||||
assert_number(&type_option, "AED0.2", "0.2AED", &field_type, &field);
|
||||
assert_number(&type_option, "AED1844", "1,844AED", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "1,844AED", &field_type, &field);
|
||||
},
|
||||
NumberFormat::ColombianPeso => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"COP18.44",
|
||||
"COP18,44",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "0.5", "COP0,5", &field_type, &field_rev);
|
||||
assert_number(&type_option, "COP1844", "COP1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "COP1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "COP18.44", "COP18,44", &field_type, &field);
|
||||
assert_number(&type_option, "0.5", "COP0,5", &field_type, &field);
|
||||
assert_number(&type_option, "COP1844", "COP1.844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "COP1.844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Riyal => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"SAR18,44",
|
||||
"SAR1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "SAR0.2", "SAR0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "SAR1844", "SAR1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "SAR1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "SAR18,44", "SAR1,844", &field_type, &field);
|
||||
assert_number(&type_option, "SAR0.2", "SAR0.2", &field_type, &field);
|
||||
assert_number(&type_option, "SAR1844", "SAR1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "SAR1,844", &field_type, &field);
|
||||
},
|
||||
|
||||
NumberFormat::Ringgit => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"MYR18,44",
|
||||
"MYR1,844",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "MYR0.2", "MYR0.2", &field_type, &field_rev);
|
||||
assert_number(&type_option, "MYR1844", "MYR1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "MYR1,844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "MYR18,44", "MYR1,844", &field_type, &field);
|
||||
assert_number(&type_option, "MYR0.2", "MYR0.2", &field_type, &field);
|
||||
assert_number(&type_option, "MYR1844", "MYR1,844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "MYR1,844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Leu => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"RON18.44",
|
||||
"18,44RON",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "0.5", "0,5RON", &field_type, &field_rev);
|
||||
assert_number(&type_option, "RON1844", "1.844RON", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "1.844RON", &field_type, &field_rev);
|
||||
assert_number(&type_option, "RON18.44", "18,44RON", &field_type, &field);
|
||||
assert_number(&type_option, "0.5", "0,5RON", &field_type, &field);
|
||||
assert_number(&type_option, "RON1844", "1.844RON", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "1.844RON", &field_type, &field);
|
||||
},
|
||||
NumberFormat::ArgentinePeso => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"ARS18.44",
|
||||
"ARS18,44",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "0.5", "ARS0,5", &field_type, &field_rev);
|
||||
assert_number(&type_option, "ARS1844", "ARS1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "ARS1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "ARS18.44", "ARS18,44", &field_type, &field);
|
||||
assert_number(&type_option, "0.5", "ARS0,5", &field_type, &field);
|
||||
assert_number(&type_option, "ARS1844", "ARS1.844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "ARS1.844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::UruguayanPeso => {
|
||||
assert_number(
|
||||
&type_option,
|
||||
"UYU18.44",
|
||||
"UYU18,44",
|
||||
&field_type,
|
||||
&field_rev,
|
||||
);
|
||||
assert_number(&type_option, "0.5", "UYU0,5", &field_type, &field_rev);
|
||||
assert_number(&type_option, "UYU1844", "UYU1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1844", "UYU1.844", &field_type, &field_rev);
|
||||
assert_number(&type_option, "UYU18.44", "UYU18,44", &field_type, &field);
|
||||
assert_number(&type_option, "0.5", "UYU0,5", &field_type, &field);
|
||||
assert_number(&type_option, "UYU1844", "UYU1.844", &field_type, &field);
|
||||
assert_number(&type_option, "1844", "UYU1.844", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Percent => {
|
||||
assert_number(&type_option, "1", "1%", &field_type, &field_rev);
|
||||
assert_number(&type_option, "10.1", "10.1%", &field_type, &field_rev);
|
||||
assert_number(&type_option, "100", "100%", &field_type, &field_rev);
|
||||
assert_number(&type_option, "1", "1%", &field_type, &field);
|
||||
assert_number(&type_option, "10.1", "10.1%", &field_type, &field);
|
||||
assert_number(&type_option, "100", "100%", &field_type, &field);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -531,120 +393,116 @@ mod tests {
|
||||
..Default::default()
|
||||
};
|
||||
let field_type = FieldType::Number;
|
||||
let field_rev = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
let field = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
|
||||
for format in NumberFormat::iter() {
|
||||
type_option.format = format;
|
||||
match format {
|
||||
NumberFormat::Num => {
|
||||
assert_number(&type_option, "18443", "18443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "18443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::USD => {
|
||||
assert_number(&type_option, "18443", "-$18,443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "-$18,443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::CanadianDollar => {
|
||||
assert_number(&type_option, "18443", "-CA$18,443", &field_type, &field_rev)
|
||||
},
|
||||
NumberFormat::EUR => {
|
||||
assert_number(&type_option, "18443", "-€18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-CA$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::EUR => assert_number(&type_option, "18443", "-€18.443", &field_type, &field),
|
||||
NumberFormat::Pound => {
|
||||
assert_number(&type_option, "18443", "-£18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-£18,443", &field_type, &field)
|
||||
},
|
||||
|
||||
NumberFormat::Yen => {
|
||||
assert_number(&type_option, "18443", "-¥18,443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "-¥18,443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Ruble => {
|
||||
assert_number(&type_option, "18443", "-18.443RUB", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18.443RUB", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Rupee => {
|
||||
assert_number(&type_option, "18443", "-₹18,443", &field_type, &field_rev)
|
||||
},
|
||||
NumberFormat::Won => {
|
||||
assert_number(&type_option, "18443", "-₩18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-₹18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Won => assert_number(&type_option, "18443", "-₩18,443", &field_type, &field),
|
||||
|
||||
NumberFormat::Yuan => {
|
||||
assert_number(&type_option, "18443", "-CN¥18,443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "-CN¥18,443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Real => {
|
||||
assert_number(&type_option, "18443", "-R$18,443", &field_type, &field_rev);
|
||||
assert_number(&type_option, "18443", "-R$18,443", &field_type, &field);
|
||||
},
|
||||
NumberFormat::Lira => {
|
||||
assert_number(&type_option, "18443", "-TRY18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-TRY18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Rupiah => {
|
||||
assert_number(&type_option, "18443", "-IDR18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-IDR18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Franc => {
|
||||
assert_number(&type_option, "18443", "-CHF18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-CHF18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::HongKongDollar => {
|
||||
assert_number(&type_option, "18443", "-HZ$18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-HZ$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::NewZealandDollar => {
|
||||
assert_number(&type_option, "18443", "-NZ$18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-NZ$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Krona => {
|
||||
assert_number(&type_option, "18443", "-18 443SEK", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18 443SEK", &field_type, &field)
|
||||
},
|
||||
NumberFormat::NorwegianKrone => {
|
||||
assert_number(&type_option, "18443", "-18,443NOK", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18,443NOK", &field_type, &field)
|
||||
},
|
||||
NumberFormat::MexicanPeso => {
|
||||
assert_number(&type_option, "18443", "-MX$18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-MX$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Rand => {
|
||||
assert_number(&type_option, "18443", "-ZAR18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-ZAR18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::NewTaiwanDollar => {
|
||||
assert_number(&type_option, "18443", "-NT$18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-NT$18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::DanishKrone => {
|
||||
assert_number(&type_option, "18443", "-18.443DKK", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18.443DKK", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Baht => {
|
||||
assert_number(&type_option, "18443", "-THB18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-THB18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Forint => {
|
||||
assert_number(&type_option, "18443", "-18 443HUF", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18 443HUF", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Koruna => {
|
||||
assert_number(&type_option, "18443", "-18 443CZK", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18 443CZK", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Shekel => {
|
||||
assert_number(&type_option, "18443", "-18 443Kč", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18 443Kč", &field_type, &field)
|
||||
},
|
||||
NumberFormat::ChileanPeso => {
|
||||
assert_number(&type_option, "18443", "-CLP18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-CLP18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::PhilippinePeso => {
|
||||
assert_number(&type_option, "18443", "-₱18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-₱18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Dirham => {
|
||||
assert_number(&type_option, "18443", "-18,443AED", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18,443AED", &field_type, &field)
|
||||
},
|
||||
NumberFormat::ColombianPeso => {
|
||||
assert_number(&type_option, "18443", "-COP18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-COP18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Riyal => {
|
||||
assert_number(&type_option, "18443", "-SAR18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-SAR18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Ringgit => {
|
||||
assert_number(&type_option, "18443", "-MYR18,443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-MYR18,443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Leu => {
|
||||
assert_number(&type_option, "18443", "-18.443RON", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18.443RON", &field_type, &field)
|
||||
},
|
||||
NumberFormat::ArgentinePeso => {
|
||||
assert_number(&type_option, "18443", "-ARS18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-ARS18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::UruguayanPeso => {
|
||||
assert_number(&type_option, "18443", "-UYU18.443", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-UYU18.443", &field_type, &field)
|
||||
},
|
||||
NumberFormat::Percent => {
|
||||
assert_number(&type_option, "18443", "-18,443%", &field_type, &field_rev)
|
||||
assert_number(&type_option, "18443", "-18,443%", &field_type, &field)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -130,18 +130,14 @@ impl NumberTypeOption {
|
||||
Err(_) => Ok(NumberCellFormat::new()),
|
||||
}
|
||||
} else {
|
||||
let draw_numer_string = NUM_REGEX.replace_all(&num_cell_data.0, "");
|
||||
let strnum = match draw_numer_string.matches('.').count() {
|
||||
0 | 1 => draw_numer_string.to_string(),
|
||||
_ => match EXTRACT_NUM_REGEX.captures(&draw_numer_string) {
|
||||
Ok(captures) => match captures {
|
||||
Some(capture) => capture[1].to_string(),
|
||||
None => "".to_string(),
|
||||
},
|
||||
Err(_) => "".to_string(),
|
||||
},
|
||||
let num = match EXTRACT_NUM_REGEX.captures(&num_cell_data.0) {
|
||||
Ok(Some(captures)) => captures
|
||||
.get(0)
|
||||
.map(|m| m.as_str().to_string())
|
||||
.unwrap_or_default(),
|
||||
_ => "".to_string(),
|
||||
};
|
||||
match Decimal::from_str(&strnum) {
|
||||
match Decimal::from_str(&num) {
|
||||
Ok(value, ..) => Ok(NumberCellFormat::from_decimal(value)),
|
||||
Err(_) => Ok(NumberCellFormat::new()),
|
||||
}
|
||||
@ -264,14 +260,7 @@ impl std::default::Default for NumberTypeOption {
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref NUM_REGEX: Regex = Regex::new(r"[^\d\.]").unwrap();
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref SCIENTIFIC_NOTATION_REGEX: Regex = Regex::new(r"([+-]?\d*\.?\d+)e([+-]?\d+)").unwrap();
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref EXTRACT_NUM_REGEX: Regex = Regex::new(r"^(\d+\.\d+)(?:\.\d+)*$").unwrap();
|
||||
static ref EXTRACT_NUM_REGEX: Regex = Regex::new(r"-?\d+(\.\d+)?").unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user