1 | /** |
2 | * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | * |
16 | * \author guonix |
17 | * \date Nov 2020 |
18 | * \brief |
19 | */ |
20 | |
21 | #include "common/types_helper.h" |
22 | #include <gtest/gtest.h> |
23 | |
24 | using namespace proxima::be; |
25 | |
26 | TEST(DataTypeCodeBookTest, TestGet) { |
27 | ASSERT_EQ(DataTypeCodeBook::Get(proto::DataType::DT_UNDEFINED), |
28 | DataTypes::UNDEFINED); |
29 | |
30 | ASSERT_EQ(DataTypeCodeBook::Get(proto::DataType::DT_VECTOR_BINARY32), |
31 | DataTypes::VECTOR_BINARY32); |
32 | |
33 | ASSERT_EQ(DataTypeCodeBook::Get(proto::DataType::DT_VECTOR_BINARY64), |
34 | DataTypes::VECTOR_BINARY64); |
35 | |
36 | ASSERT_EQ(DataTypeCodeBook::Get(proto::DataType::DT_VECTOR_FP16), |
37 | DataTypes::VECTOR_FP16); |
38 | |
39 | ASSERT_EQ(DataTypeCodeBook::Get(proto::DataType::DT_VECTOR_FP32), |
40 | DataTypes::VECTOR_FP32); |
41 | |
42 | ASSERT_EQ(DataTypeCodeBook::Get(proto::DataType::DT_VECTOR_FP64), |
43 | DataTypes::VECTOR_FP64); |
44 | |
45 | ASSERT_EQ(DataTypeCodeBook::Get(proto::DataType::DT_VECTOR_INT8), |
46 | DataTypes::VECTOR_INT8); |
47 | |
48 | ASSERT_EQ(DataTypeCodeBook::Get(proto::DataType::DT_VECTOR_INT16), |
49 | DataTypes::VECTOR_INT16); |
50 | |
51 | ASSERT_EQ(DataTypeCodeBook::Get(proto::DataType::DT_VECTOR_INT4), |
52 | DataTypes::VECTOR_INT4); |
53 | } |
54 | |
55 | |
56 | TEST(ProtoConverterTest, TestConvertOperationType) { |
57 | ASSERT_EQ(OperationTypesCodeBook::Get(proto::OP_INSERT), |
58 | OperationTypes::INSERT); |
59 | ASSERT_EQ(OperationTypesCodeBook::Get(proto::OP_UPDATE), |
60 | OperationTypes::UPDATE); |
61 | ASSERT_EQ(OperationTypesCodeBook::Get(proto::OP_DELETE), |
62 | OperationTypes::DELETE); |
63 | } |
64 | |