ifmt.rs 780 B

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