mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-06 17:35:30 +08:00
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
//go:build !386 && !arm && !mips && !mipsle && !wasm
|
|
|
|
package util
|
|
|
|
import "testing"
|
|
|
|
func TestTokenizerEncodingForCountCachesSupportedModel(t *testing.T) {
|
|
encoding, release := tokenizerEncodingForCount(defaultTokenizerModel)
|
|
if encoding == nil {
|
|
t.Fatalf("expected tokenizer encoding for %q", defaultTokenizerModel)
|
|
}
|
|
release()
|
|
|
|
if _, ok := tokenEncodingPools.Load(defaultTokenizerModel); !ok {
|
|
t.Fatalf("expected tokenizer encoding pool for %q", defaultTokenizerModel)
|
|
}
|
|
|
|
encoding, release = tokenizerEncodingForCount(defaultTokenizerModel)
|
|
if encoding == nil {
|
|
t.Fatalf("expected cached tokenizer encoding for %q", defaultTokenizerModel)
|
|
}
|
|
release()
|
|
}
|
|
|
|
func TestTokenizerEncodingForCountCachesUnsupportedModel(t *testing.T) {
|
|
const model = "__ds2api_unsupported_tokenizer_model__"
|
|
encoding, release := tokenizerEncodingForCount(model)
|
|
release()
|
|
if encoding != nil {
|
|
t.Fatalf("expected nil encoding for unsupported model %q", model)
|
|
}
|
|
if _, ok := tokenEncodingUnsupported.Load(model); !ok {
|
|
t.Fatalf("expected unsupported tokenizer model to be cached")
|
|
}
|
|
}
|