Browse Source

tests: Add tests for various int sizes

Nicholas Bishop 1 month ago
parent
commit
902f8d9fc0
1 changed files with 24 additions and 0 deletions
  1. 24 0
      tests/tests.rs

+ 24 - 0
tests/tests.rs

@@ -110,6 +110,30 @@ fn test_int() {
     }
 }
 
+#[test]
+fn test_int_length_signed() {
+    unsafe {
+        assert_eq_fmt!(c"%hhi", -125 => "-125");
+        assert_eq_fmt!(c"%hi", -23125 => "-23125");
+        assert_eq_fmt!(c"%li", -211_126_823_125i64 => "-211126823125");
+        assert_eq_fmt!(c"%lli", -211_126_823_125i64 => "-211126823125");
+        assert_eq_fmt!(c"%ti", -211_126_823_125isize => "-211126823125");
+        assert_eq_fmt!(c"%zi", 211_126_823_125usize => "211126823125");
+    }
+}
+
+#[test]
+fn test_int_length_unsigned() {
+    unsafe {
+        assert_eq_fmt!(c"%hhu", 125 => "125");
+        assert_eq_fmt!(c"%hu", 23125 => "23125");
+        assert_eq_fmt!(c"%lu", 211_126_823_125u64 => "211126823125");
+        assert_eq_fmt!(c"%llu", 211_126_823_125u64 => "211126823125");
+        assert_eq_fmt!(c"%tu", 211_126_823_125isize => "211126823125");
+        assert_eq_fmt!(c"%zu", 211_126_823_125usize => "211126823125");
+    }
+}
+
 #[test]
 fn test_octal() {
     unsafe {