Skip to content

Commit

Permalink
Add tests for Cow formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mattico committed May 14, 2021
1 parent 24d4bff commit 5f1b964
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions firmware/qemu/src/bin/alloc.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@
0.000008 INFO Vec<Box<i32>>: [-1, 2, 3, 4]
0.000009 INFO Box<Vec<i32>>: [-1, 2, 3, 4]
0.000010 INFO String: Hello! I'm a heap-allocated String
0.000011 INFO Cow<[u32]>: [1, 2, 3, 4]
0.000012 INFO Cow<Vec<u32>>: [1, 2, 3, 4]
0.000013 INFO Cow<str>: moo
0.000014 INFO Cow<String>: moo, but allocated
0.000015 INFO Cow<Rc<u32>>: 42
0.000016 INFO Cow<Arc<u32>>: 42
6 changes: 6 additions & 0 deletions firmware/qemu/src/bin/alloc.release.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@
0.000008 INFO Vec<Box<i32>>: [-1, 2, 3, 4]
0.000009 INFO Box<Vec<i32>>: [-1, 2, 3, 4]
0.000010 INFO String: Hello! I'm a heap-allocated String
0.000011 INFO Cow<[u32]>: [1, 2, 3, 4]
0.000012 INFO Cow<Vec<u32>>: [1, 2, 3, 4]
0.000013 INFO Cow<str>: moo
0.000014 INFO Cow<String>: moo, but allocated
0.000015 INFO Cow<Rc<u32>>: 42
0.000016 INFO Cow<Arc<u32>>: 42
6 changes: 6 additions & 0 deletions firmware/qemu/src/bin/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ fn main() -> ! {
"String: {=?}",
String::from("Hello! I'm a heap-allocated String")
);
defmt::info!("Cow<[u32]>: {=?}", Cow::Borrowed(&[1, 2, 3, 4]));
defmt::info!("Cow<Vec<u32>>: {=?}", Cow::Owned(vec![1, 2, 3, 4]));
defmt::info!("Cow<str>: {=?}", Cow::Borrowed("moo"));
defmt::info!("Cow<String>: {=?}", String::from("moo, but allocated"));
defmt::info!("Cow<Rc<u32>>: {=?}", Cow::Owned(Rc::new(42u32)));
defmt::info!("Cow<Arc<u32>>: {=?}", Cow::Owned(Arc::new(42u32)));

loop {
debug::exit(debug::EXIT_SUCCESS)
Expand Down

0 comments on commit 5f1b964

Please sign in to comment.