1 /*
2 * Copyright (C) 2021 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 #include "ut_common.h"
16 using namespace Hdc;
17
18 namespace HdcTest {
TEST(HdcBaseFunction,HandleNoneZeroInput)19 TEST(HdcBaseFunction, HandleNoneZeroInput)
20 {
21 char bufString[256] = "";
22 uint16_t num;
23 int argc = 0;
24 GTEST_ASSERT_LE(1, Base::GetRuntimeMSec());
25 GTEST_ASSERT_LE(10, Base::GetRandomNum(10, 12));
26 GTEST_ASSERT_EQ(0, Base::ConnectKey2IPPort("127.0.0.1:8080", bufString, &num));
27
28 Base::SplitCommandToArgs("xx p1 p2 p3", &argc);
29 GTEST_ASSERT_EQ(4, argc);
30 }
31
TEST(HdcBaseCommand,HandleNoneZeroInput)32 TEST(HdcBaseCommand, HandleNoneZeroInput)
33 {
34 Runtime *ftest = new Runtime();
35 GTEST_ASSERT_EQ(true, ftest->Initial(false));
36 GTEST_ASSERT_EQ(true, ftest->CheckEntry(ftest->UT_MOD_BASE));
37 delete ftest;
38 }
39
TEST(HdcShellMod,HandleNoneZeroInput)40 TEST(HdcShellMod, HandleNoneZeroInput)
41 {
42 Runtime *ftest = new Runtime();
43 GTEST_ASSERT_EQ(true, ftest->Initial(true));
44 GTEST_ASSERT_EQ(true, ftest->CheckEntry(ftest->UT_MOD_SHELL));
45 delete ftest;
46 }
47
TEST(HdcFileCommand,HandleNoneZeroInput)48 TEST(HdcFileCommand, HandleNoneZeroInput)
49 {
50 Runtime *ftest = new Runtime();
51 GTEST_ASSERT_EQ(true, ftest->Initial(true));
52 GTEST_ASSERT_EQ(true, ftest->CheckEntry(ftest->UT_MOD_FILE));
53 delete ftest;
54 }
55
TEST(HdcForwardCommand,HandleNoneZeroInput)56 TEST(HdcForwardCommand, HandleNoneZeroInput)
57 {
58 Runtime *ftest = new Runtime();
59 GTEST_ASSERT_EQ(true, ftest->Initial(true));
60 GTEST_ASSERT_EQ(true, ftest->CheckEntry(ftest->UT_MOD_FORWARD));
61 delete ftest;
62 }
63
TEST(AppCommand,HandleNoneZeroInput)64 TEST(AppCommand, HandleNoneZeroInput)
65 {
66 Runtime *ftest = new Runtime();
67 GTEST_ASSERT_EQ(true, ftest->Initial(true));
68 GTEST_ASSERT_EQ(true, ftest->CheckEntry(ftest->UT_MOD_APP));
69 delete ftest;
70 }
71 } // namespace HdcTest
72
main(int argc,const char * argv[])73 int main(int argc, const char *argv[])
74 {
75 int ret = 0;
76 // many feature under Win32 UT is not supported, so we cannot support it when unit test
77 #ifdef _WIN32
78 printf("Unit test not support win32 platform\r\n");
79 return 0;
80 #else
81 testing::InitGoogleTest(&argc, (char **)argv);
82 ret = RUN_ALL_TESTS();
83 WRITE_LOG(LOG_INFO, "Test all finish");
84 #endif
85 return ret;
86 }