-
Notifications
You must be signed in to change notification settings - Fork 1
/
codec_test.go
44 lines (39 loc) · 924 Bytes
/
codec_test.go
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
37
38
39
40
41
42
43
44
package tiktoken
import (
"errors"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestConvertToMergeableBPERanks(t *testing.T) {
testCases := []struct {
name string
bpeContent string
expectedRanks map[string]uint
expectedErr error
}{
{
name: "Valid BPE content",
bpeContent: "YmFzZQ== 101\ncGFzc3dvcmQ= 1",
expectedRanks: map[string]uint{
"base": 101,
"password": 1,
},
expectedErr: nil,
},
{
name: "Empty BPE content",
bpeContent: "",
expectedRanks: nil,
expectedErr: errors.New("empty bpe file"),
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
reader := strings.NewReader(tc.bpeContent)
ranks, err := ConvertToMergeableBPERanks(reader)
assert.Equal(t, tc.expectedErr, err, "Unexpected error")
assert.Equal(t, tc.expectedRanks, ranks, "Unexpected ranks")
})
}
}