File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: Apache-2.0
2+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3+
4+
5+ from vllm .v1 .outputs import (
6+ convert_to_token_id_list ,
7+ convert_to_token_ids ,
8+ get_token_count ,
9+ )
10+
11+
12+ def test_convert_to_token_id_list ():
13+ assert convert_to_token_id_list (1 ) == [1 ]
14+ assert convert_to_token_id_list (2 ) == [2 ]
15+
16+ # Return the original list back without creating new lists
17+ vs = [3 , 4 ]
18+ assert convert_to_token_id_list (vs ) is vs
19+ vs = [5 , 6 , 7 ]
20+ assert convert_to_token_id_list (vs ) is vs
21+
22+
23+ def test_convert_to_token_ids ():
24+ assert convert_to_token_ids ([10 ]) == 10
25+ assert convert_to_token_ids ([20 ]) == 20
26+
27+ # Return the original list back without creating new lists
28+ vs = [30 , 40 ]
29+ assert convert_to_token_ids (vs ) is vs
30+ vs = [50 , 60 , 70 ]
31+ assert convert_to_token_ids (vs ) is vs
32+
33+
34+ def test_get_token_count ():
35+ assert get_token_count (100 ) == 1
36+ assert get_token_count (200 ) == 1
37+ assert get_token_count ([300 ]) == 1
38+ assert get_token_count ([400 , 500 ]) == 2
39+ assert get_token_count ([600 , 700 , 800 ]) == 3
You can’t perform that action at this time.
0 commit comments