diff --git a/oscars/src/collectors/mark_sweep/internals/gc_header.rs b/oscars/src/collectors/mark_sweep/internals/gc_header.rs index c42cfa3..0b43c26 100644 --- a/oscars/src/collectors/mark_sweep/internals/gc_header.rs +++ b/oscars/src/collectors/mark_sweep/internals/gc_header.rs @@ -177,4 +177,14 @@ mod tests { assert!(!header.is_white(), "failed to toggle black"); assert!(!header.is_grey(), "failed to toggle black"); } + + #[test] + #[should_panic(expected = "GcHeader root_count overflow")] + fn root_count_overflow_panics() { + let header = GcHeader::new_white(); + + for _ in 0..=u16::MAX { + header.inc_roots(); + } + } } diff --git a/oscars/src/collectors/mark_sweep/tests.rs b/oscars/src/collectors/mark_sweep/tests.rs index 100feb6..ce54609 100644 --- a/oscars/src/collectors/mark_sweep/tests.rs +++ b/oscars/src/collectors/mark_sweep/tests.rs @@ -1,3 +1,6 @@ +#[cfg(feature = "std")] +extern crate std; + use crate::collectors::mark_sweep::MarkSweepGarbageCollector; use crate::{Finalize, Trace};