MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / fuzzJsonOperations

Method fuzzJsonOperations

fuzzing/bb_fuzzer.cpp:165–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163 }
164
165 void fuzzJsonOperations(BT::Blackboard::Ptr bb)
166 {
167 try
168 {
169 auto json = BT::ExportBlackboardToJSON(*bb);
170 if(fuzz_data_.ConsumeBool())
171 {
172 std::string json_str = json.dump();
173 size_t pos = fuzz_data_.ConsumeIntegralInRange<size_t>(0, json_str.length());
174 json_str.insert(pos, fuzz_data_.ConsumeRandomLengthString());
175 json = nlohmann::json::parse(json_str);
176 }
177 BT::ImportBlackboardFromJSON(json, *bb);
178 }
179 catch(const std::exception& e)
180 {
181 if(!ExceptionFilter::isExpectedException(e))
182 {
183 throw;
184 }
185 }
186 }
187
188public:
189 explicit BlackboardFuzzer(FuzzedDataProvider& provider) : fuzz_data_(provider)

Callers

nothing calls this directly

Calls 4

ExportBlackboardToJSONFunction · 0.85
parseFunction · 0.85
ImportBlackboardFromJSONFunction · 0.85
dumpMethod · 0.80

Tested by

no test coverage detected