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 "fusioncontroller_fuzzer.h"
17
18 #include "message_parcel.h"
19 #include "fusion_controller.h"
20 #include "location.h"
21
22 namespace OHOS {
23 using namespace OHOS::Location;
24 const int MIN_DATA_LEN = 1;
FusionControllerFuzzerTest(const uint8_t * data,size_t size)25 bool FusionControllerFuzzerTest(const uint8_t* data, size_t size)
26 {
27 if (size < MIN_DATA_LEN) {
28 return true;
29 }
30 std::unique_ptr<OHOS::Location::Location> location =
31 std::make_unique<OHOS::Location::Location>();
32 MessageParcel messageParcel;
33 location->Unmarshalling(messageParcel);
34 location->UnmarshallingShared(messageParcel);
35 location->Marshalling(messageParcel);
36 PoiInfo poiInfo;
37 location->WritePoiInfoToParcel(poiInfo, messageParcel);
38 location->ToString();
39 location->LocationEqual(location);
40 location->AdditionEqual(location);
41 location->isValidLatitude(0.0);
42 location->isValidLongitude(0.0);
43 location->GetDistanceBetweenLocations(0.0, 0.0, 0.0, 0.0);
44 std::shared_ptr<FusionController> fusionController =
45 std::make_shared<FusionController>();
46 int index = 0;
47 fusionController->ActiveFusionStrategies(data[index++]);
48 return true;
49 }
50 }
51
52 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)53 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
54 {
55 /* Run your code on data */
56 OHOS::FusionControllerFuzzerTest(data, size);
57 return 0;
58 }