• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "gtest/gtest.h"
17 #include "ModelManager.h"
18 
19 namespace {
20     // 测试默认构造函数是否被删除
TEST(ModelManagerTest,DefaultConstructorDeletedTest)21     TEST(ModelManagerTest, DefaultConstructorDeletedTest)
22     {
23         EXPECT_TRUE(std::is_default_constructible<ModelManager>::value == false);
24     }
25 
26     // 测试赋值运算符是否被删除
TEST(ModelManagerTest,AssignmentOperatorDeletedTest)27     TEST(ModelManagerTest, AssignmentOperatorDeletedTest)
28     {
29         EXPECT_TRUE(std::is_copy_assignable<ModelManager>::value == false);
30     }
31 
TEST(ModelManagerTest,SetCurrentDeviceTest)32     TEST(ModelManagerTest, SetCurrentDeviceTest)
33     {
34         std::string device = "liteWearable";
35         ModelManager::SetCurrentDevice(device);
36         EXPECT_EQ(ModelManager::GetCurrentModel(), device);
37         const ModelConfig& config = ModelManager::GetConfig();
38         EXPECT_EQ(config.deviceType, device);
39     }
40 
TEST(ModelManagerTest,GetAllModelNameTest)41     TEST(ModelManagerTest, GetAllModelNameTest)
42     {
43         std::string devices = "*** *** ";
44         std::string names = ModelManager::GetAllModelName();
45         EXPECT_EQ(names, devices);
46     }
47 
TEST(ModelManagerTest,GetConfigByDeviceTest)48     TEST(ModelManagerTest, GetConfigByDeviceTest)
49     {
50         std::string device = "smartVision";
51         const ModelConfig& config = ModelManager::GetConfig(device);
52         EXPECT_EQ(config.deviceType, device);
53     }
54 }