Skip to content

Commit

Permalink
Add tests for OnceCell::with_value
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Mar 3, 2022
1 parent 65d29b3 commit 82fd676
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/it.rs
Expand Up @@ -17,6 +17,13 @@ mod unsync {
assert_eq!(c.get(), Some(&92));
}

#[test]
fn once_cell_with_value() {
const CELL: OnceCell<i32> = OnceCell::with_value(12);
let cell = CELL;
assert_eq!(cell.get(), Some(&12));
}

#[test]
fn once_cell_get_mut() {
let mut c = OnceCell::new();
Expand Down Expand Up @@ -230,6 +237,12 @@ mod sync {
assert_eq!(c.get(), Some(&92));
}

#[test]
fn once_cell_with_value() {
static CELL: OnceCell<i32> = OnceCell::with_value(12);
assert_eq!(CELL.get(), Some(&12));
}

#[test]
fn once_cell_get_mut() {
let mut c = OnceCell::new();
Expand Down

0 comments on commit 82fd676

Please sign in to comment.