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
16 #include "detector.h"
17 #include <gtest/gtest.h>
18
19 using namespace testing::ext;
20
21 class DetectorPrimeTest : public testing::Test {
22 public:
23 static void SetUpTestCase(void);
24 static void TearDownTestCase(void);
25 void SetUp();
26 void TearDown();
27 };
28
SetUpTestCase(void)29 void DetectorPrimeTest::SetUpTestCase(void)
30 {
31 // step 2: input testsuit setup step
32 }
33
TearDownTestCase(void)34 void DetectorPrimeTest::TearDownTestCase(void)
35 {
36 // step 2: input testsuit teardown step
37 }
38
SetUp(void)39 void DetectorPrimeTest::SetUp(void)
40 {
41 // step 3: input testcase setup step
42 }
43
TearDown(void)44 void DetectorPrimeTest::TearDown(void)
45 {
46 // step 3: input testcase teardown step
47 }
48
49 /**
50 * @tc.name: check_prime_number_01
51 * @tc.desc: Check if the specified element is prime.
52 * @tc.type: FUNC
53 * @tc.require: AR00000000 SR00000000
54 */
55 HWTEST_F(DetectorPrimeTest, check_prime_number_01, TestSize.Level1)
56 {
57 EXPECT_FALSE(IsPrime(6));
58 }
59
60 /**
61 * @tc.name: check_prime_number_02
62 * @tc.desc: Check if the specified element is prime.
63 * @tc.type: FUNC
64 * @tc.require: AR00000000 SR00000000
65 */
66 HWTEST_F(DetectorPrimeTest, check_prime_number_02, TestSize.Level3)
67 {
68 EXPECT_TRUE(IsPrime(3)) << "This is the test information.";
69 }
70
71 /**
72 * @tc.name: check_prime_number_03
73 * @tc.desc: Check if the specified element is prime.
74 * @tc.type: FUNC
75 * @tc.require: AR00000000 SR00000000
76 */
77 HWTEST_F(DetectorPrimeTest, check_prime_number_03, TestSize.Level3)
78 {
79 printf("check_prime_number_03 start.\n");
80 EXPECT_FALSE(IsPrime(0));
81 printf("check_prime_number_03 finish.\n");
82 }
83
84 /**
85 * @tc.name: check_prime_number_04
86 * @tc.desc: Check if the specified element is prime.
87 * @tc.type: FUNC
88 * @tc.require: AR00000000 SR00000000
89 */
90 HWTEST_F(DetectorPrimeTest, check_prime_number_04, TestSize.Level1)
91 {
92 EXPECT_FALSE(IsPrime(-5));
93 }
94
95 /**
96 * @tc.name: check_prime_number_05
97 * @tc.desc: Check if the specified element is prime.
98 * @tc.type: FUNC
99 * @tc.require: AR00000000 SR00000000
100 */
101 HWTEST_F(DetectorPrimeTest, check_prime_number_05, TestSize.Level2)
102 {
103 EXPECT_FALSE(IsPrime(-100));
104 }
105
106 /**
107 * @tc.name: check_prime_number_06
108 * @tc.desc: Check if the specified element is prime.
109 * @tc.type: FUNC
110 * @tc.require: AR00000000 SR00000000
111 */
112 HWTEST_F(DetectorPrimeTest, check_prime_number_06, TestSize.Level2)
113 {
114 EXPECT_FALSE(IsPrime(INT_MIN));
115 }
116