Skip to content

Commit

Permalink
Update simple_allocation test in Heap Allocation post
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-opp committed May 22, 2020
1 parent 788d6a7 commit 59a7f96
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions blog/content/second-edition/posts/10-heap-allocation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ fn main(boot_info: &'static BootInfo) -> ! {

It is very similar to the `kernel_main` function in our `main.rs`, with the differences that we don't invoke `println`, don't include any example allocations, and call `test_main` unconditionally.

Now we're ready to add a few test cases. First, we add a test that performs a simple allocation using [`Box`] and checks the allocated value, to ensure that basic allocations work:
Now we're ready to add a few test cases. First, we add a test that performs some simple allocations using [`Box`] and checks the allocated values, to ensure that basic allocations work:

```rust
// in tests/heap_allocation.rs
Expand All @@ -711,8 +711,10 @@ use alloc::boxed::Box;
#[test_case]
fn simple_allocation() {
serial_print!("simple_allocation... ");
let heap_value = Box::new(41);
assert_eq!(*heap_value, 41);
let heap_value_1 = Box::new(41);
let heap_value_2 = Box::new(13);
assert_eq!(*heap_value_1, 41);
assert_eq!(*heap_value_2, 13);
serial_println!("[ok]");
}
```
Expand Down

0 comments on commit 59a7f96

Please sign in to comment.