2022-06-28 17:19:07 +00:00
|
|
|
use dioxus_core_macro::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn formatting_compiles() {
|
|
|
|
let x = (0, 1);
|
|
|
|
// escape sequences work
|
|
|
|
assert_eq!(
|
|
|
|
format_args_f!("{x:?} {{}}}}").to_string(),
|
2023-01-28 02:35:46 +00:00
|
|
|
format!("{x:?} {{}}}}")
|
2022-06-28 17:19:07 +00:00
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
format_args_f!("{{{{}} {x:?}").to_string(),
|
2023-01-28 02:35:46 +00:00
|
|
|
format!("{{{{}} {x:?}")
|
2022-06-28 17:19:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// paths in formating works
|
2022-07-03 03:45:32 +00:00
|
|
|
assert_eq!(format_args_f!("{x.0}").to_string(), format!("{}", x.0));
|
2022-06-28 17:19:07 +00:00
|
|
|
|
|
|
|
// function calls in formatings work
|
|
|
|
assert_eq!(
|
2023-07-14 20:22:08 +00:00
|
|
|
format_args_f!("{blah(&x):?}").to_string(),
|
|
|
|
format!("{:?}", blah(&x))
|
2022-06-28 17:19:07 +00:00
|
|
|
);
|
2022-08-11 05:45:56 +00:00
|
|
|
|
|
|
|
// allows duplicate format args
|
|
|
|
assert_eq!(
|
|
|
|
format_args_f!("{x:?} {x:?}").to_string(),
|
2023-01-28 02:35:46 +00:00
|
|
|
format!("{x:?} {x:?}")
|
2022-08-11 05:45:56 +00:00
|
|
|
);
|
2022-06-28 17:19:07 +00:00
|
|
|
}
|
2023-07-14 20:22:08 +00:00
|
|
|
|
|
|
|
fn blah(hi: &(i32, i32)) -> String {
|
|
|
|
format_args_f!("{hi.0} {hi.1}").to_string()
|
|
|
|
}
|