1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <stddef.h>
6 #include <stdint.h>
7 
8 #include "base/strings/utf_string_conversions.h"
9 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
10 #include "third_party/blink/public/common/indexeddb/indexeddb_key_path.h"
11 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
13   base::StringPiece key_path_str_piece(reinterpret_cast<const char*>(data),
14                                        size);
15   blink::IndexedDBKeyPath indexed_db_key_path;
16   ignore_result(
17       content::DecodeIDBKeyPath(&key_path_str_piece, &indexed_db_key_path));
18 
19   // Ensure that encoding |indexed_db_key_path| produces the same result.
20   std::string result;
21   content::EncodeIDBKeyPath(indexed_db_key_path, &result);
22   assert(base::StringPiece(result) == key_path_str_piece);
23   return 0;
24 }
25