llmgrep 3.11.1

Smart grep over Magellan code maps with schema-aligned JSON output
Documentation
// Unit tests for token budget feature
// These tests verify core functionality

#[test]
fn test_token_estimation_heuristic() {
    // Test that token estimation uses chars / 4 heuristic
    let test_string = "abcdefgh"; // 8 chars
    let estimated_tokens = test_string.len() / 4;
    assert_eq!(estimated_tokens, 2, "Token estimation should use chars / 4");
}

#[test]
fn test_json_response_has_token_fields() {
    // Test that JsonResponse has token metadata fields
    use llmgrep::output::json_response;
    use serde_json::json;

    let response = json_response(json!({"test": "data"}));

    // Verify the struct has the fields (we can't access private fields directly)
    // This test verifies the struct compiles with the token functionality
    let json_str = serde_json::to_string(&response).expect("Failed to serialize");
    let parsed: serde_json::Value = serde_json::from_str(&json_str).expect("Failed to parse JSON");
    assert!(
        parsed.get("data").is_some(),
        "JSON should include data field"
    );
    assert!(
        parsed.get("partial").is_some(),
        "JSON should include partial field"
    );
}