add TiB and PiB (#3257)

This commit is contained in:
Saeed Rasooli
2021-04-04 04:38:17 +04:30
committed by GitHub
parent 1c941557c3
commit 4c09716ad8
2 changed files with 30 additions and 0 deletions

View File

@ -341,6 +341,8 @@ fn parse_unit(lite_arg: &Spanned<String>) -> (SpannedExpression, Option<ParseErr
(Unit::Kibibyte, "KIB", Some((Unit::Byte, 1024))),
(Unit::Mebibyte, "MIB", Some((Unit::Kibibyte, 1024))),
(Unit::Gibibyte, "GIB", Some((Unit::Mebibyte, 1024))),
(Unit::Tebibyte, "TIB", Some((Unit::Gibibyte, 1024))),
(Unit::Pebibyte, "PIB", Some((Unit::Tebibyte, 1024))),
(Unit::Byte, "B", None),
(Unit::Nanosecond, "NS", None),
(Unit::Microsecond, "US", Some((Unit::Nanosecond, 1000))),
@ -2179,6 +2181,26 @@ fn unit_parse_byte_units() {
value: 123,
unit: Unit::Gibibyte,
},
TestCase {
string: String::from("10tib"),
value: 10,
unit: Unit::Tebibyte,
},
TestCase {
string: String::from("123TiB"),
value: 123,
unit: Unit::Tebibyte,
},
TestCase {
string: String::from("10pib"),
value: 10,
unit: Unit::Pebibyte,
},
TestCase {
string: String::from("123PiB"),
value: 123,
unit: Unit::Pebibyte,
},
];
for case in cases.iter() {