MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / try_string_into_boxed_str

Function try_string_into_boxed_str

crates/fuzzing/tests/oom/string.rs:77–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75
76#[test]
77fn try_string_into_boxed_str() -> Result<()> {
78 OomTest::new().test(|| {
79 // len == cap == 0
80 let s = TryString::new();
81 let _ = s.into_boxed_str()?;
82
83 // len == 0 < cap
84 let s = TryString::with_capacity(4)?;
85 let _ = s.into_boxed_str()?;
86
87 // 0 < len < cap
88 let mut s = TryString::with_capacity(4)?;
89 s.push('a')?;
90 let _ = s.into_boxed_str()?;
91
92 // 0 < len == cap
93 let mut s = TryString::new();
94 s.reserve_exact(2)?;
95 s.push('a')?;
96 s.push('a')?;
97 let _ = s.into_boxed_str()?;
98
99 Ok(())
100 })
101}

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
into_boxed_strMethod · 0.80
newFunction · 0.50
testMethod · 0.45
pushMethod · 0.45
reserve_exactMethod · 0.45

Tested by

no test coverage detected