##// END OF EJS Templates
rust: Add some unit tests for parse_byte_size in config...
Simon Sapin -
r47345:1b7c0b10 default
parent child Browse files
Show More
@@ -41,3 +41,21 b' pub(super) fn parse_byte_size(value: &[u'
41 }
41 }
42 value.parse().ok()
42 value.parse().ok()
43 }
43 }
44
45 #[test]
46 fn test_parse_byte_size() {
47 assert_eq!(parse_byte_size(b""), None);
48 assert_eq!(parse_byte_size(b"b"), None);
49
50 assert_eq!(parse_byte_size(b"12"), Some(12));
51 assert_eq!(parse_byte_size(b"12b"), Some(12));
52 assert_eq!(parse_byte_size(b"12 b"), Some(12));
53 assert_eq!(parse_byte_size(b"12.1 b"), Some(12));
54 assert_eq!(parse_byte_size(b"1.1 K"), Some(1126));
55 assert_eq!(parse_byte_size(b"1.1 kB"), Some(1126));
56
57 assert_eq!(parse_byte_size(b"-12 b"), None);
58 assert_eq!(parse_byte_size(b"-0.1 b"), None);
59 assert_eq!(parse_byte_size(b"0.1 b"), Some(0));
60 assert_eq!(parse_byte_size(b"12.1 b"), Some(12));
61 }
General Comments 0
You need to be logged in to leave comments. Login now