MCPcopy Create free account
hub / github.com/astercloud/aster / TestSimpleTokenCounter_CountBatch

Function TestSimpleTokenCounter_CountBatch

pkg/context/token_counter_test.go:68–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestSimpleTokenCounter_CountBatch(t *testing.T) {
69 counter := NewGPT4Counter()
70 texts := []string{
71 "Hello",
72 "World",
73 "This is a test",
74 "",
75 }
76
77 counts, err := counter.CountBatch(context.Background(), texts)
78 if err != nil {
79 t.Fatalf("CountBatch() error = %v", err)
80 }
81
82 if len(counts) != len(texts) {
83 t.Errorf("CountBatch() returned %d counts, want %d", len(counts), len(texts))
84 }
85
86 // 验证空字符串返回 0
87 if counts[3] != 0 {
88 t.Errorf("CountBatch() for empty string = %v, want 0", counts[3])
89 }
90
91 // 验证非空字符串返回 > 0
92 for i := range 3 {
93 if counts[i] <= 0 {
94 t.Errorf("CountBatch() for text[%d] = %v, want > 0", i, counts[i])
95 }
96 }
97}
98
99func TestSimpleTokenCounter_CountBatch_Empty(t *testing.T) {
100 counter := NewGPT4Counter()

Callers

nothing calls this directly

Calls 2

NewGPT4CounterFunction · 0.85
CountBatchMethod · 0.65

Tested by

no test coverage detected