1 /*
2  * Copyright (c) 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 <info/application_target_sdk_version.h>
17 
18 #include <string.h>
19 #include <test.h>
20 
21 // val1 == val2
22 #define EXPECT_EQ(a, b) do { \
23     if ((a) != (b)) \
24         t_error("failed %d != %d \n", a, b); \
25 } while (0)
26 typedef void (*TEST_FUN)(void);
27 
28 /**
29  * @tc.name      : set_application_target_sdk_version
30  * @tc.desc      : Test the function of set_application_target_sdk_version.
31  * @tc.level     : Level 0
32  */
33 
set_application_target_sdk_version_0010(void)34 static void set_application_target_sdk_version_0010(void)
35 {
36     set_application_target_sdk_version(SDK_VERSION_7);
37     int target = get_application_target_sdk_version();
38     EXPECT_EQ(target, SDK_VERSION_7);
39 }
40 
41 /**
42  * @tc.name      : get_application_target_sdk_version
43  * @tc.desc      : Test the function of get_application_target_sdk_version.
44  * @tc.level     : Level 0
45  */
get_application_target_sdk_version_0010(void)46 static void get_application_target_sdk_version_0010(void)
47 {
48     set_application_target_sdk_version(SDK_VERSION_8);
49     int target = get_application_target_sdk_version();
50     EXPECT_EQ(target, SDK_VERSION_8);
51 }
52 
53 /**
54  * @tc.name      : set_application_target_sdk_version
55  * @tc.desc      : Test the function of set_application_target_sdk_version.
56  * @tc.level     : Level 0
57  */
set_application_target_sdk_version_0020(void)58 static void set_application_target_sdk_version_0020(void)
59 {
60     set_application_target_sdk_version(0);
61     int target = get_application_target_sdk_version();
62     EXPECT_EQ(target, SDK_VERSION_FUTURE);
63 }
64 
65 TEST_FUN G_Fun_Array[] = {
66     set_application_target_sdk_version_0010,
67     get_application_target_sdk_version_0010,
68     set_application_target_sdk_version_0020
69 };
70 
main(void)71 int main(void)
72 {
73     int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
74     for (int pos = 0; pos < num; ++pos) {
75         G_Fun_Array[pos]();
76     }
77 
78     return t_status;
79 }