1e0857b17Sopenharmony_ci/*
2e0857b17Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3e0857b17Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0857b17Sopenharmony_ci * you may not use this file except in compliance with the License.
5e0857b17Sopenharmony_ci * You may obtain a copy of the License at
6e0857b17Sopenharmony_ci *
7e0857b17Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0857b17Sopenharmony_ci *
9e0857b17Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0857b17Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0857b17Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0857b17Sopenharmony_ci * See the License for the specific language governing permissions and
13e0857b17Sopenharmony_ci * limitations under the License.
14e0857b17Sopenharmony_ci */
15e0857b17Sopenharmony_ci
16e0857b17Sopenharmony_ci#include <gtest/gtest.h>
17e0857b17Sopenharmony_ci
18e0857b17Sopenharmony_ci#define private public
19e0857b17Sopenharmony_ci#define protected public
20e0857b17Sopenharmony_ci#include "double_wrapper.h"
21e0857b17Sopenharmony_ci#undef private
22e0857b17Sopenharmony_ci#undef protected
23e0857b17Sopenharmony_ci
24e0857b17Sopenharmony_ciusing namespace OHOS;
25e0857b17Sopenharmony_ciusing namespace OHOS::AAFwk;
26e0857b17Sopenharmony_ciusing testing::ext::TestSize;
27e0857b17Sopenharmony_ci
28e0857b17Sopenharmony_cinamespace OHOS {
29e0857b17Sopenharmony_cinamespace AAFwk {
30e0857b17Sopenharmony_ciclass AAfWKDoubleWrapperTest : public testing::Test {
31e0857b17Sopenharmony_cipublic:
32e0857b17Sopenharmony_ci    static void SetUpTestCase() {};
33e0857b17Sopenharmony_ci    static void TearDownTestCase() {};
34e0857b17Sopenharmony_ci    void SetUp() {};
35e0857b17Sopenharmony_ci    void TearDown() {};
36e0857b17Sopenharmony_ci};
37e0857b17Sopenharmony_ci
38e0857b17Sopenharmony_ci/**
39e0857b17Sopenharmony_ci * @tc.number: DoubleWrapperTest_GetValue_001
40e0857b17Sopenharmony_ci * @tc.name: GetValue
41e0857b17Sopenharmony_ci * @tc.desc:
42e0857b17Sopenharmony_ci */
43e0857b17Sopenharmony_ciHWTEST_F(AAfWKDoubleWrapperTest, DoubleWrapperTest_GetValue_001, TestSize.Level1)
44e0857b17Sopenharmony_ci{
45e0857b17Sopenharmony_ci  double value = 1000;
46e0857b17Sopenharmony_ci  Double db(value);
47e0857b17Sopenharmony_ci  ErrCode result = db.GetValue(value);
48e0857b17Sopenharmony_ci  EXPECT_EQ(ERR_OK, result);
49e0857b17Sopenharmony_ci}
50e0857b17Sopenharmony_ci
51e0857b17Sopenharmony_ci/**
52e0857b17Sopenharmony_ci * @tc.number: DoubleWrapperTest_ToString_001
53e0857b17Sopenharmony_ci * @tc.name: ToString
54e0857b17Sopenharmony_ci * @tc.desc:
55e0857b17Sopenharmony_ci */
56e0857b17Sopenharmony_ciHWTEST_F(AAfWKDoubleWrapperTest, DoubleWrapperTest_ToString_001, TestSize.Level1)
57e0857b17Sopenharmony_ci{
58e0857b17Sopenharmony_ci  double value = 1000;
59e0857b17Sopenharmony_ci  Double db(value);
60e0857b17Sopenharmony_ci  EXPECT_EQ("1000.000000", db.ToString());
61e0857b17Sopenharmony_ci}
62e0857b17Sopenharmony_ci
63e0857b17Sopenharmony_ci/**
64e0857b17Sopenharmony_ci * @tc.number: DoubleWrapperTest_Box_001
65e0857b17Sopenharmony_ci * @tc.name: Box
66e0857b17Sopenharmony_ci * @tc.desc:
67e0857b17Sopenharmony_ci */
68e0857b17Sopenharmony_ciHWTEST_F(AAfWKDoubleWrapperTest, DoubleWrapperTest_Box_001, TestSize.Level1)
69e0857b17Sopenharmony_ci{
70e0857b17Sopenharmony_ci  double value = 1000;
71e0857b17Sopenharmony_ci  Double db(value);
72e0857b17Sopenharmony_ci  double result = db.Unbox(db.Box(value));
73e0857b17Sopenharmony_ci  EXPECT_EQ(1000, result);
74e0857b17Sopenharmony_ci}
75e0857b17Sopenharmony_ci
76e0857b17Sopenharmony_ci/**
77e0857b17Sopenharmony_ci * @tc.number: DoubleWrapperTest_Parse_001
78e0857b17Sopenharmony_ci * @tc.name: Parse
79e0857b17Sopenharmony_ci * @tc.desc:
80e0857b17Sopenharmony_ci */
81e0857b17Sopenharmony_ciHWTEST_F(AAfWKDoubleWrapperTest, DoubleWrapperTest_Parse_001, TestSize.Level1)
82e0857b17Sopenharmony_ci{
83e0857b17Sopenharmony_ci  double value = 1000;
84e0857b17Sopenharmony_ci  Double db(value);
85e0857b17Sopenharmony_ci  double result = db.Unbox(db.Parse(db.ToString()));
86e0857b17Sopenharmony_ci  EXPECT_EQ(1000, result);
87e0857b17Sopenharmony_ci}
88e0857b17Sopenharmony_ci
89e0857b17Sopenharmony_ci/**
90e0857b17Sopenharmony_ci * @tc.number: DoubleWrapperTest_Parse_002
91e0857b17Sopenharmony_ci * @tc.name: Parse
92e0857b17Sopenharmony_ci * @tc.desc:
93e0857b17Sopenharmony_ci */
94e0857b17Sopenharmony_ciHWTEST_F(AAfWKDoubleWrapperTest, DoubleWrapperTest_Parse_002, TestSize.Level1)
95e0857b17Sopenharmony_ci{
96e0857b17Sopenharmony_ci    double value = 3.14;
97e0857b17Sopenharmony_ci    Double db(value);
98e0857b17Sopenharmony_ci    double result = db.Unbox(db.Parse(db.ToString()));
99e0857b17Sopenharmony_ci    EXPECT_EQ(3.14, result);
100e0857b17Sopenharmony_ci}
101e0857b17Sopenharmony_ci}
102e0857b17Sopenharmony_ci}