Debian Codegraph @

tests/format_flags_tests.rs

raw symbols SCIP
1 #[cfg(feature = "format")]
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::numrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/;
3
4 #[cfg(feature = "format")]
5 use lexical_utilrust-analyzer cargo lexical-util 1.0.7 crate/::formatrust-analyzer cargo lexical-util 1.0.7 format/;
6
7 #[cfg(feature = "format")]
8 const fn from_digit_separatorrust-analyzer cargo lexical-util 1.0.7 from_digit_separator().(digit_separator: u8) -> u128 {
9 formatrust-analyzer cargo lexical-util 1.0.7 format/::NumberFormatBuilderrust-analyzer cargo lexical-util 1.0.7 format_builder/NumberFormatBuilder#::newrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]new().()
10 .digit_separatorrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]digit_separator().(numrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/::NonZeroU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU8#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(digit_separator))
11 .digit_separator_flagsrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]digit_separator_flags().(true)
12 .build_uncheckedrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]build_unchecked().()
13 }
14
15 #[cfg(feature = "format")]
16 fn is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 is_valid_digit_separator().(digit_separator: u8) -> bool {
17 let format = from_digit_separatorrust-analyzer cargo lexical-util 1.0.7 from_digit_separator().(digit_separator);
18 formatrust-analyzer cargo lexical-util 1.0.7 format/::is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 format_flags/is_valid_digit_separator().(format)
19 }
20
21 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
22 #[cfg(feature = "format")]
23 fn test_is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 test_is_valid_digit_separator().() {
24 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 is_valid_digit_separator().(b'_'), true);
25 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 is_valid_digit_separator().(b'\''), true);
26 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 is_valid_digit_separator().(b'.'), true);
27 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 is_valid_digit_separator().(b'e'), true);
28 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 is_valid_digit_separator().(b'0'), false);
29 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 is_valid_digit_separator().(128), false);
30
31 // Try with a custom radix.
32 #[cfg(feature = "radix")]
33 {
34 let format = formatrust-analyzer cargo lexical-util 1.0.7 format/::NumberFormatrust-analyzer cargo lexical-util 1.0.7 feature_format/NumberFormat#::<{ from_digit_separatorrust-analyzer cargo lexical-util 1.0.7 from_digit_separator().(b'e') }>::rebuildrust-analyzer cargo lexical-util 1.0.7 feature_format/impl#[`NumberFormat<FORMAT>`]rebuild().()
35 .radixrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]radix().(16)
36 .build_uncheckedrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]build_unchecked().();
37 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo lexical-util 1.0.7 format/::is_valid_digit_separatorrust-analyzer cargo lexical-util 1.0.7 format_flags/is_valid_digit_separator().(format), false);
38 }
39 }
40
41 #[cfg(all(feature = "power-of-two", feature = "format"))]
42 fn is_valid_punctuationrust-analyzer cargo lexical-util 1.0.7 is_valid_punctuation().(digit_separator: u8, base_prefix: u8, base_suffix: u8) -> bool {
43 let fmt = formatrust-analyzer cargo lexical-util 1.0.7 format/::NumberFormatBuilderrust-analyzer cargo lexical-util 1.0.7 format_builder/NumberFormatBuilder#::newrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]new().()
44 .digit_separatorrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]digit_separator().(numrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/::NonZeroU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU8#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(digit_separator))
45 .digit_separator_flagsrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]digit_separator_flags().(true)
46 .base_prefixrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]base_prefix().(numrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/::NonZeroU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU8#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(base_prefix))
47 .base_suffixrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]base_suffix().(numrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/::NonZeroU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU8#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(base_suffix))
48 .build_uncheckedrust-analyzer cargo lexical-util 1.0.7 format_builder/impl#[NumberFormatBuilder]build_unchecked().();
49 formatrust-analyzer cargo lexical-util 1.0.7 format/::is_valid_punctuationrust-analyzer cargo lexical-util 1.0.7 format_flags/is_valid_punctuation().(fmt)
50 }
51
52 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
53 #[cfg(all(feature = "power-of-two", feature = "format"))]
54 fn test_is_valid_punctuationrust-analyzer cargo lexical-util 1.0.7 test_is_valid_punctuation().() {
55 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_punctuationrust-analyzer cargo lexical-util 1.0.7 is_valid_punctuation().(b'_', b'h', 0), true);
56 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_punctuationrust-analyzer cargo lexical-util 1.0.7 is_valid_punctuation().(b'e', b'h', 0), true);
57 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_punctuationrust-analyzer cargo lexical-util 1.0.7 is_valid_punctuation().(b'^', b'h', 0), true);
58 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_punctuationrust-analyzer cargo lexical-util 1.0.7 is_valid_punctuation().(b'\'', b'h', 0), true);
59 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_valid_punctuationrust-analyzer cargo lexical-util 1.0.7 is_valid_punctuation().(b'\'', b'h', b'h'), false);
60 }