ifmt.rs 814 B

12345678910111213141516171819202122232425262728293031323334
  1. use dioxus_core_macro::*;
  2. #[test]
  3. fn formatting_compiles() {
  4. let x = (0, 1);
  5. // escape sequences work
  6. assert_eq!(
  7. format_args_f!("{x:?} {{}}}}").to_string(),
  8. format!("{x:?} {{}}}}")
  9. );
  10. assert_eq!(
  11. format_args_f!("{{{{}} {x:?}").to_string(),
  12. format!("{{{{}} {x:?}")
  13. );
  14. // paths in formating works
  15. assert_eq!(format_args_f!("{x.0}").to_string(), format!("{}", x.0));
  16. // function calls in formatings work
  17. assert_eq!(
  18. format_args_f!("{blah(&x):?}").to_string(),
  19. format!("{:?}", blah(&x))
  20. );
  21. // allows duplicate format args
  22. assert_eq!(
  23. format_args_f!("{x:?} {x:?}").to_string(),
  24. format!("{x:?} {x:?}")
  25. );
  26. }
  27. fn blah(hi: &(i32, i32)) -> String {
  28. format_args_f!("{hi.0} {hi.1}").to_string()
  29. }