summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/decimal_literal_representation.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/tests/ui/decimal_literal_representation.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/decimal_literal_representation.rs b/src/tools/clippy/tests/ui/decimal_literal_representation.rs
new file mode 100644
index 000000000..55d07698e
--- /dev/null
+++ b/src/tools/clippy/tests/ui/decimal_literal_representation.rs
@@ -0,0 +1,27 @@
+// run-rustfix
+
+#[warn(clippy::decimal_literal_representation)]
+#[allow(unused_variables)]
+#[rustfmt::skip]
+fn main() {
+ let good = ( // Hex:
+ 127, // 0x7F
+ 256, // 0x100
+ 511, // 0x1FF
+ 2048, // 0x800
+ 4090, // 0xFFA
+ 16_371, // 0x3FF3
+ 61_683, // 0xF0F3
+ 2_131_750_925, // 0x7F0F_F00D
+ );
+ let bad = ( // Hex:
+ 32_773, // 0x8005
+ 65_280, // 0xFF00
+ 2_131_750_927, // 0x7F0F_F00F
+ 2_147_483_647, // 0x7FFF_FFFF
+ #[allow(overflowing_literals)]
+ 4_042_322_160, // 0xF0F0_F0F0
+ 32_773usize, // 0x8005_usize
+ 2_131_750_927isize, // 0x7F0F_F00F_isize
+ );
+}