-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConversationRolledSummaryLimiterEditModeTests.cs
More file actions
36 lines (33 loc) · 1.22 KB
/
ConversationRolledSummaryLimiterEditModeTests.cs
File metadata and controls
36 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using CoreAI.Ai;
using NUnit.Framework;
namespace CoreAI.Tests.EditMode
{
public sealed class ConversationRolledSummaryLimiterEditModeTests
{
[Test]
public void Apply_WhenUnderCap_ReturnsTrimmedInputUnchanged()
{
HeuristicTokenEstimator est = new();
string text = "hello";
Assert.AreEqual("hello", ConversationRolledSummaryLimiter.Apply(text, est, 100));
}
[Test]
public void Apply_WhenOverCap_TruncatesWithEllipsis()
{
HeuristicTokenEstimator est = new();
string text = new('a', 400);
string cut = ConversationRolledSummaryLimiter.Apply(text, est, 20);
Assert.IsTrue(cut.EndsWith("…"));
Assert.Less(cut.Length, text.Length);
Assert.LessOrEqual(est.EstimateText(cut), est.EstimateText(text));
}
[Test]
public void Apply_ZeroOrNegativeCap_ReturnsOriginal()
{
HeuristicTokenEstimator est = new();
string text = new('b', 500);
Assert.AreEqual(text, ConversationRolledSummaryLimiter.Apply(text, est, 0));
Assert.AreEqual(text, ConversationRolledSummaryLimiter.Apply(text, est, -1));
}
}
}