[Updated] D10022: rust: Add some unit tests for parse_byte_size in config
SimonSapin
phabricator at mercurial-scm.org
Wed Feb 24 16:11:30 UTC 2021
Closed by commit rHG273659c16a88: rust: Add some unit tests for parse_byte_size in config (authored by SimonSapin).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10022?vs=25682&id=25881
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10022/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10022
AFFECTED FILES
rust/hg-core/src/config/values.rs
CHANGE DETAILS
diff --git a/rust/hg-core/src/config/values.rs b/rust/hg-core/src/config/values.rs
--- a/rust/hg-core/src/config/values.rs
+++ b/rust/hg-core/src/config/values.rs
@@ -41,3 +41,21 @@
}
value.parse().ok()
}
+
+#[test]
+fn test_parse_byte_size() {
+ assert_eq!(parse_byte_size(b""), None);
+ assert_eq!(parse_byte_size(b"b"), None);
+
+ assert_eq!(parse_byte_size(b"12"), Some(12));
+ assert_eq!(parse_byte_size(b"12b"), Some(12));
+ assert_eq!(parse_byte_size(b"12 b"), Some(12));
+ assert_eq!(parse_byte_size(b"12.1 b"), Some(12));
+ assert_eq!(parse_byte_size(b"1.1 K"), Some(1126));
+ assert_eq!(parse_byte_size(b"1.1 kB"), Some(1126));
+
+ assert_eq!(parse_byte_size(b"-12 b"), None);
+ assert_eq!(parse_byte_size(b"-0.1 b"), None);
+ assert_eq!(parse_byte_size(b"0.1 b"), Some(0));
+ assert_eq!(parse_byte_size(b"12.1 b"), Some(12));
+}
To: SimonSapin, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210224/c1302bbb/attachment-0002.html>
More information about the Mercurial-patches
mailing list