File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 28
28
29
29
# Run unit tests
30
30
RESOURCES_PATH=test/resources build/sentencepiece_test
31
+ build/tiktoken_test
Original file line number Diff line number Diff line change @@ -53,4 +53,9 @@ if(TOKENIZERS_BUILD_TEST)
53
53
sentencepiece_test PUBLIC third-party/sentencepiece/src
54
54
third-party/sentencepiece include GTEST_INCLUDE_PATH )
55
55
target_link_libraries (sentencepiece_test PUBLIC tokenizers gtest_main )
56
+
57
+ # tiktoken tests
58
+ add_executable (tiktoken_test test /test_base64.cpp )
59
+ target_include_directories (tiktoken_test PUBLIC include GTEST_INCLUDE_PATH )
60
+ target_link_libraries (tiktoken_test PUBLIC gtest_main )
56
61
endif ()
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ #include " base64.h"
10
+ #include " gtest/gtest.h"
11
+
12
+ namespace tokenizers {
13
+
14
+ TEST (Base64Test, TestDecodeSmoke) {
15
+ std::string text = " bGxhbWE=" ;
16
+ auto result = base64::decode (text);
17
+ EXPECT_TRUE (result.ok ());
18
+ EXPECT_EQ (result.get (), " llama" );
19
+ }
20
+
21
+ TEST (Base64Test, TestDecodeEmptyStringReturnsError) {
22
+ std::string text = " " ;
23
+ auto result = base64::decode (text);
24
+ EXPECT_FALSE (result.ok ());
25
+ EXPECT_EQ (result.error (), Error::Base64DecodeFailure);
26
+ }
27
+
28
+ TEST (Base64Test, TestInvalidStringDecodeReturnsError) {
29
+ std::string text = " llama" ;
30
+ auto result = base64::decode (text);
31
+ EXPECT_FALSE (result.ok ());
32
+ EXPECT_EQ (result.error (), Error::Base64DecodeFailure);
33
+ }
34
+
35
+ } // namespace tokenizers
You can’t perform that action at this time.
0 commit comments