]> git.lizzy.rs Git - rust.git/blob - src/librustdoc/clean/utils/tests.rs
Rollup merge of #106499 - lyming2007:issue-105946-fix, r=estebank
[rust.git] / src / librustdoc / clean / utils / tests.rs
1 use super::*;
2
3 #[test]
4 fn int_format_decimal() {
5     assert_eq!(format_integer_with_underscore_sep("12345678"), "12_345_678");
6     assert_eq!(format_integer_with_underscore_sep("123"), "123");
7     assert_eq!(format_integer_with_underscore_sep("123459"), "123_459");
8     assert_eq!(format_integer_with_underscore_sep("-12345678"), "-12_345_678");
9     assert_eq!(format_integer_with_underscore_sep("-123"), "-123");
10     assert_eq!(format_integer_with_underscore_sep("-123459"), "-123_459");
11 }
12
13 #[test]
14 fn int_format_hex() {
15     assert_eq!(format_integer_with_underscore_sep("0xab3"), "0xab3");
16     assert_eq!(format_integer_with_underscore_sep("0xa2345b"), "0xa2_345b");
17     assert_eq!(format_integer_with_underscore_sep("0xa2e6345b"), "0xa2e6_345b");
18     assert_eq!(format_integer_with_underscore_sep("-0xab3"), "-0xab3");
19     assert_eq!(format_integer_with_underscore_sep("-0xa2345b"), "-0xa2_345b");
20     assert_eq!(format_integer_with_underscore_sep("-0xa2e6345b"), "-0xa2e6_345b");
21 }
22
23 #[test]
24 fn int_format_binary() {
25     assert_eq!(format_integer_with_underscore_sep("0o12345671"), "0o12_345_671");
26     assert_eq!(format_integer_with_underscore_sep("0o123"), "0o123");
27     assert_eq!(format_integer_with_underscore_sep("0o123451"), "0o123451");
28     assert_eq!(format_integer_with_underscore_sep("-0o12345671"), "-0o12_345_671");
29     assert_eq!(format_integer_with_underscore_sep("-0o123"), "-0o123");
30     assert_eq!(format_integer_with_underscore_sep("-0o123451"), "-0o123451");
31 }
32
33 #[test]
34 fn int_format_octal() {
35     assert_eq!(format_integer_with_underscore_sep("0b101"), "0b101");
36     assert_eq!(format_integer_with_underscore_sep("0b101101011"), "0b1_0110_1011");
37     assert_eq!(format_integer_with_underscore_sep("0b01101011"), "0b0110_1011");
38     assert_eq!(format_integer_with_underscore_sep("-0b101"), "-0b101");
39     assert_eq!(format_integer_with_underscore_sep("-0b101101011"), "-0b1_0110_1011");
40     assert_eq!(format_integer_with_underscore_sep("-0b01101011"), "-0b0110_1011");
41 }