SPB Git

spb/poche Public

Agent personnel 100 % on-device — SwiftUI + Apple Foundation Models + EventKit + SwiftData. Aucune API, aucun serveur.

Swift 100%
1.3 KB · 41 lines swift
Raw Blame History
1//2//  ContextBudgetTests.swift3//  PocheTests4//5//  Author:  Simon-Pierre Boucher6//  Contact: contact@spboucher.ai7//89import Testing10@testable import Poche1112struct ContextBudgetTests {13    let budget = ContextBudget()1415    @Test func reservesAtLeastThirtyPercentForResponse() {16        #expect(budget.responseReserve >= budget.windowSize * 3 / 10)17        #expect(budget.sendableLimit == budget.windowSize - budget.responseReserve)18    }1920    @Test func condensesAtSeventyPercent() {21        #expect(!budget.needsCondensation(estimatedTokens: budget.condenseThreshold - 1))22        #expect(budget.needsCondensation(estimatedTokens: budget.condenseThreshold))23    }2425    @Test func aFullPromptCannotBeSent() {26        // A prompt at 4092/4096 still fails: no room left for the answer.27        #expect(!budget.canSend(estimatedTokens: budget.windowSize - 4))28    }2930    @Test func usageRatioIsClamped() {31        #expect(budget.usageRatio(estimatedTokens: budget.windowSize * 2) == 1)32        #expect(budget.usageRatio(estimatedTokens: 0) == 0)33    }3435    @Test func estimatorOvercountsRatherThanUndercounts() {36        // ~3 chars/token is pessimistic for French (~3.5–4 real).37        let text = String(repeating: "bonjour tout le monde ", count: 50)38        #expect(TokenEstimator.tokens(in: text) >= text.count / 4)39    }40}41