1 /*
2  * Copyright (c) 2021-2022 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 
18 #define private public
19 #define protected public
20 #include "short_wrapper.h"
21 #undef private
22 #undef protected
23 
24 using namespace OHOS;
25 using namespace OHOS::AAFwk;
26 using testing::ext::TestSize;
27 
28 namespace OHOS {
29 namespace AAFwk {
30 class AAfWKShortWrapperTest : public testing::Test {
31 public:
SetUpTestCase()32     static void SetUpTestCase() {};
TearDownTestCase()33     static void TearDownTestCase() {};
SetUp()34     void SetUp() {};
TearDown()35     void TearDown() {};
36 };
37 
38 /**
39  * @tc.number: ZcharWrapperTest_GetValue_001
40  * @tc.name: GetValue
41  * @tc.desc:
42  */
43 HWTEST_F(AAfWKShortWrapperTest, ShortWrapperTest_GetValue_001, TestSize.Level1)
44 {
45     short value = 0;
46     Short shortValue(value);
47     ErrCode result = shortValue.GetValue(value);
48     EXPECT_EQ(ERR_OK, result);
49 }
50 
51 /**
52  * @tc.number: ZcharWrapperTest_ToString_001
53  * @tc.name: ToString
54  * @tc.desc:
55  */
56 HWTEST_F(AAfWKShortWrapperTest, ShortWrapperTest_ToString_001, TestSize.Level1)
57 {
58     short value = 0;
59     Short shortValue(value);
60     EXPECT_EQ("0", shortValue.ToString());
61 }
62 
63 /**
64  * @tc.number: ZcharWrapperTest_Box_001
65  * @tc.name: Box
66  * @tc.desc:
67  */
68 HWTEST_F(AAfWKShortWrapperTest, ShortWrapperTest_Box_001, TestSize.Level1)
69 {
70     short value = 0;
71     Short shortValue(value);
72     short result = shortValue.Unbox(shortValue.Box(value));
73     EXPECT_EQ(0, result);
74 }
75 
76 /**
77  * @tc.number: ZcharWrapperTest_Ubox_001
78  * @tc.name: Box
79  * @tc.desc:
80  */
81 HWTEST_F(AAfWKShortWrapperTest, ShortWrapperTest_Ubox_001, TestSize.Level1)
82 {
83 
84     short value = 0;
85     Short shortValue(value);
86     short result = shortValue.Unbox(shortValue.Box(value));
87     EXPECT_EQ(0, result);
88 }
89 
90 /**
91  * @tc.number: ZcharWrapperTest_Parse_001
92  * @tc.name: Parse
93  * @tc.desc:
94  */
95 HWTEST_F(AAfWKShortWrapperTest, ShortWrapperTest_Parse_001, TestSize.Level1)
96 {
97     short value = 0;
98     Short shortValue(value);
99     short result = shortValue.Unbox(shortValue.Parse(shortValue.ToString()));
100     EXPECT_EQ(0, result);
101 }
102 }
103 }