about summary refs log tree commit diff
path: root/tests/ui/fmt/format-macro-no-std.rs
blob: d096b4de013909078008b936498c186802c778d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
}