about summary refs log tree commit diff
path: root/tests/ui/fmt
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-06-09 02:16:25 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-06-11 20:51:49 +0500
commitc6c55cc0cb63667833c54c13ad4a2eb576d48e13 (patch)
tree32ae5b6ade574c1282453e7caa8778cc1765474e /tests/ui/fmt
parent8072811356a178dbdf8ca09b1635cfafd4661971 (diff)
downloadrust-c6c55cc0cb63667833c54c13ad4a2eb576d48e13.tar.gz
rust-c6c55cc0cb63667833c54c13ad4a2eb576d48e13.zip
cleaned up some tests
Diffstat (limited to 'tests/ui/fmt')
-rw-r--r--tests/ui/fmt/format-macro-no-std.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/fmt/format-macro-no-std.rs b/tests/ui/fmt/format-macro-no-std.rs
new file mode 100644
index 00000000000..d096b4de013
--- /dev/null
+++ b/tests/ui/fmt/format-macro-no-std.rs
@@ -0,0 +1,34 @@
+//! Test format! macro functionality in no_std environment
+
+//@ run-pass
+//@ ignore-emscripten no no_std executables
+//@ ignore-wasm different `main` convention
+
+#![feature(lang_items)]
+#![no_std]
+#![no_main]
+
+// Import global allocator and panic handler.
+extern crate std as other;
+
+#[macro_use]
+extern crate alloc;
+
+use alloc::string::ToString;
+
+#[no_mangle]
+extern "C" fn main(_argc: core::ffi::c_int, _argv: *const *const u8) -> core::ffi::c_int {
+    let s = format!("{}", 1_isize);
+    assert_eq!(s, "1".to_string());
+
+    let s = format!("test");
+    assert_eq!(s, "test".to_string());
+
+    let s = format!("{test}", test = 3_isize);
+    assert_eq!(s, "3".to_string());
+
+    let s = format!("hello {}", "world");
+    assert_eq!(s, "hello world".to_string());
+
+    0
+}