MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_context_item_builder

Function test_context_item_builder

core/src/context/mod.rs:535–554  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

533
534 #[test]
535 fn test_context_item_builder() {
536 let item = ContextItem::new("item-2", ContextType::Memory, "Memory content")
537 .with_token_count(150)
538 .with_relevance(0.85)
539 .with_source("viking://memory/session-123")
540 .with_provenance("memory")
541 .with_priority(0.7)
542 .with_trust(1.2)
543 .with_freshness(-1.0)
544 .with_metadata("key", serde_json::json!("value"));
545
546 assert_eq!(item.token_count, 150);
547 assert!((item.relevance - 0.85).abs() < f32::EPSILON);
548 assert_eq!(item.source, Some("viking://memory/session-123".to_string()));
549 assert_eq!(item.provenance(), Some("memory"));
550 assert!((item.priority() - 0.7).abs() < f32::EPSILON);
551 assert!((item.trust() - 1.0).abs() < f32::EPSILON);
552 assert!(item.freshness().abs() < f32::EPSILON);
553 assert_eq!(item.metadata.get("key"), Some(&serde_json::json!("value")));
554 }
555
556 #[test]
557 fn test_context_item_relevance_clamping() {

Callers

nothing calls this directly

Calls 8

with_freshnessMethod · 0.80
with_trustMethod · 0.80
with_provenanceMethod · 0.80
with_sourceMethod · 0.80
with_relevanceMethod · 0.80
with_token_countMethod · 0.80
with_metadataMethod · 0.45
with_priorityMethod · 0.45

Tested by

no test coverage detected