Skip to content

Commit

Permalink
Merge pull request #48 from antiguru/disable_option
Browse files Browse the repository at this point in the history
  • Loading branch information
antiguru authored Mar 6, 2024
2 parents f54bd74 + fa98c67 commit 880b747
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: "Test Suite"
on:
push:
branches:
- "main"
pull_request:

jobs:
Expand Down
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,12 @@ impl LgAlloc {
self
}

/// Disable lgalloc globally.
pub fn disable(&mut self) -> &mut Self {
self.enabled = Some(false);
self
}

/// Set the background worker configuration.
pub fn with_background_config(&mut self, config: BackgroundWorkerConfig) -> &mut Self {
self.background_config = Some(config);
Expand Down Expand Up @@ -1225,4 +1231,11 @@ mod test {

Ok(())
}

#[test]
#[serial]
fn test_disable() {
crate::lgalloc_set_config(&*LgAlloc::new().disable());
assert!(matches!(allocate::<u8>(1024), Err(AllocError::Disabled)));
}
}

0 comments on commit 880b747

Please sign in to comment.