• 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 using namespace std;
19 
20 namespace {
21     // 测试默认构造函数是否被删除
TEST(ModelManagerTest,DefaultConstructorDeletedTest)22     TEST(ModelManagerTest, DefaultConstructorDeletedTest)
23     {
24         EXPECT_TRUE(std::is_default_constructible<ModelManager>::value == false);
25     }
26 
27     // 测试赋值运算符是否被删除
TEST(ModelManagerTest,AssignmentOperatorDeletedTest)28     TEST(ModelManagerTest, AssignmentOperatorDeletedTest)
29     {
30         EXPECT_TRUE(std::is_copy_assignable<ModelManager>::value == false);
31     }
32 
TEST(ModelManagerTest,SetCurrentDeviceTest)33     TEST(ModelManagerTest, SetCurrentDeviceTest)
34     {
35         std::string device = "liteWearable";
36         ModelManager::SetCurrentDevice(device);
37         EXPECT_EQ(ModelManager::GetCurrentModel(), device);
38         const ModelConfig& config = ModelManager::GetConfig();
39         EXPECT_EQ(config.deviceType, device);
40     }
41 
TEST(ModelManagerTest,GetAllModelNameTest)42     TEST(ModelManagerTest, GetAllModelNameTest)
43     {
44         std::string devices = "*** *** ";
45         std::string names = ModelManager::GetAllModelName();
46         EXPECT_EQ(names, devices);
47     }
48 
TEST(ModelManagerTest,GetConfigByDeviceTest)49     TEST(ModelManagerTest, GetConfigByDeviceTest)
50     {
51         std::string device = "smartVision";
52         const ModelConfig& config = ModelManager::GetConfig(device);
53         EXPECT_EQ(config.deviceType, device);
54     }
55 }