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

Function basic

crates/environ/src/string_pool.rs:311–338  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

309
310 #[test]
311 fn basic() -> Result<()> {
312 let mut pool = StringPool::new();
313
314 let a = pool.insert("a")?;
315 assert_eq!(&pool[a], "a");
316 assert_eq!(pool.get_atom("a"), Some(a));
317
318 let a2 = pool.insert("a")?;
319 assert_eq!(a, a2);
320 assert_eq!(&pool[a2], "a");
321
322 let b = pool.insert("b")?;
323 assert_eq!(&pool[b], "b");
324 assert_ne!(a, b);
325 assert_eq!(pool.get_atom("b"), Some(b));
326
327 assert!(pool.get_atom("zzz").is_none());
328
329 let mut pool2 = StringPool::new();
330 let c = pool2.insert("c")?;
331 assert_eq!(&pool2[c], "c");
332 assert_eq!(a, c);
333 assert_eq!(&pool2[a], "c");
334 assert!(!pool2.contains(b));
335 assert!(pool2.get(b).is_none());
336
337 Ok(())
338 }
339
340 #[test]
341 fn stress() -> Result<()> {

Callers

nothing calls this directly

Calls 3

OkFunction · 0.85
newFunction · 0.50
insertMethod · 0.45

Tested by

no test coverage detected