box.rs 406 B

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