box.rs 514 B

12345678910111213141516171819202122232425262728
  1. extern crate ralloc;
  2. fn alloc_box() -> Box<u32> {
  3. Box::new(0xDEADBEAF)
  4. }
  5. #[test]
  6. fn test() {
  7. {
  8. let mut a = Box::new(1);
  9. let mut b = Box::new(2);
  10. let mut c = Box::new(3);
  11. assert_eq!(*a, 1);
  12. assert_eq!(*b, 2);
  13. assert_eq!(*c, 3);
  14. assert_eq!(*alloc_box(), 0xDEADBEAF);
  15. *a = 0;
  16. *b = 0;
  17. *c = 0;
  18. assert_eq!(*a, 0);
  19. assert_eq!(*b, 0);
  20. assert_eq!(*c, 0);
  21. }
  22. ralloc::lock().debug_assert_no_leak();
  23. }